/**
  * 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.getLoggedInUser(), validationResult);
       }
     }
   }
 }
예제 #2
0
  @Override
  public void updateValue(
      FieldLayoutItem fieldLayoutItem,
      Issue issue,
      ModifiedValue modifiedValue,
      IssueChangeHolder issueChangeHolder) {
    // all comment creations are seen as an update
    Map<String, Object> commentParams = (Map<String, Object>) modifiedValue.getNewValue();
    String body = (String) commentParams.get(getId());

    // allow the renderer for this field a change to transform the value
    String rendererType = (fieldLayoutItem != null) ? fieldLayoutItem.getRendererType() : null;
    body = (String) rendererManager.getRendererForType(rendererType).transformFromEdit(body);

    if (commentParams.containsKey(EDIT_COMMENT)) {
      editComment(issueChangeHolder, commentParams, body);
    } else if (commentParams.containsKey(REMOVE_COMMENT)) {
      removeComment(issueChangeHolder, commentParams);
    } else {
      if (StringUtils.isNotBlank(body)) {
        createComment(issue, issueChangeHolder, commentParams, body);
      }
    }
  }