private boolean pipelineNotFound(String pipelineName, OperationResult result) { if (!goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) { result.notFound(String.format("Pipeline '%s' not found", pipelineName), String.format("Pipeline '%s' not found", pipelineName), HealthStateType.general(HealthStateScope.forPipeline(pipelineName))); return true; } return false; }
@Override public void onEntityConfigChange(PipelineConfig pipelineConfig) { LOGGER.info("[Configuration Changed] Removing deleted jobs for pipeline {}.", pipelineConfig.name()); synchronized (BuildAssignmentService.this) { List<JobPlan> jobsToRemove; if (goConfigService.hasPipelineNamed(pipelineConfig.name())) { jobsToRemove = getMismatchingJobPlansFromUpdatedPipeline(pipelineConfig, jobPlans); } else { jobsToRemove = getAllJobPlansFromDeletedPipeline(pipelineConfig, jobPlans); } IterableUtils.forEach(jobsToRemove, o -> removeJob(o)); } } };
private void removePipelinesThatAreNotInConfig(final Username username, PipelineDependencyGraphOld graph) { graph.filterDependencies(pipelineName -> goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName)) && securityService.hasViewPermissionForPipeline(username, pipelineName)); }
private boolean hasViewPermissionWorkaroundForNonExistantPipelineBug_4477(CaseInsensitiveString pipelineName, Username username) { if (!goConfigService.hasPipelineNamed(pipelineName)) { throw new RecordNotFoundException(); } if (securityService.isUserAdmin(username)) { return true; } // we check if pipeline exists because this method returns true in case the group or pipeline does not exist! return securityService.hasViewPermissionForPipeline(username, pipelineName.toString()); }
public boolean validate(String pipelineName, Username username, OperationResult result) { if (!goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) { String pipelineNotKnown = String.format("Pipeline named [%s] is not known.", pipelineName); result.notFound(pipelineNotKnown, pipelineNotKnown, HealthStateType.general(HealthStateScope.GLOBAL)); return false; } if (!securityService.hasViewPermissionForPipeline(username, pipelineName)) { result.forbidden(NOT_AUTHORIZED_TO_VIEW_PIPELINE, NOT_AUTHORIZED_TO_VIEW_PIPELINE, HealthStateType.general(HealthStateScope.forPipeline(pipelineName))); return false; } return true; }
public ScheduleOptions build(HttpOperationResult result, String pipelineName, PipelineScheduleOptions pipelineScheduleOptions) { ScheduleOptions scheduleOptions = new ScheduleOptions(); HealthStateType healthStateType = HealthStateType.general(HealthStateScope.forPipeline(pipelineName)); if (!goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) { result.notFound(String.format("Pipeline '%s' not found.", pipelineName), "", healthStateType); return null; } for (Builder builder : builders) { if (result.canContinue()) builder.build(scheduleOptions, result, pipelineName, pipelineScheduleOptions, healthStateType); } return scheduleOptions; }
public boolean canUnlock(String pipelineName, Username username, OperationResult result) { if (!goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) { String msg = format("pipeline name %s is incorrect", pipelineName); result.notFound(msg, msg, HealthStateType.general(HealthStateScope.forPipeline(pipelineName))); return false; } if (!securityService.hasOperatePermissionForPipeline(username.getUsername(), pipelineName)) { String msg = "user does not have operate permission on the pipeline"; result.forbidden(msg, msg, HealthStateType.general(HealthStateScope.forPipeline(pipelineName))); return false; } return isUnlockable(pipelineName, result); }
private void removeRevisionsBasedOnPermissionAndCurrentConfig(ValueStreamMap valueStreamMap, Username username) { for (Node node : valueStreamMap.allNodes()) { if (node instanceof PipelineDependencyNode) { String pipelineName = node.getName(); PipelineDependencyNode pipelineDependencyNode = (PipelineDependencyNode) node; if (!goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) { pipelineDependencyNode.setDeleted(); } else if (!securityService.hasViewPermissionForPipeline(username, pipelineName)) { pipelineDependencyNode.setNoPermission(); } pipelineDependencyNode.setCanEdit(goConfigService.canEditPipeline(pipelineName, username)); } } }
if (!goConfigService.hasPipelineNamed(this.pipelineConfig.name())) {
if (!goConfigService.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) { result.notFound(resourceNotFound("pipeline", pipelineName), general(forPipeline(pipelineName))); return new ArrayList<>();