public boolean isValid() { return result.isRight(); }
public boolean isValid() { return result.isRight(); }
public boolean matchJql(final String filter, final Issue issue) { if (StringUtils.isBlank(filter)) { return true; } if (!jqlValidationUtil.isJqlValid(filter).isRight()) { log.error(String.format("The following JQL query '%-1.800s' defined for filtering webhook events is incorrect. Filtering has been disabled for webhook.", filter)); return true; } try { final Query query = getQuery(issue.getKey(), filter); final long startTime = System.currentTimeMillis(); final boolean matches = searchProvider.searchCountOverrideSecurity(query, null) > 0; long queryTime = System.currentTimeMillis() - startTime; if (queryTime > 50) { String logMessage = String.format("JQL query '%-1.800s' produced lucene query and took '%d' ms to run.", query.toString(), queryTime); slowLog.info(logMessage); } return matches; } catch (SearchException e) { return false; } catch (JqlParseException e) { log.error("Query could not be parsed", e); return false; } }
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 protected boolean matchesSafely(final Either<L, R> item, final Description mismatchDescription) { if (!item.isRight()) { mismatchDescription.appendText("LEFT[") .appendValue(item.left().get()) .appendText("]"); return false; } else if (!matcher.matches(item.right().get())) { mismatchDescription.appendText("RIGHT["); matcher.describeMismatch(item.right().get(), mismatchDescription); mismatchDescription.appendText("]"); return false; } else { return true; } }
if (result.isRight())
/** * We allow all users to create a room, but we need to check whether a user with their email address exists in * HipChat, so that they can become the owner of the new room. * * @param username the username * @return true if the user exists in HipChat with the same email address */ @Override public boolean canUserCreateRoot(String username) { boolean canCreate = findHipChatIdForUser(username).isRight(); eventPublisher.publish( canCreate ? new RoomCreationCheckboxShownEvent() : new RoomCreationCheckboxNotShownEvent(RoomCreationCheckboxNotShownEvent.Reason.USER_NOT_IN_HIPCHAT)); return canCreate; }
@SuppressWarnings("unchecked") @Override public RegistrationResult onModule(ConnectModuleProviderModuleDescriptor moduleDescriptor, ConnectModuleProvider<?> provider) { final String descriptorKey = provider.getMeta().getDescriptorKey(); final Collection moduleBeans = builtModuleList.get(descriptorKey); if (moduleBeans == null) return RegistrationResult.emptyFor(provider); if (vertigoState.isVertigoSpiEnabled()) { final Either<GenerationResult, RegistrationResult> potentialDescriptors = BeanToModuleRegistrar.this.getDescriptorsToRegisterForModulesVertigoStyle(provider, moduleBeans, addon, translations); if (potentialDescriptors.isRight()) { return potentialDescriptors.right().get(); } else { if (potentialDescriptors.left().get() != GenerationResult.NOT_IMPLEMENTED && systemPropertyService.isVertigoFallbackDisabled()) { throw new IllegalStateException("The module provider " + provider.getClass() + " implemented serializeToPluginModules but failed to run the whole process. Fallback disabled: failing hard."); } } } return new RegistrationResult(provider, provider.createPluginModuleDescriptors(ImmutableList.copyOf(moduleBeans), addon), ImmutableList.of()); } });
@Deprecated public final static String getEntityToken(Either<Issue, Project> entity) { if (entity == null) { return null; } if (entity.isLeft()) { return getIssueToken(entity.left().get()); } else if (entity.isRight()) { return getProjectToken(entity.right().get()); } else { return null; } }
if (resultOrError.isRight())
@Override public ServiceResult perform() throws GenericEntityException { if (id.equals(permissionSchemeManager.getDefaultSchemeObject().getId())) { return fail(i18n.getText("admin.schemes.permissions.cannot.delete.default.scheme"), Reason.VALIDATION_FAILED); } Either<ServiceOutcome<Object>, PermissionScheme> schemeToDelete = getScheme(user, id); if (schemeToDelete.isRight()) { if (!permissionSchemeManager.getProjects(representationConverter.scheme(schemeToDelete.right().get())).isEmpty()) { return fail(i18n.getText("admin.schemes.permissions.cannot.delete.with.projects", id), Reason.VALIDATION_FAILED); } permissionSchemeManager.deleteScheme(id); return ok(); } else { return schemeToDelete.left().get(); } } });
if (getActions.isRight())
@SuppressWarnings("unchecked") @Override public ErrorCollection setScreen(@Nonnull String transitionName, @Nullable FieldScreen screen, @Nonnull JiraWorkflow workflow) { ErrorCollection errorCollection = checkArguments(transitionName, workflow); if (errorCollection.hasAnyErrors()) { return errorCollection; } Option<JiraWorkflow> getDraft = draftOf(errorCollection, workflow); if (getDraft.isEmpty()) { return errorCollection; } JiraWorkflow draftWorkflow = getDraft.get(); Either<Collection<ActionDescriptor>, ErrorCollection> getActions = getActionsByName(transitionName, draftWorkflow); if (getActions.isRight()) { return getActions.right().get(); } for (ActionDescriptor action : getActions.left().get()) { setActionScreen(action, screen); } workflowService.updateWorkflow(getServiceContext(errorCollection), draftWorkflow); return errorCollection; }
@Override public ErrorCollection addConditionToWorkflow(@Nonnull String transitionName, @Nonnull ConditionDescriptor condition, @Nonnull JiraWorkflow workflow) { ErrorCollection errorCollection = checkArguments(transitionName, workflow, condition, "admin.workflowtransitions.service.error.null.condition"); if (errorCollection.hasAnyErrors()) { return errorCollection; } Option<JiraWorkflow> getDraft = draftOf(errorCollection, workflow); if (getDraft.isEmpty()) { //Draft creation might fail, if so, return the resulting error. return errorCollection; } JiraWorkflow draftWorkflow = getDraft.get(); Either<Collection<ActionDescriptor>, ErrorCollection> getActions = getActionsByName(transitionName, draftWorkflow); if (getActions.isRight()) { return getActions.right().get(); } for (ActionDescriptor action : getActions.left().get()) { transitionConditionUtil.addCondition(action, "", condition); } workflowService.updateWorkflow(getServiceContext(errorCollection), draftWorkflow); return errorCollection; }
protected <T> T handleGenericResponseStatus(JiraProxy jira, Either<NegativeResponseStatus, T> response, Function<NegativeResponseStatus, Void> errorOccuredHandler){ if(response.isRight()){ return response.right().get(); } else {
@Override public Either<List<ProjectVersionBean>, ErrorCollection> getVersions(@Nonnull final String jql) { ApplicationUser user = authenticationContext.getUser(); Either<Query, ErrorCollection> queryOrError = queryParser.getQuery(user, jql); if (queryOrError.isRight()) { return Either.right(queryOrError.right().get()); } Query query = queryOrError.left().get(); Option<Query> filterQuery = projectOrFilterQueryParser.getFilterQuery(user, query); if (filterQuery.isDefined()) { query = filterQuery.get(); } Collection<Project> projects = getProjectsForQuery(user, query); List<ProjectVersionBean> projectVersionBeanList = getVersionsForProjects(query, projects); return Either.left(projectVersionBeanList); }
if (scheme.isRight())
if (groupOrRole.isRight())
if (queryOrError.isRight())