projectService.getProjectByKeyForAction(authContext.getUser(), projectKey, VIEW_PROJECT); if (projectResult.getErrorCollection().hasAnyErrors()) final ErrorCollection errors = ErrorCollection.of(projectResult.getErrorCollection()); return Response.status(Response.Status.NOT_FOUND).entity(errors).cacheControl(never()).build(); projects.add(projectResult.getProject());
if (getProjectResult.isValid()) if (!permissionManager.hasPermission(ProjectPermissions.SET_ISSUE_SECURITY, getProjectResult.getProject(), user)) List<IssueSecurityLevel> usersSecurityLevels = issueSecurityLevelManager.getUsersSecurityLevels(getProjectResult.getProject(), user); return responseFactory.okNoCache(SecurityListLevelJsonBean.of(SecurityLevelJsonBean.shortBeans(usersSecurityLevels, baseUrls))); return responseFactory.errorResponse(getProjectResult.getErrorCollection());
@Override public GetProjectResult getProjectByIdForAction(ApplicationUser user, Long id, ProjectAction action) { Project project = projectManager.getProjectObj(id); if (project == null || !checkActionPermission(user, project, ProjectAction.VIEW_PROJECT)) { return new ProjectNotFoundResult(user, "admin.errors.project.not.found.for.id", String.valueOf(id)); } if (!checkActionPermission(user, project, action)) { return new PermissionErrorResult(user, action); } return new GetProjectResult(project); }
projectService.getProjectByIdForAction(user, bean.getProjectId(), ProjectAction.EDIT_PROJECT_CONFIG) : projectService.getProjectByKeyForAction(user, bean.getProject(), ProjectAction.EDIT_PROJECT_CONFIG); if (!getResult.isValid()) .projectId(getResult.getProject().getId()) .name(bean.getName()) .description(bean.getDescription())
ProjectService.GetProjectResult getResult = projectService.getProjectByKeyForAction(user, bean.getProject(), ProjectAction.EDIT_PROJECT_CONFIG); if (!getResult.isValid()) throwWebException(getResult.getErrorCollection()); Project project = getResult.getProject();
if (projectResult.isValid()) filterName = projectResult.getProject().getName();
if (projectResult.isValid()) final Project project = projectResult.getProject();
if (!projectResult.isValid()) return Response.status(Response.Status.BAD_REQUEST).entity(ErrorCollection.of(projectResult.getErrorCollection())).cacheControl(NO_CACHE).build(); 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);
@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 (!getProjectResult.isValid() || getProjectResult.getProject() == null) return new UpdateProjectValidationResult(ErrorCollections.copyOf(getProjectResult.getErrorCollection())); Project project = getProjectResult.getProject(); if (!StringUtils.equals(oldKey, newKey))
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); } }
@Nonnull @Override public CreateProjectValidationResult validateCreateProjectBasedOnExistingProject( final ApplicationUser user, @Nonnull final Long existingProjectId, @Nonnull ProjectCreationData input ) { final JiraServiceContext serviceContext = getServiceContext(user, ErrorCollections.empty()); final I18nHelper i18nBean = getI18nBean(user); if (!globalPermissionManager.hasPermission(GlobalPermissionKey.ADMINISTER, user)) { serviceContext.getErrorCollection().addErrorMessage(i18nBean.getText("admin.projects.service.error.no.admin.permission"), Reason.FORBIDDEN); return new CreateProjectValidationResult(serviceContext.getErrorCollection()); } final GetProjectResult projectById = getProjectByIdForAction(user, existingProjectId, ProjectAction.EDIT_PROJECT_CONFIG); if (!projectById.isValid()) { return new CreateProjectValidationResult(projectById.getErrorCollection()); } final ProjectCreationData creationData = new ProjectCreationData.Builder().fromExistingProject(projectById.get(), input).build(); isValidAllProjectData(serviceContext, creationData); return new CreateProjectValidationResult(serviceContext.getErrorCollection(), user, creationData, Optional.of(existingProjectId)); }
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 boolean userCanCreateAvatarFor(final ApplicationUser user, final String owningObjectId) { final long owningProjectId; try { owningProjectId = Long.parseLong(owningObjectId); } catch (Exception x) { throw new IllegalArgumentException("ownerId", x); } final ProjectService.GetProjectResult getProjectResult = projectService.getProjectByIdForAction(user, owningProjectId, ProjectAction.EDIT_PROJECT_CONFIG); return getProjectResult.isValid(); }
@Override public GetProjectResult getProjectByKeyForAction(ApplicationUser user, String key, ProjectAction action) { Assertions.notNull("action", action); Project project = projectManager.getProjectObjByKey(key); if (project == null || !checkActionPermission(user, project, ProjectAction.VIEW_PROJECT)) { return new ProjectNotFoundResult(user, "admin.errors.project.not.found.for.key", key); } if (!checkActionPermission(user, project, action)) { return new PermissionErrorResult(user, action); } return new GetProjectResult(project); }
@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(); }
@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; } });