use of com.thoughtworks.go.config.CaseInsensitiveString 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);
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class ScheduleServiceCachedIntegrationTest method shouldUpdateResultOfStageWhenJobCompletes_irrespectiveOfOtherThreadsPrimingStageCache.
@Test
public void shouldUpdateResultOfStageWhenJobCompletes_irrespectiveOfOtherThreadsPrimingStageCache() throws Exception {
Pipeline assigned = preCondition.createPipelineWithFirstStageAssigned();
Stage stage = assigned.findStage(preCondition.devStage);
StageSummaryModel model = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
JobIdentifier identifier = stage.getFirstJob().getIdentifier();
scheduleService.updateJobStatus(identifier, JobState.Building);
scheduleService.jobCompleting(identifier, JobResult.Passed, "uuid");
//priming the cache
Stage stageLoadedByOtherFlows = stageDao.stageById(stage.getId());
scheduleService.updateJobStatus(stage.getFirstJob().getIdentifier(), JobState.Completed);
StageSummaryModel reloadedModel = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
Stage reloadedStage = reloadedModel.getStage();
assertThat(reloadedStage.getFirstJob().getState(), is(JobState.Completed));
assertThat(reloadedStage.getCompletedByTransitionId(), is(reloadedStage.getFirstJob().getTransitions().byState(JobState.Completed).getId()));
assertThat(reloadedStage.getResult(), is(StageResult.Passed));
assertThat(reloadedStage.getState(), is(StageState.Passed));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class ScheduleServiceCachedIntegrationTest method shouldUpdateResultOfStageWhenJobCompletes.
@Test
public void shouldUpdateResultOfStageWhenJobCompletes() throws Exception {
// ScheduleService service = new ScheduleService(goConfigService, pipelineService, stageService, currentActivityService, schedulingChecker, pipelineScheduledTopic, pipelineDao,
// stageDao, stageOrderService, securityService, pipelineScheduleQueue, jobInstanceService, jobInstanceDao, agentAssignment, environmentConfigService,
// pipelineLockService, serverHealthService, transactionTemplate, agentService);
Pipeline assigned = preCondition.createPipelineWithFirstStageAssigned();
Stage stage = assigned.findStage(preCondition.devStage);
StageSummaryModel model = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
assertThat(model.getStage().getFirstJob().getState(), is(JobState.Assigned));
scheduleService.updateJobStatus(stage.getFirstJob().getIdentifier(), JobState.Building);
StageSummaryModel reloadedModel = stageService.findStageSummaryByIdentifier(stage.getIdentifier(), new Username(new CaseInsensitiveString("foo")), new HttpLocalizedOperationResult());
assertThat(reloadedModel.getStage().getFirstJob().getState(), is(JobState.Building));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class ScheduleServiceSecurityTest method shouldReturnAppropriateHttpResultIfTheStageIsInvalid.
@Test
public void shouldReturnAppropriateHttpResultIfTheStageIsInvalid() throws Exception {
configHelper.addSecurityWithAdminConfig();
configHelper.setOperatePermissionForGroup("defaultGroup", "jez");
Username jez = new Username(new CaseInsensitiveString("jez"));
HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
Stage resultStage = scheduleService.cancelAndTriggerRelevantStages(-23l, jez, operationResult);
assertThat(resultStage, is(nullValue()));
assertThat(operationResult.isSuccessful(), is(false));
assertThat(operationResult.httpCode(), is(SC_NOT_FOUND));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class ScheduleServiceSecurityTest method shouldReturnAppropriateHttpResultIfUserDoesNotHaveOperatePermission.
@Test
public void shouldReturnAppropriateHttpResultIfUserDoesNotHaveOperatePermission() throws Exception {
configHelper.addSecurityWithAdminConfig();
configHelper.setOperatePermissionForGroup("defaultGroup", "jez");
Pipeline pipeline = fixture.createPipelineWithFirstStagePassedAndSecondStageRunning();
Username anonymous = new Username(new CaseInsensitiveString("anonymous"));
HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
Stage resultStage = scheduleService.cancelAndTriggerRelevantStages(pipeline.getStages().byName(fixture.ftStage).getId(), anonymous, operationResult);
assertThat(resultStage, is(nullValue()));
assertThat(operationResult.isSuccessful(), is(false));
assertThat(operationResult.httpCode(), is(SC_UNAUTHORIZED));
}
Aggregations