private void pausePipeline(String pipelineName, String pauseCause, Username pauseBy) { String mutexPipelineName = mutexForPausePipeline(pipelineName); synchronized (mutexPipelineName) { String sanitizedPauseCause = pauseCause.substring(0, Math.min(255, pauseCause.length())); String pauseByDisplayName = pauseBy.getDisplayName(); String sanitizedPauseBy = pauseByDisplayName.substring(0, Math.min(255, pauseByDisplayName.length())); pipelineSqlMapDao.pause(pipelineName, sanitizedPauseCause, sanitizedPauseBy); LOGGER.info("[Pipeline Pause] Pipeline [{}] is paused by [{}] because [{}]", pipelineName, pauseBy, pauseCause); notifyListeners(PipelinePauseChangeListener.Event.pause(pipelineName, pauseBy)); } }
public static BuildCause createManualForced(MaterialRevisions materialRevisions, Username username) { if (username == null) { throw new IllegalArgumentException("Username cannot be null"); } String message = String.format("Forced by %s", username.getDisplayName()); return new BuildCause(materialRevisions, BuildTrigger.forForced(message), CaseInsensitiveString.str(username.getUsername())); }
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Username userName = SessionUtils.currentUsername(); String pipeline = pipeline(request); if (authorizedToViewPipeline(userName, pipeline)) { super.service(request, response); return; } response.sendError(SC_FORBIDDEN, String.format("%s is not authorized to view the pipeline %s", userName.getDisplayName(), pipeline)); }
@Override public boolean canContinue(CruiseConfig cruiseConfig) { if (!goConfigService.isAdministrator(username.getUsername())) { result.forbidden(LocalizedMessage.forbiddenToEditResource("environment", environmentConfig.name(), username.getDisplayName()), HealthStateType.forbidden()); return false; } return true; }