Class DefaultAttachmentValidatorInvoker

java.lang.Object
com.atlassian.jira.issue.attachment.DefaultAttachmentValidatorInvoker
All Implemented Interfaces:
AttachmentValidatorInvoker

public class DefaultAttachmentValidatorInvoker extends Object implements AttachmentValidatorInvoker
  • Constructor Details

    • DefaultAttachmentValidatorInvoker

      public DefaultAttachmentValidatorInvoker(com.atlassian.plugin.PluginAccessor pluginAccessor)
  • Method Details

    • invokeBeforeUploadValidators

      public io.atlassian.fugue.Option<AttachmentError> invokeBeforeUploadValidators(String fileName, io.atlassian.fugue.Either<Issue,Project> target, Function<BeforeUploadAttachmentValidator,Optional<AttachmentValidationError>> validation)
      Description copied from interface: AttachmentValidatorInvoker
      Safely invoke pluggable before upload attachment validators, catching any exceptions on the way. Exceptions are logged and are treated as if the validator would pass.
      Specified by:
      invokeBeforeUploadValidators in interface AttachmentValidatorInvoker
      Parameters:
      fileName - name of the file being processed
      target - issue or project to which the file is being attached
      validation - validation function
      Returns:
      optionally an attachment error (any encountered), or an empty option if all validators pass
    • invokeAfterUploadValidators

      public io.atlassian.fugue.Option<AttachmentError> invokeAfterUploadValidators(String fileName, io.atlassian.fugue.Either<Issue,Project> target, Function<AfterUploadAttachmentValidator,io.atlassian.util.concurrent.Promise<Optional<AttachmentValidationError>>> validation)
      Description copied from interface: AttachmentValidatorInvoker
      Safely invoke pluggable after upload attachment validators, catching any exceptions on the way. Exceptions are logged and are treated as if the validator would pass.

      validation logic is expected to return an instance of Promise of validation result. This approach aims to support concurrent execution of validators. All promises will be converged into a single error (if any encountered, order of validation not guaranteed) or an empty Option.

      Specified by:
      invokeAfterUploadValidators in interface AttachmentValidatorInvoker
      Parameters:
      fileName - name of the file being processed
      target - issue or project to which the file is being attached
      validation - validation function
      Returns:
      optionally an attachment error (any encountered), or an empty option if all validators pass