private void notifyHandlersOfProjectCreated(ApplicationUser user, Project newProject, CreateProjectValidationResult result) { final ProjectCreatedData.Builder projectCreatedData = new ProjectCreatedData.Builder().withProject(newProject); Optional.ofNullable(result.getProjectCreationData().getProjectTemplateKey()).ifPresent(projectCreatedData::withProjectTemplateKey); result.getExistingProjectId().ifPresent(projectCreatedData::withExistingProjectId); boolean notificationWasSuccessful = projectCreateNotifier.notifyAllHandlers(projectCreatedData.build()); if (!notificationWasSuccessful) { deleteProject(user, new DeleteProjectValidationResult(ErrorCollections.empty(), newProject)); throw new RuntimeException("An error occurred while notifying that a project was created"); } }
if (!result.isValid()) final Project project = result.getProject(); try
@Override public DeleteProjectValidationResult validateDeleteProject(ApplicationUser user, String key) { final I18nHelper i18nBean = getI18nBean(user); if (!globalPermissionManager.hasPermission(GlobalPermissionKey.ADMINISTER, user)) { return new DeleteProjectValidationResult(ErrorCollections.create(i18nBean.getText("admin.projects.service.error.no.admin.permission"), Reason.FORBIDDEN)); } //check if the project exists. If not return with an error. final GetProjectResult oldProjectResult = getProjectByKeyForAction(user, key, ProjectAction.EDIT_PROJECT_CONFIG); if (!oldProjectResult.isValid() || oldProjectResult.getProject() == null) { return new DeleteProjectValidationResult(ErrorCollections.copyOf(oldProjectResult.getErrorCollection())); } return new DeleteProjectValidationResult(ErrorCollections.empty(), oldProjectResult.getProject()); }
@Override public Response apply(final Project project) { ProjectService.DeleteProjectValidationResult validationResult = projectService.validateDeleteProject(authContext.getUser(), project.getKey()); if (validationResult.isValid()) { ProjectService.DeleteProjectResult result = projectService.deleteProject(authContext.getUser(), validationResult); return result.isValid() ? responses.noContent() : responses.errorResponse(result.getErrorCollection()); } else { return responses.errorResponse(validationResult.getErrorCollection()); } } });
public void deleteProject(User user, String projectKey) throws RemoteException { com.atlassian.jira.bc.project.ProjectService.DeleteProjectValidationResult result = projectService.validateDeleteProject(user, projectKey); if (!result.isValid()) { throw new RemoteValidationException("Error removing project: ", result.getErrorCollection()); } com.atlassian.jira.bc.project.ProjectService.DeleteProjectResult deleteResult = projectService.deleteProject(user, result); if (!deleteResult.isValid()) { throw new RemoteValidationException("Error removing project: ", deleteResult.getErrorCollection()); } }
protected void doValidation() { final Project projectObject = getProject(); if(projectObject == null) { addErrorMessage(getText("admin.deleteproject.error.no.project", pid)); return; } final ProjectService.DeleteProjectValidationResult result = projectService.validateDeleteProject(getLoggedInUser(), projectObject.getKey()); if(!result.isValid()) { addErrorCollection(result.getErrorCollection()); } }