Search in sources :

Example 1 with PipelineHistoryJsonPresentationModel

use of com.thoughtworks.go.server.presentation.models.PipelineHistoryJsonPresentationModel in project gocd by gocd.

the class PipelineHistoryController method list.

@RequestMapping(value = "/**/pipelineHistory.json", method = RequestMethod.GET)
public ModelAndView list(@RequestParam("pipelineName") String pipelineName, @RequestParam(value = "perPage", required = false) Integer perPageParam, @RequestParam(value = "start", required = false) Integer startParam, @RequestParam(value = "labelFilter", required = false) String labelFilter, HttpServletResponse response, HttpServletRequest request) throws NamingException {
    PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(new CaseInsensitiveString(pipelineName));
    String username = CaseInsensitiveString.str(UserHelper.getUserName().getUsername());
    Pagination pagination;
    try {
        pagination = Pagination.pageStartingAt(startParam, pipelineHistoryService.totalCount(pipelineName), perPageParam);
    } catch (Exception e) {
        Map<String, Object> json = new LinkedHashMap<>();
        addDeveloperErrorMessage(json, e);
        return jsonNotAcceptable(json).respond(response);
    }
    PipelinePauseInfo pauseInfo = pipelinePauseService.pipelinePauseInfo(pipelineName);
    boolean hasBuildCauseInBuffer = pipelineScheduleQueue.hasBuildCause(CaseInsensitiveString.str(pipelineConfig.name()));
    PipelineInstanceModels pipelineHistory = StringUtil.isBlank(labelFilter) ? pipelineHistoryService.load(pipelineName, pagination, username, true) : pipelineHistoryService.findMatchingPipelineInstances(pipelineName, labelFilter, perPageParam, UserHelper.getUserName(), new HttpLocalizedOperationResult());
    boolean hasForcedBuildCause = pipelineScheduleQueue.hasForcedBuildCause(pipelineName);
    PipelineHistoryJsonPresentationModel historyJsonPresenter = new PipelineHistoryJsonPresentationModel(pauseInfo, pipelineHistory, pipelineConfig, pagination, canForce(pipelineConfig, username), hasForcedBuildCause, hasBuildCauseInBuffer, canPause(pipelineConfig, username));
    return jsonFound(historyJsonPresenter.toJson()).respond(response);
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels) PipelineHistoryJsonPresentationModel(com.thoughtworks.go.server.presentation.models.PipelineHistoryJsonPresentationModel) PipelinePauseInfo(com.thoughtworks.go.domain.PipelinePauseInfo) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) NamingException(javax.naming.NamingException) PipelineNotFoundException(com.thoughtworks.go.config.PipelineNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 PipelineNotFoundException (com.thoughtworks.go.config.PipelineNotFoundException)1 PipelinePauseInfo (com.thoughtworks.go.domain.PipelinePauseInfo)1 PipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels)1 PipelineHistoryJsonPresentationModel (com.thoughtworks.go.server.presentation.models.PipelineHistoryJsonPresentationModel)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 Pagination (com.thoughtworks.go.server.util.Pagination)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 NamingException (javax.naming.NamingException)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1