|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jcms.upload.DocUploadInfo
public class DocUploadInfo
A convenient wrapper of uploaded files that have been decoded by MultiPartFilter. It handle uploads and rights of file path and FileDocument.
FileDocument
Field Summary | |
---|---|
protected String |
contentType
|
protected String |
fieldName
|
protected File |
file
|
protected long |
fileLength
|
protected File |
fileTmp
|
static FileDocument |
INVALID_DOCUMENT
|
protected boolean |
isFileDocument
|
protected String |
originalFileName
|
protected boolean |
override
|
static String |
REVISION
|
protected int |
status
|
static int |
STATUS_CUSTOM_REJECTED
|
static int |
STATUS_FILENAME_CONFLICT
|
static int |
STATUS_INTERNAL_ERROR
|
static int |
STATUS_NONE
|
static int |
STATUS_TOO_LARGE
|
static int |
STATUS_TOO_SMALL
|
protected String |
statusMsgProp
|
protected String |
targetFileDir
|
protected String |
targetFileName
|
Fields inherited from interface com.jalios.util.JaliosConstants |
---|
CRLF, 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 |
Constructor Summary | |
---|---|
DocUploadInfo()
|
|
DocUploadInfo(FileDocument fd)
Convenient constructor to call method checkPermission() from a given existing FileDocument |
Method Summary | |
---|---|
boolean |
canOverride()
Returns the override parameter |
boolean |
checkPermission()
Check upload permission for the given DocUploadInfo. |
protected void |
computePath()
Setup upload infos: targetFilePath targetFileName file status (Name conflicts) Vars targetFileName and targetFilePath are not modified by "override" parameter for FileDocument because old file must not be overrided at this time. |
void |
doUpload(org.apache.commons.fileupload.FileItem item,
boolean isFileDocument,
boolean override)
Performs upload of the given FileItem. |
void |
doUpload(File file,
String contentType,
boolean isFileDocument,
boolean override)
Performs upload of the given File. |
String |
getContentType()
Returns the ContentType |
File |
getFile()
Returns the uploaded File. |
FileDocument |
getFileDocument()
Returns an instance of FileDocument build from current upload infos. |
FileDocument |
getFileDocument(Class clazz)
Returns an instance of FileDocument build from current upload infos. |
long |
getFileLength()
Returns an flie length build from current upload infos. |
String |
getFilename()
Returns the relative path of the file or "" if there is no file. |
File |
getFileTmp()
Returns the uploaded tmp File. |
static long |
getMaxFileSize(String contentType)
Returns the maximum file size allowed for the given contentType. |
String |
getOriginalFileName()
Returns the original File name |
int |
getStatus()
Returns the Status |
String |
getStatusMessage(String lang)
Return a Message for the current Status. |
String |
getTargetFileDir()
Returns the path of the directory containing the target file. |
String |
getTargetFileName()
Returns the name of the target file. |
String |
getTitle()
|
boolean |
isFileDocument()
Returns the isFileDocument parameter |
protected void |
performUpload(org.apache.commons.fileupload.FileItem item)
Creates real file for the given FileItem |
void |
setCustomStatusMessage(String prop)
Set the custom status message that should be displayed to the user, must be used. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
public static final int STATUS_NONE
public static final int STATUS_FILENAME_CONFLICT
public static final int STATUS_CUSTOM_REJECTED
public static final int STATUS_INTERNAL_ERROR
public static final int STATUS_TOO_LARGE
public static final int STATUS_TOO_SMALL
protected String fieldName
protected String originalFileName
protected String contentType
protected String targetFileName
protected String targetFileDir
protected File file
protected long fileLength
protected File fileTmp
protected boolean isFileDocument
protected boolean override
protected int status
protected String statusMsgProp
public static final FileDocument INVALID_DOCUMENT
Constructor Detail |
---|
public DocUploadInfo()
public DocUploadInfo(FileDocument fd)
fd
- Method Detail |
---|
public void doUpload(File file, String contentType, boolean isFileDocument, boolean override)
file
- the File representing the given FilecontentType
- the contentType of the given FileisFileDocument
- true if it must be stored in a FileDocument Pathoverride
- true to override existing file with same namepublic void doUpload(org.apache.commons.fileupload.FileItem item, boolean isFileDocument, boolean override)
item
- the FileItem representing the given FileisFileDocument
- true if it must be stored in a FileDocument Pathoverride
- true to override existing file with same nameprotected void computePath()
protected void performUpload(org.apache.commons.fileupload.FileItem item)
item
- the FileItempublic boolean checkPermission()
public static long getMaxFileSize(String contentType)
"upload.permission.size.*"
.
contentType
- the ContentType for which we want to retrieve the maximum file size allowed.
public String getStatusMessage(String lang)
lang
- the userlang
public void setCustomStatusMessage(String prop)
Invoke during RightPolicyFilter.checkAfterUpload(DocUploadInfo)
if you refuse the file (return false).
prop
- an I18N property (e.g. "jcmsplugin.myplugin.msg.")public FileDocument getFileDocument()
public FileDocument getFileDocument(Class clazz)
clazz
- the class of FileDocument to instanciate
public String getTitle()
public String getFilename()
public String toString()
toString
in class Object
public File getFile()
public File getFileTmp()
public String getOriginalFileName()
public String getContentType()
public String getTargetFileName()
"uploaded-file.gif"
public String getTargetFileDir()
"upload/docs/image/gif/"
public int getStatus()
public boolean isFileDocument()
public boolean canOverride()
public long getFileLength()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |