Class AbstractFileFieldDisplayer
- java.lang.Object
-
- org.silverpeas.core.contribution.content.form.displayers.AbstractFieldDisplayer<FileField>
-
- org.silverpeas.core.contribution.content.form.displayers.AbstractFileFieldDisplayer
-
- All Implemented Interfaces:
FieldDisplayer<FileField>
- Direct Known Subclasses:
FileFieldDisplayer
,ImageFieldDisplayer
,VideoFieldDisplayer
public abstract class AbstractFileFieldDisplayer extends AbstractFieldDisplayer<FileField>
- Author:
- ehugonnet
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractFileFieldDisplayer.Operation
The different kinds of operation that can be applied into an attached file.
-
Field Summary
Fields Modifier and Type Field Description protected static String
OPERATION_KEY
-
Constructor Summary
Constructors Constructor Description AbstractFileFieldDisplayer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkFieldType(String typeName, String contextCall)
Checks the type of the field is as expected.protected SimpleDocument
createSimpleDocument(String objectId, String componentId, org.apache.commons.fileupload.FileItem item, String fileName, String userId, boolean versionned)
protected void
deleteAttachment(String attachmentId, PagesContext pageContext)
Deletes the specified attachment, identified by its unique identifier.?void
displayScripts(PrintWriter out, FieldTemplate template, PagesContext pageContext)
Prints the javascripts which will be used to control the new value given to the named field.String[]
getManagedTypes()
Returns the name of the managed types.protected boolean
isDeletion(AbstractFileFieldDisplayer.Operation operation, String attachmentId)
Is the specified operation is a deletion?boolean
isDisplayedMandatory()
protected boolean
isUpdate(AbstractFileFieldDisplayer.Operation operation, String attachmentId)
Is the specified operation is an update?protected String
processInput(List<org.apache.commons.fileupload.FileItem> items, FileField field, PagesContext pageContext)
protected String
processUploadedFile(List<org.apache.commons.fileupload.FileItem> items, String parameterName, PagesContext pagesContext)
List<String>
update(String attachmentId, FileField field, FieldTemplate template, PagesContext pagesContext)
Updates the value of the field.List<String>
update(List<org.apache.commons.fileupload.FileItem> items, FileField field, FieldTemplate template, PagesContext pageContext)
Updates the value of the field.-
Methods inherited from class org.silverpeas.core.contribution.content.form.displayers.AbstractFieldDisplayer
getDefaultValue, index
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.contribution.content.form.FieldDisplayer
display, getNbHtmlObjectsDisplayed
-
-
-
-
Field Detail
-
OPERATION_KEY
protected static final String OPERATION_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
createSimpleDocument
protected SimpleDocument createSimpleDocument(String objectId, String componentId, org.apache.commons.fileupload.FileItem item, String fileName, String userId, boolean versionned) throws IOException
- Throws:
IOException
-
deleteAttachment
protected void deleteAttachment(String attachmentId, PagesContext pageContext)
Deletes the specified attachment, identified by its unique identifier.?- Parameters:
attachmentId
- the unique identifier of the attachment to delete.pageContext
- the context of the page.
-
getManagedTypes
public String[] getManagedTypes()
Returns the name of the managed types.
-
displayScripts
public void displayScripts(PrintWriter out, FieldTemplate template, PagesContext pageContext)
Prints the javascripts which will be used to control the new value given to the named field. The error messages may be adapted to a local language. The FieldTemplate gives the field type and constraints. The FieldTemplate gives the local labeld too. Never throws an Exception but log a silvertrace and writes an empty string when :- the fieldName is unknown by the template.
- the field type is not a managed type.
-
update
public List<String> update(List<org.apache.commons.fileupload.FileItem> items, FileField field, FieldTemplate template, PagesContext pageContext) throws FormException
Description copied from interface:FieldDisplayer
Updates the value of the field. The fieldName must be used to retrieve the HTTP parameter from the request. @throw FormException if the field type is not a managed type. @throw FormException if the field doesn't accept the new value.- Specified by:
update
in interfaceFieldDisplayer<FileField>
- Overrides:
update
in classAbstractFieldDisplayer<FileField>
- Throws:
FormException
-
processInput
protected String processInput(List<org.apache.commons.fileupload.FileItem> items, FileField field, PagesContext pageContext)
-
update
public List<String> update(String attachmentId, FileField field, FieldTemplate template, PagesContext pagesContext) throws FormException
Description copied from interface:FieldDisplayer
Updates the value of the field. The fieldName must be used to retrieve the HTTP parameter from the request. @throw FormException if the field type is not a managed type. @throw FormException if the field doesn't accept the new value.- Throws:
FormException
-
isDeletion
protected boolean isDeletion(AbstractFileFieldDisplayer.Operation operation, String attachmentId)
Is the specified operation is a deletion?- Parameters:
operation
- the operation.attachmentId
- the identifier of the attachment on which the operation is.- Returns:
- true if the operation is a deletion, false otherwise.
-
isUpdate
protected boolean isUpdate(AbstractFileFieldDisplayer.Operation operation, String attachmentId)
Is the specified operation is an update?- Parameters:
operation
- the operation.attachmentId
- the identifier of the attachment on which the operation is.- Returns:
- true if the operation is an update, false otherwise.
-
processUploadedFile
protected String processUploadedFile(List<org.apache.commons.fileupload.FileItem> items, String parameterName, PagesContext pagesContext) throws IOException
- Throws:
IOException
-
isDisplayedMandatory
public boolean isDisplayedMandatory()
-
checkFieldType
protected void checkFieldType(String typeName, String contextCall)
Checks the type of the field is as expected. The field must be of type file.- Parameters:
typeName
- the name of the type.contextCall
- the context of the call: which is the caller of this method. This parameter is used for trace purpose.
-
-