private void createChangeItemForRemove(final RemoteIssueLink remoteIssueLink, final Issue issue, final ApplicationUser remoteUser) { final ChangeItemBean changeItemBean = new ChangeItemBean( ChangeItemBean.STATIC_FIELD, "RemoteIssueLink", remoteIssueLink.getId().toString(), getChangeItemDescription(remoteIssueLink, remoteUser), null, null); createChangeItem(changeItemBean, issue, remoteUser); }
@Override public void removeRemoteIssueLink(final Long remoteIssueLinkId, final ApplicationUser user) { // Make sure remote issue link exists final RemoteIssueLink remoteIssueLink = getRemoteIssueLink(remoteIssueLinkId); if (remoteIssueLink == null) { // Nothing to do return; } removeRemoteIssueLink(remoteIssueLink, user); }
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; }
@Override public void updateRemoteIssueLink(final RemoteIssueLink remoteIssueLink, final ApplicationUser user) throws UpdateException { validateMandatoryFieldsForUpdate(remoteIssueLink); validateFieldLengthsForUpdate(remoteIssueLink); validateUrlsForUpdate(remoteIssueLink); final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); if (issue == null) { throw new UpdateException("Issue with id '" + remoteIssueLink.getIssueId() + "' does not exist."); } // Make sure remote issue link exists final RemoteIssueLink found = getRemoteIssueLink(remoteIssueLink.getId()); if (found == null) { throw new UpdateException("Remote link with id '" + remoteIssueLink.getId() + "' does not exist."); } else { validateGlobalIdForUpdate(issue, found.getGlobalId(), remoteIssueLink.getGlobalId()); } remoteIssueLinkStore.updateRemoteIssueLink(remoteIssueLink); if (found.getGlobalId() != null && !found.getGlobalId().equals(remoteIssueLink.getGlobalId()) && hasDuplicateGlobalId(issue, remoteIssueLink)) { remoteIssueLinkStore.updateRemoteIssueLink(found); throw new UpdateException("A remote issue link already exists on this issue with the globalId '" + remoteIssueLink.getGlobalId() + "'"); } createChangeItemForUpdate(found, remoteIssueLink, issue, user); eventPublisher.publish(new RemoteIssueLinkUpdateEvent(remoteIssueLink)); }
@Override public RemoteIssueLink createRemoteIssueLink(final RemoteIssueLink remoteIssueLink, final ApplicationUser user) throws CreateException { validateMandatoryFieldsForCreate(remoteIssueLink); validateFieldLengthsForCreate(remoteIssueLink); validateUrlsForCreate(remoteIssueLink); final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); if (issue == null) { throw new CreateException("Issue with id '" + remoteIssueLink.getIssueId() + "' does not exist."); } validateGlobalIdForCreate(issue, remoteIssueLink.getGlobalId()); final RemoteIssueLink created = remoteIssueLinkStore.createRemoteIssueLink(remoteIssueLink); if (hasDuplicateGlobalId(issue, created)) { remoteIssueLinkStore.removeRemoteIssueLink(created.getId()); throw new CreateException("A remote issue link already exists on this issue with the globalId '" + created.getGlobalId() + "'"); } createChangeItemForCreate(created, issue, user); eventPublisher.publish(new RemoteIssueLinkCreateEvent(remoteIssueLink)); return created; }
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 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 removeRemoteIssueLink(RemoteIssueLink remoteIssueLink, ApplicationUser user) { remoteIssueLinkStore.removeRemoteIssueLink(remoteIssueLink.getId()); final Issue issue = issueManager.getIssueObject(remoteIssueLink.getIssueId()); createChangeItemForRemove(remoteIssueLink, issue, user); eventPublisher.publish(new RemoteIssueLinkDeleteEvent(remoteIssueLink)); }
private void createChangeItemForCreate(final RemoteIssueLink remoteIssueLink, final Issue issue, final ApplicationUser remoteUser) { final ChangeItemBean changeItemBean = new ChangeItemBean( ChangeItemBean.STATIC_FIELD, "RemoteIssueLink", null, null, remoteIssueLink.getId().toString(), getChangeItemDescription(remoteIssueLink, remoteUser)); createChangeItem(changeItemBean, issue, remoteUser); }
private void createChangeItemForUpdate(final RemoteIssueLink oldLink, final RemoteIssueLink newLink, final Issue issue, final ApplicationUser remoteUser) { final ChangeItemBean changeItemBean = new ChangeItemBean( ChangeItemBean.STATIC_FIELD, "RemoteIssueLink", oldLink.getId().toString(), getChangeItemDescription(oldLink, remoteUser), newLink.getId().toString(), getChangeItemDescription(newLink, remoteUser)); createChangeItem(changeItemBean, issue, remoteUser); }