@Override public Either<Throwable, Set<MentionRoom>> apply(final Throwable input) { return Either.left(input); } },
@Override public ServiceOutcome<Version> validateReleaseDate(ApplicationUser user, Version version, String releaseDate) { return setReleaseDate(user, version, Either.<String, Date>left(releaseDate)); }
private PermissionGrantAsPureData(PermissionGrant grant, PermissionGrantInput grantData) { if (grant != null) { actual = left(grant); } else { actual = right(grantData); } }
@Override public ServiceOutcome<Version> setReleaseDate(ApplicationUser user, Version version, String releaseDate) { return setReleaseDate(user, version, Either.<String, Date>left(releaseDate)); }
@Override public ServiceOutcome<IssueSecurityLevelScheme> getIssueSecurityLevelSchemeForProject(final ApplicationUser user, final long projectId) { return getIssueSecurityLevelSchemeForProject(user, Either.left(projectId)); }
private <T> Either<AttachmentError, T> attachmentError(final String logMessage, final String localizedMessage, final String filename, final ErrorCollection.Reason reason) { log.warn(logMessage); return Either.left(new AttachmentError(logMessage, localizedMessage, filename, Option.<Exception>none(), reason)); }
private <T> Either<AttachmentError, T> attachmentError(final String logMessage, final String localizedMessage, final String filename, final ErrorCollection.Reason reason) { log.warn(logMessage); return Either.left(new AttachmentError(logMessage, localizedMessage, filename, Option.<Exception>none(), reason)); }
private Either<ServiceOutcome<PermissionScheme>, String> validateSchemeName(@Nullable String oldName, String newName) throws GenericEntityException { if (!newName.equals(oldName) && permissionSchemeManager.schemeExists(newName)) { return left(DefaultPermissionSchemeService.<PermissionScheme>fail(i18n.getText("admin.schemes.permissions.scheme.already.exists", newName), Reason.VALIDATION_FAILED)); } else { return right(newName); } }
public void validateFilter(final MessageCollection.Builder errorCollectionBuilder, final Optional<String> filter) { if (filter.isPresent() && StringUtils.isNotBlank(filter.get())) { final String jql = filter.get(); final Either<JqlParseException, String> jqlValid = isJqlValid(jql); if (!jqlValid.isRight()) { final Message errorMessage = new ErrorMessage("jql", i18n.getText("webhooks.invalid.jql", jql, jqlValid.left().get())); errorCollectionBuilder.addMessage(errorMessage, MessageCollection.Reason.VALIDATION_FAILED); } } }
@Override public Either<NegativeResponseStatus, Projects> apply(JiraProxy input) { Either<NegativeResponseStatus, PluginVersion> version = input.isPluginInstalled(); if(version.isLeft()) return Either.left(version.left().get()); if(version.right().get().getResult().equals(PluginInfoResource.PLUGIN_VERSION)){ return input.getProjects(); } else { return Either.left(NegativeResponseStatus.unsupportedVersion(input.getJiraLocation())); } } });
public boolean canCreateTemporaryAttachments(final JiraServiceContext jiraServiceContext, @Nullable final Issue issue) { return validateNonNullIssue(jiraServiceContext, issue) && attachmentValidator.canCreateTemporaryAttachments( jiraServiceContext.getLoggedInApplicationUser(), Either.<Issue, Project>left(issue), jiraServiceContext.getErrorCollection()); }
private Either<ErrorCollection, PermissionSchemeBean> validated(final PermissionSchemeBean bean) { if (isNullOrEmpty(bean.getName())) { return left(ErrorCollections.validationError("name", i18n.getText("rest.missing.field", "name"))); } return right(bean); }
private Response.ResponseBuilder withApplicationRole(String key, Function<ApplicationRole, Response.ResponseBuilder> valid) { final Either<Response.ResponseBuilder, ApplicationRole> appRoleEither = getApplicationRole(key); if (appRoleEither.isLeft()) { return appRoleEither.left().get(); } return valid.apply(appRoleEither.right().get()); }
private Either<Project, ErrorCollection> notifyProjectTypeUpdated(ApplicationUser user, Project project, ProjectTypeKey oldProjectType, ProjectTypeKey newProjectType) { boolean notificationWasSuccessful = projectTypeUpdatedNotifier.notifyAllHandlers(user, project, oldProjectType, newProjectType); if (!notificationWasSuccessful) { // rollback the project type update, since something went wrong on one of the project type update handlers projectManager.updateProjectType(user, project, oldProjectType); return Either.right(new SimpleErrorCollection("admin.errors.project.type.update.error", Reason.SERVER_ERROR)); } return Either.left(project); }
public static ResultWithJiraLocation<?> extract(Either<? extends ResultWithJiraLocation<?>, ? extends ResultWithJiraLocation<?>> either) { if (either.isLeft()) { return either.left().get(); } else { return either.right().get(); } } }
@Override public <T> Either<Response, T> validateOutcome(ServiceOutcome<T> outcome) { if (outcome.isValid()) { return Either.right(outcome.get()); } else { return Either.left(errorResponse(outcome.getErrorCollection())); } }
@Override public ErrorCollection apply(final ApplicationUser user, final ChangeHistory changeGroup) { Either<ErrorCollection, Issue> issue = getIssueFromChangeHistory(changeGroup); if (issue.isLeft()) { return issue.left().get(); } return issuePermissionFunction.apply(user, issue.right().get()); } }
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())); }
@Override public Response apply(@Nullable final Project project) { Either<Project, com.atlassian.jira.util.ErrorCollection> updateResult = projectService.updateProjectType(authContext.getLoggedInUser(), project, new ProjectTypeKey(newProjectTypeKey)); if (updateResult.isLeft()) { return responses.okNoCache(projectBeanFactory.fullProject(updateResult.left().get(), "")); } return responses.errorResponse(updateResult.right().get()); } });
@Override public Promise<Unit> moveTemporaryToAttachment(final TemporaryAttachmentId temporaryAttachmentId, final AttachmentKey destinationKey) { final Either<Exception, File> tempFileEitherException = localTemporaryFileStore.getTemporaryAttachmentFile(temporaryAttachmentId); if (tempFileEitherException.isLeft()) { return Promises.rejected(tempFileEitherException.left().get()); } final File tempFile = tempFileEitherException.right().get(); final File destinationFile = getAttachmentFileHolder(destinationKey); return moveFile(tempFile, destinationFile, true); }