Interface AttachmentValidatorInvoker
- All Known Implementing Classes:
DefaultAttachmentValidatorInvoker
public interface AttachmentValidatorInvoker
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.atlassian.fugue.Option
<AttachmentError> createAttachmentError
(String fileName, String logMessage, String localizedMessage, ErrorCollection.Reason reason) 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) Safely invoke pluggable after upload attachment validators, catching any exceptions on the way.io.atlassian.fugue.Option
<AttachmentError> invokeBeforeUploadValidators
(String fileName, io.atlassian.fugue.Either<Issue, Project> target, Function<BeforeUploadAttachmentValidator, Optional<AttachmentValidationError>> validation) Safely invoke pluggable before upload attachment validators, catching any exceptions on the way.
-
Method Details
-
invokeBeforeUploadValidators
io.atlassian.fugue.Option<AttachmentError> invokeBeforeUploadValidators(String fileName, io.atlassian.fugue.Either<Issue, Project> target, Function<BeforeUploadAttachmentValidator, Optional<AttachmentValidationError>> validation) 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.- Parameters:
fileName
- name of the file being processedtarget
- issue or project to which the file is being attachedvalidation
- validation function- Returns:
- optionally an attachment error (any encountered), or an empty option if all validators pass
-
invokeAfterUploadValidators
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) 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 ofPromise
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 emptyOption
.- Parameters:
fileName
- name of the file being processedtarget
- issue or project to which the file is being attachedvalidation
- validation function- Returns:
- optionally an attachment error (any encountered), or an empty option if all validators pass
-
createAttachmentError
static io.atlassian.fugue.Option<AttachmentError> createAttachmentError(String fileName, String logMessage, String localizedMessage, ErrorCollection.Reason reason)
-