org.silverpeas.upload
Class UploadSession

java.lang.Object
  extended by org.silverpeas.upload.UploadSession

public class UploadSession
extends Object

Manage a session of file & folder upload. Each file is saved in a temporary folder the server. The different treatments which use this mechanism must use all the services provided by FileUploadManager and UploadedFile in order to save definitely the uploaded files.

Author:
Yohann Chastagnier

Method Summary
 void clear()
          Clears the session (deletes all the file from the server).
static void clearFrom(SessionInfo sessionInfo)
          Clears the upload sessions still attached to a user session.
 UploadSession forComponentInstanceId(String componentInstanceId)
          Sets the component instance id associated to the upload session.
static UploadSession from(javax.servlet.http.HttpServletRequest request)
          Initializes an instance from a request (if not created, a new one will be created if necessary).
static UploadSession from(String uploadSessionId)
          Initializes an instance from a session id (if not created, a new one will be created if necessary).
 String getComponentInstanceId()
          Gets the component instance id if any associated.
 String getComponentInstanceParameterValue(String parameterName)
          Gets the parameter value of a component instance.
 String getId()
          Gets the session identifier.
 File getRootFolder()
          Gets the root folder on the server of the upload session.
 File[] getRootFolderFiles()
          Gets the File list (so file or folder) from the root folder on the server of the upload session.
 UploadSessionFile getUploadSessionFile(String fullPath)
          Gets a new upload file from the session.
 boolean isUserAuthorized(String componentInstanceId)
          Indicates if the current user is authorized to perform this upload session.
 boolean remove(String fullPath)
          Removes from the upload session the file identified by the given identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forComponentInstanceId

public UploadSession forComponentInstanceId(String componentInstanceId)
Sets the component instance id associated to the upload session.

Parameters:
componentInstanceId -

isUserAuthorized

public boolean isUserAuthorized(String componentInstanceId)
Indicates if the current user is authorized to perform this upload session.

Parameters:
componentInstanceId -

getId

public String getId()
Gets the session identifier.

Returns:
a string.

getComponentInstanceId

public String getComponentInstanceId()
Gets the component instance id if any associated.

Returns:
a string.

getComponentInstanceParameterValue

public String getComponentInstanceParameterValue(String parameterName)
Gets the parameter value of a component instance. The component instance is the one passed on file uploads. If no component instance identifier has been passed, then nothing is done.

Returns:
a string that represents the parameter value, empty value if the component instance identifier is unknown or if the parameter is not defined for component instance.

clear

public void clear()
Clears the session (deletes all the file from the server).


remove

public boolean remove(String fullPath)
               throws Exception
Removes from the upload session the file identified by the given identifier. If the file path is currently in writing mode, nothing is removed.

Parameters:
fullPath - the path of the file into the session.
Returns:
true of removed has been effective, false otherwise.
Throws:
Exception

getUploadSessionFile

public UploadSessionFile getUploadSessionFile(String fullPath)
                                       throws Exception
Gets a new upload file from the session. If the file path is currently in writing mode, the the UploadSessionFile.getServerFile() of the returned instance is null.

Parameters:
fullPath - the path of the file into the session.
Returns:
Throws:
Exception

getRootFolder

public File getRootFolder()
Gets the root folder on the server of the upload session.
If the folder does not yet exist, then it is created.

Returns:
a File that represents the upload session folder.

getRootFolderFiles

public File[] getRootFolderFiles()
Gets the File list (so file or folder) from the root folder on the server of the upload session.
If the folder does not yet exist, then it is created.

Returns:
a list of File from the root folder provided by getRootFolder().

from

public static UploadSession from(javax.servlet.http.HttpServletRequest request)
Initializes an instance from a request (if not created, a new one will be created if necessary).

Parameters:
request - an http servlet request.
Returns:
a new initialized instance.

from

public static UploadSession from(String uploadSessionId)
Initializes an instance from a session id (if not created, a new one will be created if necessary).

Parameters:
uploadSessionId - an existing, or not, upload session id.
Returns:
a new initialized instance.

clearFrom

public static void clearFrom(SessionInfo sessionInfo)
Clears the upload sessions still attached to a user session.

Parameters:
sessionInfo - the session of a user.


Copyright © 2016 Silverpeas. All Rights Reserved.