@Override public Project apply(@Nullable final String input) { Long id = new Long(input); ProjectService.GetProjectResult projectResult = projectService.getProjectById(user, id); if (projectResult.isValid()) { return projectResult.getProject(); } return null; } });
final Project project = projectResult.getProject(); final ProjectService.UpdateProjectValidationResult updateValidationResult = projectService.validateUpdateProject(authenticationContext.getUser(), project.getName(), project.getKey(), project.getDescription(), project.getLeadUserName(), project.getUrl(), project.getAssigneeType(), avatarId);
private Optional<Project> getProject() { if (project == null) { ProjectService.GetProjectResult result = projectService.getProjectByIdForAction(getLoggedInApplicationUser(), projectId, ProjectAction.VIEW_PROJECT); project = Optional.fromNullable(result.getProject()); } return project; }
if (!getProjectResult.isValid() || getProjectResult.getProject() == null) Project project = getProjectResult.getProject(); if (!StringUtils.equals(oldKey, newKey))
@Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { final Matcher matcher = PATTERN.matcher(request.getPathInfo()); if (matcher.matches()) { String projectKey = matcher.group(1); final ApplicationUser user = authenticationContext.getUser(); ProjectService.GetProjectResult result = projectService.getProjectByKeyForAction(user, projectKey, ProjectAction.EDIT_PROJECT_CONFIG); if (result.isValid()) { Project project = result.getProject(); final Map<String, Object> context = velocityParamFactory.getDefaultVelocityParams(MapBuilder.<String, Object>newBuilder() .add("project", project) .add(POST_FUNCTIONS_KEY_NAME, getHipChatPostFunctions( project)) .add(HAS_HIP_CHAT_API_TOKEN, hasHipChatApiToken()) .toMap(), authenticationContext ); // The content-type needs to be set so that Sitemesh will decorate responses generated by Velocity correctly. response.setContentType("text/html; charset=UTF-8"); renderer.render("templates/hip-chat-notifications.vm", context, response.getWriter()); } } }
if (result.isValid()) final String encodedKey = urlEncode(result.getProject().getKey()); if (getIssueType() == null)
/** * Retrieve a single project, throwing an exception if the user has no permissions. */ Project retrieveProjectByKey(String projectKey, User user) throws RemoteException { try { final com.atlassian.jira.bc.project.ProjectService.GetProjectResult result = projectService.getProjectByKey(user, projectKey); if (!result.isValid()) { throw new RemoteValidationException("Error retrieving project with key '" + projectKey + "':", result.getErrorCollection()); } else { return result.getProject(); } } catch (DataAccessException e) { throw new RemoteException("Error retrieving project: " + projectKey, e); } }
public Option<Object> apply(String key) { ApplicationUser loggedInUser = jiraAuthenticationContext.getLoggedInUser(); ProjectService.GetProjectResult projectByKey = projectService.getProjectByKey(loggedInUser, key); Option<Object> option; if (projectByKey.isValid()) { option = Option.<Object>some(projectByKey.getProject()); } else { option = Option.none(); } return option; } }
private Project getProjectByIdOrKey(String projectIdOrKey) { final ProjectService.GetProjectResult result = projectFinder.getGetProjectForActionByIdOrKey(authContext.getUser(), projectIdOrKey, ProjectAction.EDIT_PROJECT_CONFIG); if (result.getErrorCollection().hasAnyErrors()) { final ErrorCollection errors = ErrorCollection.of(result.getErrorCollection()); if (result.getErrorCollection().getReasons().contains(com.atlassian.jira.util.ErrorCollection.Reason.FORBIDDEN)) { throw new NotAuthorisedWebException(errors); } else { throw new NotFoundWebException(errors); } } return result.getProject(); }
@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()); }
private Project getProject(final ApplicationUser user, final Long id) { return throw404WhenInvalid(projectService.getProjectById(user, id)).getProject(); }
Project retrieveProjectById(Long id, User user) throws RemoteException { final com.atlassian.jira.bc.project.ProjectService.GetProjectResult result = projectService.getProjectById(user, id); if (!result.isValid()) { throw new RemoteValidationException("Error retrieving project with id '" + id + "':", result.getErrorCollection()); } else { return result.getProject(); } }
private Either<Response, Project> getEitherProjectOrErrors(final String projectIdOrKey, final ProjectAction action) { final ProjectService.GetProjectResult projectResult = projectFinder.getGetProjectForActionByIdOrKey(authContext.getLoggedInUser(), projectIdOrKey, action); if (projectResult.isValid()) { return Either.right(projectResult.getProject()); } return Either.left(responseFactory.errorResponse(projectResult.getErrorCollection())); }
private Project getProject(ProjectComponent component) { ProjectService.GetProjectResult projectResult = projectService.getProjectById(authContext.getUser(), component.getProjectId()); if (!projectResult.isValid()) { throw new NotFoundWebException(ErrorCollection.of(projectResult.getErrorCollection())); } return projectResult.getProject(); } private Project getProjectForAdmin(ProjectComponent component)
private Either<Response, Project> getEitherProjectOrErrors(final String projectIdOrKey, final ProjectAction action) { final ProjectService.GetProjectResult projectResult = projectFinder.getGetProjectForActionByIdOrKey(authContext.getUser(), projectIdOrKey, action); if (!projectResult.isValid()) { return Either.left(responses.errorResponse(projectResult.getErrorCollection())); } return Either.right(projectResult.getProject()); } }
private Project getProject() { ProjectService.GetProjectResult projectResult = getProjectResult(); if (projectResult != null && projectResult.isValid()) { return projectResult.getProject(); } else { return null; } }
@Override public ServiceResult validateUpdateProject(final ApplicationUser user, final String key) { //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 ServiceResultImpl(ErrorCollections.copyOf(oldProjectResult.getErrorCollection())); } return new ServiceResultImpl(ErrorCollections.empty()); }
private Project getProject(ApplicationUser user, Long id) { ProjectService.GetProjectResult projectResult = projectService.getProjectById(user, id); if (projectResult.isValid()) { return projectResult.getProject(); } else { return throwFourOhFour(projectResult.getErrorCollection()); } }
private Project getProjectForAdmin(ProjectComponent component) { ProjectService.GetProjectResult projectResult = projectService.getProjectByIdForAction(authContext.getUser(), component.getProjectId(), EDIT_PROJECT_CONFIG); if (!projectResult.isValid()) { throw new NotFoundWebException(ErrorCollection.of(projectResult.getErrorCollection())); } return projectResult.getProject(); }
private Option<Project> getProject(final String currentProjectId, final ApplicationUser user) { if (StringUtils.isNotBlank(currentProjectId)) { GetProjectResult projectResult = projectFinder.getGetProjectForActionByIdOrKey(user, currentProjectId, ProjectAction.VIEW_ISSUES); return projectResult.isValid() ? some(projectResult.getProject()) : none(Project.class); } return none(Project.class); }