private Result validateGlobalIds(final Collection<String> globalIds) { if (globalIds != null) { if (globalIds.size() > MAX_GLOBAL_ID_LIST_SIZE_FOR_FIND) { return new Result(false, "The number of globalIds cannot exceed " + MAX_GLOBAL_ID_LIST_SIZE_FOR_FIND + "."); } for (String globalId : globalIds) { if (globalId == null) { return new Result(false, "A globalId in the input collection is null."); } if (isLongerThan(globalId, MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("globalId", MAX_LONG_VARCHAR_LENGTH)); } } } return TRUE; }
/** * Mandatory fields are: * - id (the remote issue link must exist) * - issueId * - title * - url * * @param remoteIssueLink * @throws UpdateException */ private void validateMandatoryFieldsForUpdate(final RemoteIssueLink remoteIssueLink) throws UpdateException { if (remoteIssueLink.getId() == null) { throw new UpdateException(missingMandatoryFieldMessage("id")); } final Result result = validateMandatoryFields(remoteIssueLink); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } }
private Result validateFieldLengths(final RemoteIssueLink remoteIssueLink) { if (isLongerThan(remoteIssueLink.getGlobalId(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("globalId", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getTitle(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("title", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getRelationship(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("relationship", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getApplicationType(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("applicationType", MAX_LONG_VARCHAR_LENGTH)); } if (isLongerThan(remoteIssueLink.getApplicationName(), MAX_LONG_VARCHAR_LENGTH)) { return new Result(false, tooLongFieldMessage("applicationName", MAX_LONG_VARCHAR_LENGTH)); } return TRUE; }
private Result validateUrls(final RemoteIssueLink remoteIssueLink) { if (!isValidUrl(remoteIssueLink.getUrl())) { return new Result(false, invalidUrlMessage("url")); } if (!isValidUrl(remoteIssueLink.getIconUrl())) { return new Result(false, invalidUrlMessage("iconUrl")); } if (!isValidUrl(remoteIssueLink.getStatusIconUrl())) { return new Result(false, invalidUrlMessage("statusIconUrl")); } if (!isValidUrl(remoteIssueLink.getStatusIconLink())) { return new Result(false, invalidUrlMessage("statusIconLink")); } return TRUE; }
private Result validateMandatoryFields(final RemoteIssueLink remoteIssueLink) { if (remoteIssueLink.getIssueId() == null) { return new Result(false, missingMandatoryFieldMessage("issueId")); } if (StringUtils.isBlank(remoteIssueLink.getTitle())) { return new Result(false, missingMandatoryFieldMessage("title")); } if (StringUtils.isBlank(remoteIssueLink.getUrl())) { return new Result(false, missingMandatoryFieldMessage("url")); } return TRUE; }
/** * Mandatory fields are: * - issueId * - title * - url * * @param remoteIssueLink * @throws CreateException */ private void validateMandatoryFieldsForCreate(final RemoteIssueLink remoteIssueLink) throws CreateException { final Result result = validateMandatoryFields(remoteIssueLink); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
private void validateUrlsForCreate(final RemoteIssueLink remoteIssueLink) throws CreateException { final Result result = validateUrls(remoteIssueLink); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
private void validateFieldLengthsForCreate(final RemoteIssueLink remoteIssueLink) throws CreateException { final Result result = validateFieldLengths(remoteIssueLink); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
private void validateGlobalIdForUpdate(final Issue issue, final String oldGlobalId, final String newGlobalId) throws UpdateException { // Validate only if it has changed if (!isEqual(oldGlobalId, newGlobalId)) { final Result result = validateGlobalId(issue, newGlobalId); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } } }
private void validateFieldLengthsForUpdate(final RemoteIssueLink remoteIssueLink) throws UpdateException { final Result result = validateFieldLengths(remoteIssueLink); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } }
private void validateGlobalIdsForGet(final Collection<String> globalIds) throws GetException { Result result = validateGlobalIds(globalIds); if (!result.isValid()) { throw new GetException(result.getMessage()); } }
private Result validateGlobalId(final Issue issue, final String globalId) { if (globalId == null) { return TRUE; } // Check for duplicate globalId on this issue if (getRemoteIssueLinkByGlobalId(issue, globalId) != null) { return new Result(false, "A remote issue link already exists on this issue with the globalId '" + globalId + "'"); } return TRUE; }
private void validateGlobalIdForCreate(final Issue issue, final String globalId) throws CreateException { final Result result = validateGlobalId(issue, globalId); if (!result.isValid()) { throw new CreateException(result.getMessage()); } }
private void validateUrlsForUpdate(final RemoteIssueLink remoteIssueLink) throws UpdateException { final Result result = validateUrls(remoteIssueLink); if (!result.isValid()) { throw new UpdateException(result.getMessage()); } }