private IssueLinkType findIssueLinkTypeByNames(final String issueLinkType){ try{ return Iterables.find(issueLinkService.getIssueLinkTypes(), new Predicate<IssueLinkType>() { @Override public boolean apply(IssueLinkType input) { Preconditions.checkNotNull(input); return issueLinkType.equals(input.getInward()) || issueLinkType.equals(input.getOutward()); } }); } catch(NoSuchElementException e){ return null; } }
private IssueLink getLink() { if (issueLink == null) { if (destId != null) { issueLink = issueLinkService.getIssueLink(getId(), destId, linkType); } else if (sourceId != null) { issueLink = issueLinkService.getIssueLink(sourceId, getId(), linkType); } } return issueLink; } }
log.warn("IssueLinkService classloader: " + issueLinkService.getClass().getClassLoader()); log.warn("IssueLinkService" + issueLinkService); IssueLinkService.SingleIssueLinkResult issueLinkResult = issueLinkService.getIssueLink(valueOf(linkId), authContext.getUser()); if (!issueLinkResult.isValid()) IssueLinkService.DeleteIssueLinkValidationResult deleteSourceIssueLinkValidationResult = issueLinkService.validateDelete(authContext.getUser(), sourceIssueResult.getIssue(), issueLink); if (deleteSourceIssueLinkValidationResult.isValid()) issueLinkService.delete(deleteSourceIssueLinkValidationResult); return Response.status(Response.Status.NO_CONTENT).cacheControl(never()).build(); IssueLinkService.DeleteIssueLinkValidationResult deleteDesinationIssueLinkValidationResult = issueLinkService.validateDelete(authContext.getUser(), destinationIssueResult.getIssue(), issueLink); if (deleteDesinationIssueLinkValidationResult.isValid()) issueLinkService.delete(deleteDesinationIssueLinkValidationResult); return Response.status(Response.Status.NO_CONTENT).cacheControl(never()).build();
private void createIssueLink(final ApplicationUser user, final Issue fromIssue, final Issue toIssue, final String relationship) throws IssueLinkCreationException { IssueLinkType issueLinkType = findIssueLinkTypeByNames(relationship); if(issueLinkType == null){ String message = authenticationContext.getI18nHelper().getText("cpji.link.type.doesnt.exist.link.wasnt.copied", relationship, fromIssue, toIssue); throw new CannotFindIssueLinkTypeException(message); } final IssueLinkService.AddIssueLinkValidationResult addIssueLinkValidationResult = issueLinkService.validateAddIssueLinks( user, fromIssue, relationship, ImmutableList.<String>of(toIssue.getKey())); if (addIssueLinkValidationResult.isValid()) { issueLinkService.addIssueLinks(user, addIssueLinkValidationResult); } else { log.warn("Error creating local link from " + fromIssue.getKey() + " to " + toIssue.getKey() + ". " + addIssueLinkValidationResult.getErrorCollection()); throw new IssueLinkCreationException(addIssueLinkValidationResult.getErrorCollection()); } }
public void createValue(Issue issue, IssueLinkingValue value) { if (isIssueLinkingEnabled()) { IssueLinkingValue issueLinkingValue = value; IssueLinkService.AddIssueLinkValidationResult validationResult = issueLinkingValue.getValidationResult(); if (validationResult != null && validationResult.isValid()) { issueLinkService.addIssueLinks(authenticationContext.getUser(), validationResult); } } }
protected void doValidation() { validationResult = issueLinkService.validateDelete(getLoggedInUser(), getIssueObject(), getLink()); if (!validationResult.isValid()) { addErrorCollection(validationResult.getErrorCollection()); } }
public void validateParams(OperationContext operationContext, ErrorCollection errorCollection, I18nHelper i18n, Issue issue, FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem) { IssueLinkingValue value = (IssueLinkingValue) operationContext.getFieldValuesHolder().get(getId()); if (isIssueLinkingEnabled() && value != null && !value.getLinkedIssues().isEmpty()) { IssueLinkService.AddIssueLinkValidationResult issueLinkValidationResult = issueLinkService.validateAddIssueLinks(authenticationContext.getUser(), issue, value.getLinkDescription(), value.getLinkedIssues()); // if we were returned an updated value, that signifies that we must update the TimeTrackingValue in the FieldValuesHolder if (issueLinkValidationResult.isValid()) { //noinspection unchecked operationContext.getFieldValuesHolder().put(getId(), new IssueLinkingValue.Builder(issueLinkValidationResult).build()); } else { transferErrorMessages(errorCollection, issueLinkValidationResult.getErrorCollection().getErrorMessages()); transferErrorMessages(errorCollection, issueLinkValidationResult.getErrorCollection().getErrors().values()); } } }
@RequiresXsrfCheck protected String doExecute() throws Exception { if (confirm) { issueLinkService.delete(validationResult); String targetID = hasIssueLinks(getLoggedInUser(), getIssueObject()) ? "#linkingmodule" : ""; final String redirectUrl = "/browse/" + getIssueObject().getKey() + targetID; if (isInlineDialogMode()) { return returnCompleteWithInlineRedirect(redirectUrl); } return returnComplete(redirectUrl); } else { // No confirmation supplied - ask for one return INPUT; } }
/** * Returns true if there were no errors and issue has local links. * * @param user current user * @param issue current issue * @return true if issue has local links */ private boolean hasIssueLinks(ApplicationUser user, Issue issue) { final IssueLinkService.IssueLinkResult result = issueLinkService.getIssueLinks(getLoggedInUser(), getIssueObject()); return result.isValid() && !result.getLinkCollection().getAllIssues().isEmpty(); }
/** * This is called after the issue has been stored on disk and allows us a chance to create change records for the * update. * * @param fieldLayoutItem for this field within this context. * @param issue Issue this field is part of. * @param modifiedValue new value to set field to. Cannot be null. * @param issueChangeHolder an object to record any changes made to the issue by this method. */ public void updateValue(FieldLayoutItem fieldLayoutItem, Issue issue, ModifiedValue modifiedValue, IssueChangeHolder issueChangeHolder) { Object newValue = modifiedValue.getNewValue(); if (newValue != null) { if (isIssueLinkingEnabled()) { IssueLinkingValue issueLinkingValue = (IssueLinkingValue) newValue; IssueLinkService.AddIssueLinkValidationResult validationResult = issueLinkingValue.getValidationResult(); if (validationResult != null && validationResult.isValid()) { issueLinkService.addIssueLinks(authenticationContext.getUser(), validationResult); } } } }
public Collection<String> getLinkDescs() { if (linkDescs == null) { linkDescs = issueLinkDisplayHelper.getSortedIssueLinkTypes(issueLinkService.getIssueLinkTypes()); } return linkDescs; }
IssueLinkService.SingleIssueLinkResult issueLinkResult = issueLinkService.getIssueLink(valueOf(linkId), authContext.getUser()); if (!issueLinkResult.isValid())
public Collection getLinkDescs() { if (linkDescs == null) { linkDescs = issueLinkDisplayHelper.getSortedIssueLinkTypes(issueLinkService.getIssueLinkTypes()); } return linkDescs; }
private String getCreateOrEditHtml(FieldLayoutItem fieldLayoutItem, OperationContext operationContext, Action action, Issue issue, Map displayParameters, final Boolean create) { IssueLinkDisplayHelper issueLinkDisplayHelper = new IssueLinkDisplayHelper(userHistoryManager, authenticationContext.getUser()); Map<String, Object> velocityParams = getVelocityParams(fieldLayoutItem, action, issue, displayParameters); velocityParams.put(PARAMS_ISCREATEISSUE, create); final Object value = operationContext.getFieldValuesHolder().get(getId()); velocityParams.put("value", value); velocityParams.put("linkTypes", issueLinkDisplayHelper.getSortedIssueLinkTypes(issueLinkService.getIssueLinkTypes())); velocityParams.put("selectedLinkType", issueLinkDisplayHelper.getLastUsedLinkType()); if (value != null && value instanceof IssueLinkingValue) { //JRADEV-7325: if the fieldvaluesholder contains a value and it contains a linkdescription set that as the //currently selected value! final IssueLinkingValue ilv = (IssueLinkingValue) value; if (StringUtils.isNotBlank(ilv.getLinkDescription())) { velocityParams.put("selectedLinkType", ilv.getLinkDescription()); } } return renderTemplate("issuelinks-edit.vm", velocityParams); }