All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.nemerosa.ontrack.boot.ui.InfoController Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.boot.ui;

import net.nemerosa.ontrack.model.structure.Info;
import net.nemerosa.ontrack.model.structure.InfoService;
import net.nemerosa.ontrack.model.support.ApplicationInfo;
import net.nemerosa.ontrack.model.support.ApplicationInfoService;
import net.nemerosa.ontrack.ui.controller.AbstractResourceController;
import net.nemerosa.ontrack.ui.resource.Resource;
import net.nemerosa.ontrack.ui.resource.Resources;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.on;

@RestController
@RequestMapping("/info")
public class InfoController extends AbstractResourceController {

    private final InfoService infoService;
    private final ApplicationInfoService applicationInfoService;

    @Autowired
    public InfoController(InfoService infoService, ApplicationInfoService applicationInfoService) {
        this.infoService = infoService;
        this.applicationInfoService = applicationInfoService;
    }

    /**
     * General information about the application
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    public Resource info() {
        return Resource.of(
                infoService.getInfo(),
                uri(on(getClass()).info())
        )
                // API links
                .with("user", uri(on(UserController.class).getCurrentUser()))
                        // TODO Structure controller (--> projects, branches, etc.)
                        // Info message
                .with("_applicationInfo", uri(on(InfoController.class).applicationInfo()))
                ;
    }

    /**
     * Messages about the application
     */
    @RequestMapping(value = "application", method = RequestMethod.GET)
    public Resources applicationInfo() {
        return Resources.of(
                applicationInfoService.getApplicationInfoList(),
                uri(on(InfoController.class).applicationInfo())
        );
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy