Class DefaultUploadValidationService
- java.lang.Object
-
- org.hippoecm.frontend.plugins.yui.upload.validation.DefaultUploadValidationService
-
- All Implemented Interfaces:
Serializable
,org.apache.wicket.util.io.IClusterable
,FileUploadValidationService
,IValidationService
- Direct Known Subclasses:
ImageUploadValidationService
public class DefaultUploadValidationService extends Object implements FileUploadValidationService
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
DefaultUploadValidationService.Validator
-
Field Summary
Fields Modifier and Type Field Description static String
EXTENSION_MIMETYPE_ALLOWED_MAPPINGS
static String
EXTENSIONS_ALLOWED
static String
MAX_FILE_SIZE
static String
MIME_TYPES_ALLOWED
-
Fields inherited from interface org.hippoecm.frontend.plugins.yui.upload.validation.FileUploadValidationService
DEFAULT_EXTENSIONS_ALLOWED, DEFAULT_MAX_FILE_SIZE
-
Fields inherited from interface org.hippoecm.frontend.validation.IValidationService
VALIDATE_ID
-
-
Constructor Summary
Constructors Constructor Description DefaultUploadValidationService()
DefaultUploadValidationService(org.apache.wicket.util.value.IValueMap params)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addValidator(DefaultUploadValidationService.Validator validator)
void
addViolation(String key, Object... params)
String[]
getAllowedExtensions()
protected String[]
getDefaultExtensionsAllowed()
protected String
getDefaultMaxFileSize()
Check if the defaultMaximumUploadSize stored in the ApplicationSettings is set explicitly and only then used it, otherwise use DEFAULT_MAX_FILE_SIZE.org.apache.wicket.util.lang.Bytes
getMaxFileSize()
IValidationResult
getValidationResult()
static FileUploadValidationService
getValidationService(IPluginContext pluginContext, IPluginConfig pluginConfig, String defaultValidationServiceId)
Get the validation service specified by the parameterIValidationService.VALIDATE_ID
in the plugin config.void
setAllowedExtensions(String[] extensions)
void
setAllowedMimeTypes(String[] mimeTypes)
Deprecated.since 14.7.0 : setting allowed mime types does not do anything any morevoid
validate()
void
validate(org.apache.wicket.markup.html.form.upload.FileUpload upload)
-
-
-
Field Detail
-
MAX_FILE_SIZE
public static final String MAX_FILE_SIZE
- See Also:
- Constant Field Values
-
EXTENSIONS_ALLOWED
public static final String EXTENSIONS_ALLOWED
- See Also:
- Constant Field Values
-
EXTENSION_MIMETYPE_ALLOWED_MAPPINGS
public static final String EXTENSION_MIMETYPE_ALLOWED_MAPPINGS
- See Also:
- Constant Field Values
-
MIME_TYPES_ALLOWED
public static final String MIME_TYPES_ALLOWED
- See Also:
- Constant Field Values
-
-
Method Detail
-
addValidator
protected final void addValidator(DefaultUploadValidationService.Validator validator)
-
validate
public final void validate(org.apache.wicket.markup.html.form.upload.FileUpload upload) throws ValidationException
- Specified by:
validate
in interfaceFileUploadValidationService
- Throws:
ValidationException
-
validate
public void validate() throws ValidationException
- Specified by:
validate
in interfaceIValidationService
- Throws:
ValidationException
-
getValidationResult
public IValidationResult getValidationResult()
- Specified by:
getValidationResult
in interfaceIValidationService
-
addViolation
public void addViolation(String key, Object... params)
- Specified by:
addViolation
in interfaceFileUploadValidationService
-
setAllowedMimeTypes
@Deprecated public void setAllowedMimeTypes(String[] mimeTypes)
Deprecated.since 14.7.0 : setting allowed mime types does not do anything any more
-
getAllowedExtensions
public String[] getAllowedExtensions()
- Specified by:
getAllowedExtensions
in interfaceFileUploadValidationService
-
setAllowedExtensions
public void setAllowedExtensions(String[] extensions)
- Specified by:
setAllowedExtensions
in interfaceFileUploadValidationService
-
getMaxFileSize
public org.apache.wicket.util.lang.Bytes getMaxFileSize()
- Specified by:
getMaxFileSize
in interfaceFileUploadValidationService
-
getDefaultMaxFileSize
protected String getDefaultMaxFileSize()
Check if the defaultMaximumUploadSize stored in the ApplicationSettings is set explicitly and only then used it, otherwise use DEFAULT_MAX_FILE_SIZE. This is because it is set to Bytes.MAX by default which is a bit overkill (8388608T).- Returns:
- The String value of the default maximum file size for an upload
-
getDefaultExtensionsAllowed
protected String[] getDefaultExtensionsAllowed()
-
getValidationService
public static FileUploadValidationService getValidationService(IPluginContext pluginContext, IPluginConfig pluginConfig, String defaultValidationServiceId)
Get the validation service specified by the parameterIValidationService.VALIDATE_ID
in the plugin config. If no service id configuration is found, the service with iddefaultValidationServiceId
is used. If it cannot find this service, a new default service is returned.
-
-