RemoveUserFromApplicationValidationResult(final ApplicationUser userToRemove, final Set<String> applicationGroupNames) { super(new SimpleErrorCollection()); this.userToRemove = userToRemove; this.applicationGroupNames = applicationGroupNames; }
public static ErrorCollectionMatcher hasOnlyError(final String fieldName, final String errorMessage) { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); errorCollection.addError(fieldName, errorMessage); return new ErrorCollectionMatcher(errorCollection, false, true); }
private static ErrorCollection createErrrorCollectionWithMessage(String message){ final SimpleErrorCollection ec = new SimpleErrorCollection(); ec.addErrorMessage(message); return ec; } }
/** * Transforms the errors into a {@link ErrorCollection}. * @return An ErrorCollection. */ public ErrorCollection toErrorCollection() { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); errorCollection.addErrors(errors); errorCollection.addErrorMessages(errorMessages); return errorCollection; } }
@Override public ErrorCollection getErrorCollection() { final SimpleErrorCollection copied = new SimpleErrorCollection(); copied.addErrorCollection(errorCollection); return copied; }
private boolean checkInvalidCharacters(final String fieldKey, final String fieldValue, Errors errors) { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); // This is needed due to http://jira.opensymphony.com/browse/WF-476. We should consider removing this // if we upgrade osworkflow to a version that fixes WF-476. WorkflowUtil.checkInvalidCharacters(fieldValue, fieldKey, errorCollection); errors.addErrorCollection(errorCollection); return !errorCollection.hasAnyErrors(); }
protected SetPropertyValidationResult validateSetProperty(ApplicationUser user, Option<E> entity, PropertyInput propertyInput, EntityPropertyOptions options) { checkNotNull(propertyInput); SimpleErrorCollection errorCollection = new SimpleErrorCollection(); if (checkEntity(entity, user, getEditPermissionFunction(options), errorCollection)) { if (StringUtils.isEmpty(propertyInput.getPropertyValue())) { errorCollection.addErrorMessage(i18n.getText("jira.properties.service.empty.value"), VALIDATION_FAILED); } else { errorCollection.addErrorCollection(validatePropertyInput(propertyInput)); } } Option<EntityPropertyInput> property = errorCollection.hasAnyErrors() ? Option.<EntityPropertyInput>none() : Option.some(createInputForPropertySet(entity.get(), propertyInput)); return new SetPropertyValidationResult(errorCollection, property); }
public static ErrorCollectionMatcher hasErrorMessages(final String... errorMessage) { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); errorCollection.addErrorMessages(Lists.newArrayList(errorMessage)); return new ErrorCollectionMatcher(errorCollection, false, false); }
@Override public ErrorCollection updateIssueInputParameters(IssueContext issueCtx, Issue issue, String fieldId, IssueInputParameters inputParameters, List<FieldOperationHolder> operations) SimpleErrorCollection errors = new SimpleErrorCollection(); if (operations.isEmpty()) errors.addError(ISSUE_LINKS, i18nHelper.getText("rest.operations.morethanone", String.valueOf(operations.size()), fieldId)); return errors; if (errors.hasAnyErrors()) errors.addErrorMessage(i18nHelper.getText("rest.issue.link.null")); return errors; if (inwardIssue != null && outwardIssue != null) errors.addErrorMessage(i18nHelper.getText("rest.issue.link.error.too.many.keys")); errors.addErrorMessage(i18nHelper.getText("rest.issue.link.comment.not.allowed")); if (errors.hasAnyErrors())
/** * Constructs a new ValidationFailureException with an error message, a collection of errors, and a cause. * * @param message a String containing an error message * @param errors an ErrorCollection containing collection of validation errors * @param throwable the Throwable that caused the validation failure */ public ValidationFailureException(String message, ErrorCollection errors, Throwable throwable) { super(message, throwable); SimpleErrorCollection errorsCopy = new SimpleErrorCollection(); if (message != null) { errorsCopy.addErrorMessage(message); } if (errors != null) { errorsCopy.addErrorCollection(errors); } this.errors = errorsCopy; }
final SimpleErrorCollection errors = new SimpleErrorCollection(); if (project == null) errors.addErrorMessage(i18nBean.getText("admin.errors.must.specify.valid.project")); return new ValidateResult(errors, EnumSet.of(CreateVersionValidationResult.Reason.BAD_PROJECT)); && !permissionManager.hasPermission(ADMINISTER_PROJECTS, project, appUser)) errors.addErrorMessage(i18nBean.getText("admin.errors.version.no.permission")); return new ValidateResult(errors, EnumSet.of(CreateVersionValidationResult.Reason.FORBIDDEN)); errors.addError("name", i18nBean.getText("admin.errors.enter.valid.version.name")); reasons.add(CreateVersionValidationResult.Reason.BAD_NAME); errors.addError("name", i18nBean.getText("admin.errors.version.already.exists")); reasons.add(CreateVersionValidationResult.Reason.DUPLICATE_NAME); errors.addError("name", i18nBean.getText("admin.errors.version.name.toolong")); reasons.add(CreateVersionValidationResult.Reason.VERSION_NAME_TOO_LONG); errors.addErrorCollection(e.parseErrors); reasons.add(CreateVersionValidationResult.Reason.BAD_START_DATE); errors.addErrorCollection(e.parseErrors); reasons.add(CreateVersionValidationResult.Reason.BAD_RELEASE_DATE); errors.addErrorCollection(validateDatesOutcome.getErrorCollection()); reasons.add(CreateVersionValidationResult.Reason.BAD_START_RELEASE_DATE_ORDER);
private <T> ServiceOutcome<T> outcomeForReason(Reason reason, String text) { final SimpleErrorCollection simpleErrorCollection = new SimpleErrorCollection(); simpleErrorCollection.addErrorMessage(text); simpleErrorCollection.addReason(reason); return from(simpleErrorCollection, null); }
private <T> ServiceOutcome<T> generateErrorOutcomeFor(final String key, final String message) { final SimpleErrorCollection collection = new SimpleErrorCollection(); collection.addReason(ErrorCollection.Reason.VALIDATION_FAILED); collection.addError(key, message); return new ServiceOutcomeImpl<>(collection); }
private ErrorCollection buildAllErrors(final Iterable<ErrorCollection> errorCollections) { final SimpleErrorCollection allErrors = new SimpleErrorCollection(); for (ErrorCollection errorCollection : errorCollections) { allErrors.addErrorMessages(errorCollection.getErrorMessages()); allErrors.addErrors(errorCollection.getErrors()); allErrors.addReasons(errorCollection.getReasons()); } return allErrors; }
public Response createComponent(final ComponentBean bean) SimpleErrorCollection errorCollection = new SimpleErrorCollection(); if (isBlank(bean.getProject())) errorCollection.addError("name", i18n.getText("admin.projects.component.namenotset")); throw new BadRequestWebException(ErrorCollection.of(errorCollection)); if (leadUser == null) errorCollection.addError("componentLead", i18n.getText("admin.projects.component.userdoesnotexist",leadUserName)); bean.getDescription(), leadUserKey, project.getId(), assigneeType); if (errorCollection.hasAnyErrors())
SimpleErrorCollection errors = new SimpleErrorCollection(); createIssueLink(user, issue, issueToLinkTo, remoteIssueLink.getRelationship()); } catch(IssueLinkCreationException e){ errors.addErrorCollection(e.getErrorCollection()); } finally { if(errors.hasAnyErrors()){ throw new IssueLinkCreationException(errors);
@Override public void addErrorMessages(Collection<String> incomingMessages) { if (incomingMessages != null && !incomingMessages.isEmpty()) { for (final String incomingMessage : incomingMessages) { addErrorMessage(incomingMessage); } } }
public boolean isSuccessful() { return !errorCollection.hasAnyErrors(); } }
private void addError(String message) { // we always use the license field! errorCollection.addError(LICENSE_FIELD, message); }