Class AttachmentFileExtensionValidator
java.lang.Object
com.atlassian.jira.plugin.attachment.AttachmentFileExtensionValidator
- All Implemented Interfaces:
BeforeUploadAttachmentValidator,PluggableAttachmentValidator
@ParametersAreNonnullByDefault
public class AttachmentFileExtensionValidator
extends Object
implements BeforeUploadAttachmentValidator
Validates attachments by filename extensions, preventing uploading of files which do not match configured settings.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.issue.attachment.validation.PluggableAttachmentValidator
PluggableAttachmentValidator.FileInfo -
Constructor Summary
ConstructorsConstructorDescriptionAttachmentFileExtensionValidator(AttachmentConfigStore attachmentConfigStore, I18nHelper.BeanFactory i18nHelper) -
Method Summary
Modifier and TypeMethodDescriptionvalidateBeforeUpload(ApplicationUser user, Project project, Issue issue, PluggableAttachmentValidator.FileInfo fileInfo) Validate attachment before the file is uploaded to Jira.
-
Constructor Details
-
AttachmentFileExtensionValidator
public AttachmentFileExtensionValidator(AttachmentConfigStore attachmentConfigStore, I18nHelper.BeanFactory i18nHelper)
-
-
Method Details
-
validateBeforeUpload
public Optional<AttachmentValidationError> validateBeforeUpload(@Nullable ApplicationUser user, Project project, @Nullable Issue issue, PluggableAttachmentValidator.FileInfo fileInfo) Description copied from interface:BeforeUploadAttachmentValidatorValidate attachment before the file is uploaded to Jira.This validation will be executed synchronously, blocking the attachment action until it completes. Returning a validation error will prevent completion of the action.
Any thrown exceptions will be interpreted as lack of problems discovered (as if an empty result was returned).
- Specified by:
validateBeforeUploadin interfaceBeforeUploadAttachmentValidator- Parameters:
user- user performing the action, or null if anonymousproject- project of the issue to witch the file is being attached toissue- issue to which the file is being attached to, or null if the issue does not exist yet (issue will be created with the attachment)fileInfo- information about the attached file- Returns:
- an optional validation error
-