Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.ui.web.component.file
Class InputFileMimetypeValidator

java.lang.Object
  extended by org.nuxeo.ecm.platform.ui.web.component.file.InputFileMimetypeValidator
All Implemented Interfaces:
EventListener, StateHolder, Validator

public class InputFileMimetypeValidator
extends Object
implements Validator, StateHolder

Input file mimetype validator.

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.

Author:
Anahide Tchertchian

Field Summary
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
           
 
Fields inherited from interface javax.faces.validator.Validator
NOT_IN_RANGE_MESSAGE_ID
 
Constructor Summary
InputFileMimetypeValidator()
           
 
Method Summary
 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)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALIDATOR_ID

public static final String VALIDATOR_ID
See Also:
Constant Field Values

MIMETYPE_AUTHORIZED_EXTENSIONS_MESSAGE_ID

public static final String MIMETYPE_AUTHORIZED_EXTENSIONS_MESSAGE_ID
The message identifier of the FacesMessage to be created if the authorized extensions check fails. The message format string for this message may optionally include the following placeholders:

See Also:
Constant Field Values

MIMETYPE_UNAUTHORIZED_EXTENSIONS_MESSAGE_ID

public static final String MIMETYPE_UNAUTHORIZED_EXTENSIONS_MESSAGE_ID
The message identifier of the FacesMessage to be created if the unauthorized extensions check fails. The message format string for this message may optionally include the following placeholders:

See Also:
Constant Field Values
Constructor Detail

InputFileMimetypeValidator

public InputFileMimetypeValidator()
Method Detail

validate

public void validate(FacesContext context,
                     UIComponent component,
                     Object value)
              throws ValidatorException
Specified by:
validate in interface Validator
Throws:
ValidatorException

getExtensions

public String[] getExtensions()

setExtensions

public void setExtensions(String[] extensions)

isAuthorized

public boolean isAuthorized()

setAuthorized

public void setAuthorized(boolean authorized)

isHidden

public boolean isHidden()

setHidden

public void setHidden(boolean hidden)

isTransient

public boolean isTransient()
Specified by:
isTransient in interface StateHolder

setTransient

public void setTransient(boolean newTransientValue)
Specified by:
setTransient in interface StateHolder

saveState

public Object saveState(FacesContext context)
Specified by:
saveState in interface StateHolder

restoreState

public void restoreState(FacesContext context,
                         Object state)
Specified by:
restoreState in interface StateHolder

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.