Package com.jalios.jcms.upload
Class DocUploadInfo
- java.lang.Object
- 
- com.jalios.jcms.upload.DocUploadInfo
 
- 
- All Implemented Interfaces:
- JcmsConstants,- JaliosConstants
 
 public class DocUploadInfo extends java.lang.Object implements JcmsConstants A convenient wrapper of uploaded files that have been decoded by MultiPartFilter. It handle uploads and rights of file path and FileDocument.- Since:
- jcms-5.7.0
- Author:
- Jean-Philippe Encausse
- See Also:
- FileDocument
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringcontentTypeprotected java.lang.StringextensionRewrittenAfterprotected java.lang.StringextensionRewrittenBeforeprotected java.lang.StringfieldNameprotected java.io.Filefileprotected longfileLengthprotected java.io.FilefileTmpstatic FileDocumentINVALID_DOCUMENTprotected java.lang.StringoriginalFileNameprotected intstatusstatic intSTATUS_CUSTOM_REJECTEDstatic intSTATUS_FILENAME_CONFLICTstatic intSTATUS_INTERNAL_ERRORstatic intSTATUS_NONEstatic intSTATUS_TOO_LARGEstatic intSTATUS_TOO_SMALLprotected java.lang.StringstatusMsgPropprotected java.lang.StringtargetFileDirprotected java.lang.StringtargetFileNameprotected FileUploadOptionsuploadOptionsprotected WorkspaceworkspaceWorkspace used during FileDocument creationprotected org.jdom.DocumentxmlImportDocumentXML Document used to import fields during FileDocument creation- 
Fields inherited from interface com.jalios.util.JaliosConstantsCRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
 - 
Fields inherited from interface com.jalios.jcms.JcmsConstantsADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, AJAX_MODE_ATTR, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, CLASS_PROPERTY, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, COUNTRY_SPRITE, CS_TYPOLOGY_ROOT_CAT_VID, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DATA_DIRECTORY, DEFAULT_PHOTO_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, GLYPH_ICON_PREFIX, ICON_ARCHIVE, ICON_ICON_PREFIX, ICON_LOCK, ICON_LOCK_STRONG, ICON_PREFIX_PROP, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, IS_IN_FRONT_OFFICE, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JCMS_TOASTR_COLLECTION, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LANG_SPRITE, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_CREATE_STR, OP_DEEP_COPY, OP_DEEP_COPY_STR, OP_DEEP_DELETE, OP_DEEP_DELETE_STR, OP_DELETE, OP_DELETE_STR, OP_MERGE, OP_MERGE_STR, OP_UPDATE, OP_UPDATE_STR, ORGANIZATION_ROOT_GROUP_PROP, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_PROP_PREFIX, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_PROP_PREFIX, PHOTO_LARGE_WIDTH, PHOTO_MINI, PHOTO_MINI_HEIGHT, PHOTO_MINI_PROP_PREFIX, PHOTO_MINI_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_PROP_PREFIX, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_PROP_PREFIX, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_PROP_PREFIX, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, RAW_CONTENT_ICON_PREFIX, READ_RIGHT_TAB, SDATE_SEARCH, SEARCHENGINE_ALARM, SECURITY_LOG_FILE, SESSION_AUTHORIZED_FILENAMES_SET, SPRITE_ICON_PREFIX, STATS_REPORT_DIR, STATUS_PROP, STORE_DIR, STORE_XML, SUCCESS_MSG, SVG_ICON_PREFIX, SVGINLINE_ICON_PREFIX, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, TTCARD_MEDIA_HEIGHT, TTCARD_MEDIA_WIDTH, TYPES_ICON_ALT_PROP, TYPES_ICON_SUFFIX_PROP, TYPES_ICON_TITLE_PROP, TYPES_PREFIX_PROP, TYPES_THUMB_SUFFIX_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, UPLOAD_PERMISSION_COUNT_PROP_PREFIX, UPLOAD_PERMISSION_SIZE_PROP_PREFIX, URL_REGEXP, VID_LOGGED_MEMBER, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
 
- 
 - 
Constructor SummaryConstructors Constructor Description DocUploadInfo()DocUploadInfo(FileDocument fd)Convenient constructor to call method checkPermission() from a given existing FileDocument
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanOverride()Deprecated.booleancheckPermission()Check upload permission for the given DocUploadInfo.protected voidcomputePath()Setup upload infos: targetFileDir, only when working with FileDocument targetFileName, only when working with FileDocument file status (Name conflicts)voiddoUpload(java.io.File file, FileUploadOptions options)Performs upload of the specified file with corresponding options.voiddoUpload(java.io.File file, java.lang.String contentType, boolean isFileDocument, boolean override)Deprecated.voiddoUpload(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)Deprecated.voiddoUpload(org.apache.commons.fileupload.FileItem item, FileUploadOptions options)Performs upload of the specified FileItem with corresponding options.java.lang.StringgetContentType()Returns the ContentTypejava.io.FilegetFile()Returns the uploaded File.FileDocumentgetFileDocument()Returns an instance of FileDocument build from current upload infos.FileDocumentgetFileDocument(java.lang.Class clazz)Returns an instance of FileDocument build from current upload infos.longgetFileLength()Returns an flie length build from current upload infos.java.lang.StringgetFilename()Returns the relative path of the file or "" if there is no file.java.io.FilegetFileTmp()Returns the uploaded tmp File.static longgetMaxFileSize(java.lang.String contentType)Returns the maximum file size allowed for the given contentType.java.lang.StringgetOriginalFileName()Returns the original File name.intgetStatus()Returns the Statusjava.lang.StringgetStatusMessage(java.lang.String lang)Return a Message for the current Status.java.lang.StringgetTargetFileDir()Returns the path of the directory containing the target file.java.lang.StringgetTargetFileName()Returns the name of the target file.java.lang.StringgetTitle()booleanisFileDocument()Deprecated.protected voidperformUpload(org.apache.commons.fileupload.FileItem item)Creates real file for the given FileItemvoidsetCustomStatusMessage(java.lang.String prop)Set the custom status message that should be displayed to the user, must be used.voidsetWorkspace(Workspace workspace)Set the Workspace to in FileDocument when being created.voidsetXmlImportDocument(org.jdom.Document xmlImportDocument)Set the XML Document to use to populate FileDocument when being created.java.lang.StringtoString()
 
- 
- 
- 
Field Detail- 
STATUS_NONEpublic static final int STATUS_NONE - See Also:
- Constant Field Values
 
 - 
STATUS_FILENAME_CONFLICTpublic static final int STATUS_FILENAME_CONFLICT - See Also:
- Constant Field Values
 
 - 
STATUS_CUSTOM_REJECTEDpublic static final int STATUS_CUSTOM_REJECTED - See Also:
- Constant Field Values
 
 - 
STATUS_INTERNAL_ERRORpublic static final int STATUS_INTERNAL_ERROR - See Also:
- Constant Field Values
 
 - 
STATUS_TOO_LARGEpublic static final int STATUS_TOO_LARGE - See Also:
- Constant Field Values
 
 - 
STATUS_TOO_SMALLpublic static final int STATUS_TOO_SMALL - See Also:
- Constant Field Values
 
 - 
fieldNameprotected java.lang.String fieldName 
 - 
originalFileNameprotected java.lang.String originalFileName 
 - 
contentTypeprotected java.lang.String contentType 
 - 
targetFileNameprotected java.lang.String targetFileName 
 - 
targetFileDirprotected java.lang.String targetFileDir 
 - 
fileprotected java.io.File file 
 - 
fileLengthprotected long fileLength 
 - 
fileTmpprotected java.io.File fileTmp 
 - 
uploadOptionsprotected FileUploadOptions uploadOptions 
 - 
statusprotected int status 
 - 
statusMsgPropprotected java.lang.String statusMsgProp 
 - 
xmlImportDocumentprotected org.jdom.Document xmlImportDocument XML Document used to import fields during FileDocument creation
 - 
workspaceprotected Workspace workspace Workspace used during FileDocument creation
 - 
extensionRewrittenBeforeprotected java.lang.String extensionRewrittenBefore 
 - 
extensionRewrittenAfterprotected java.lang.String extensionRewrittenAfter 
 - 
INVALID_DOCUMENTpublic static final FileDocument INVALID_DOCUMENT 
 
- 
 - 
Constructor Detail- 
DocUploadInfopublic DocUploadInfo() 
 - 
DocUploadInfopublic DocUploadInfo(FileDocument fd) Convenient constructor to call method checkPermission() from a given existing FileDocument- Parameters:
- fd- the FileDocument
 
 
- 
 - 
Method Detail- 
doUpload@Deprecated public void doUpload(java.io.File file, java.lang.String contentType, boolean isFileDocument, boolean override)Deprecated.Performs upload of the given File.- Parameters:
- file- the File representing the given File
- contentType- the contentType of the given File
- isFileDocument- true if it must be stored in a FileDocument Path
- override- IGNORED
 
 - 
doUploadpublic void doUpload(java.io.File file, FileUploadOptions options)Performs upload of the specified file with corresponding options.- Parameters:
- file- the File representing the given File
- options- the upload options may be null
- Since:
- jcms-10.0.6 / JCMS-8317
 
 - 
doUpload@Deprecated public void doUpload(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)Deprecated.Performs upload of the given FileItem.- Parameters:
- item- the FileItem representing the given File
- isFileDocument- true if it must be stored in a FileDocument Path
- override- IGNORED
 
 - 
doUploadpublic void doUpload(org.apache.commons.fileupload.FileItem item, FileUploadOptions options)Performs upload of the specified FileItem with corresponding options.- Parameters:
- item- the FileItem representing the given File
- options- the upload options may be null
- Since:
- jcms-10.0.6 / JCMS-8317
 
 - 
computePathprotected void computePath() Setup upload infos:- targetFileDir, only when working with FileDocument
- targetFileName, only when working with FileDocument
- file
- status (Name conflicts)
 
 - 
performUploadprotected void performUpload(org.apache.commons.fileupload.FileItem item) Creates real file for the given FileItem- Parameters:
- item- the FileItem
 
 - 
checkPermissionpublic boolean checkPermission() Check upload permission for the given DocUploadInfo. Then check permission in the RightPolicy. If file is rejected then delete file.- Returns:
- true if the Permission are OK.
 
 - 
getMaxFileSizepublic static long getMaxFileSize(java.lang.String contentType) Returns the maximum file size allowed for the given contentType.
 Can be configured by modifying properties"upload.permission.size.*".- Parameters:
- contentType- the ContentType for which we want to retrieve the maximum file size allowed.
- Returns:
- a file size in bytes
- Since:
- jcms-5.7.0
 
 - 
getStatusMessagepublic java.lang.String getStatusMessage(java.lang.String lang) Return a Message for the current Status.- Parameters:
- lang- the userlang
- Returns:
- String a message for the given status
 
 - 
setCustomStatusMessagepublic void setCustomStatusMessage(java.lang.String prop) Set the custom status message that should be displayed to the user, must be used.Invoke during RightPolicyFilter.checkAfterUpload(DocUploadInfo)if you refuse the file (return false).- Parameters:
- prop- an I18N property (e.g. "jcmsplugin.myplugin.msg.")
 
 - 
getFileDocumentpublic FileDocument getFileDocument() Returns an instance of FileDocument build from current upload infos. performCreate is never called on FileDocument- Returns:
- FileDocument
 
 - 
getFileDocumentpublic FileDocument getFileDocument(java.lang.Class clazz) Returns an instance of FileDocument build from current upload infos. performCreate is never called on FileDocument- Parameters:
- clazz- the class of FileDocument to instanciate
- Returns:
- FileDocument
- Since:
- jcms-6.2.0
 
 - 
getTitlepublic java.lang.String getTitle() 
 - 
getFilenamepublic java.lang.String getFilename() Returns the relative path of the file or "" if there is no file.For use only when working with FileDocument. - Returns:
- String the path relative to the webapp root, return null if upload was not performed to create/update a FileDocument
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getFilepublic java.io.File getFile() Returns the uploaded File. Since JCMS 6.1, the file is stored in fileTmp then moved to file. So code calling this method might be modified.- Returns:
- File the uploaded File
- Since:
- jcms-6.1.0
 
 - 
getFileTmppublic java.io.File getFileTmp() Returns the uploaded tmp File. Used for permission checks- Returns:
- File the uploaded File
 
 - 
getOriginalFileNamepublic java.lang.String getOriginalFileName() Returns the original File name.Value is guaranteed to be sanitized (ie without path seperator like / or \to prevent any path traversal) and safe for use as new file name. - Returns:
- String original File name
 
 - 
getContentTypepublic java.lang.String getContentType() Returns the ContentType- Returns:
- String the ContentType
 
 - 
getTargetFileNamepublic java.lang.String getTargetFileName() Returns the name of the target file. e.g.:"uploaded-file.gif"- Returns:
- a file name
 
 - 
getTargetFileDirpublic java.lang.String getTargetFileDir() Returns the path of the directory containing the target file. e.g.:"upload/docs/image/gif/"- Returns:
- a relative path
 
 - 
getStatuspublic int getStatus() Returns the Status- Returns:
- String the Status
 
 - 
isFileDocument@Deprecated public boolean isFileDocument() Deprecated.Returns the isFileDocument parameter- Returns:
- boolean the isFileDocument
 
 - 
canOverride@Deprecated public boolean canOverride() Deprecated.Returns the override parameter- Returns:
- always return false
 
 - 
getFileLengthpublic long getFileLength() Returns an flie length build from current upload infos.- Returns:
- file length
 
 - 
setXmlImportDocumentpublic void setXmlImportDocument(org.jdom.Document xmlImportDocument) Set the XML Document to use to populate FileDocument when being created.- Parameters:
- xmlImportDocument- a JDom XML Document
- Since:
- jcms-9.0
 
 - 
setWorkspacepublic void setWorkspace(Workspace workspace) Set the Workspace to in FileDocument when being created.- Parameters:
- workspace- a Workspace
- Since:
- jcms-9.0.2
 
 
- 
 
-