public class InputFileMimetypeValidator extends Object implements Validator, StateHolder
Validates an InputFileInfo
blob value in case it's been uploaded.
Accepted mimetypes are set using the "extensions" attribute, representing the
list of accepted extension suffixes separated by commas (for instance:
".jpeg, .png").
Validation is done on the filename, no actual mimetype check is done for now.
Modifier and Type | Field and Description |
---|---|
static String |
MIMETYPE_AUTHORIZED_EXTENSIONS_MESSAGE_ID
The message identifier of the
FacesMessage to be created if the
authorized extensions check fails. |
static String |
MIMETYPE_UNAUTHORIZED_EXTENSIONS_MESSAGE_ID
The message identifier of the
FacesMessage to be created if the
unauthorized extensions check fails. |
static String |
VALIDATOR_ID |
NOT_IN_RANGE_MESSAGE_ID
Constructor and Description |
---|
InputFileMimetypeValidator() |
Modifier and Type | Method and Description |
---|---|
String[] |
getExtensions() |
boolean |
isAuthorized() |
boolean |
isHidden() |
boolean |
isTransient() |
void |
restoreState(FacesContext context,
Object state) |
Object |
saveState(FacesContext context) |
void |
setAuthorized(boolean authorized) |
void |
setExtensions(String[] extensions) |
void |
setHidden(boolean hidden) |
void |
setTransient(boolean newTransientValue) |
void |
validate(FacesContext context,
UIComponent component,
Object value) |
public static final String VALIDATOR_ID
public static final String MIMETYPE_AUTHORIZED_EXTENSIONS_MESSAGE_ID
FacesMessage
to be created if the
authorized extensions check fails. The message format string for this
message may optionally include the following placeholders:
{0}
replaced by the configured auhtorized extensions.public static final String MIMETYPE_UNAUTHORIZED_EXTENSIONS_MESSAGE_ID
FacesMessage
to be created if the
unauthorized extensions check fails. The message format string for this
message may optionally include the following placeholders:
{0}
replaced by the configured unauthorized extensions.public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
validate
in interface Validator
ValidatorException
public String[] getExtensions()
public void setExtensions(String[] extensions)
public boolean isAuthorized()
public void setAuthorized(boolean authorized)
public boolean isHidden()
public void setHidden(boolean hidden)
public boolean isTransient()
isTransient
in interface StateHolder
public void setTransient(boolean newTransientValue)
setTransient
in interface StateHolder
public Object saveState(FacesContext context)
saveState
in interface StateHolder
public void restoreState(FacesContext context, Object state)
restoreState
in interface StateHolder
Copyright © 2013 Nuxeo SA. All Rights Reserved.