com.trackstudio.app.webdav
Class TSStorage

java.lang.Object
  extended by com.trackstudio.app.webdav.TSStorage
All Implemented Interfaces:
IWebdavStorage

public class TSStorage
extends java.lang.Object
implements IWebdavStorage

Reference Implementation of IWebdavStorage

Author:
joa, re

Field Summary
static java.lang.String DAV_ROOT
           
static java.lang.String DAV_ROOT_TASK
           
static java.lang.String DAV_ROOT_USER
           
static java.lang.String DAV_ZIP_FOLDER
           
static java.lang.String DELIM1
           
static java.lang.String SESSION_ID
           
 
Constructor Summary
TSStorage()
           
 
Method Summary
 void begin(java.security.Principal principal, java.util.Hashtable parameters, SessionContext sc)
          Indicates that a new request or transaction with this store involved has been started.
 void checkAuthentication(SessionContext sc)
          Checks if authentication information passed in IWebdavStorage.begin(Principal, Hashtable, SessionContext) is valid.
 void commit()
          Indicates that all changes done inside this request shall be made permanent and any transactions, connections and other temporary resources shall be terminated.
 void createFolder(java.lang.String uri, SessionContext sc)
          Creates a folder at the position specified by folderUri.
 void createResource(java.lang.String uri, SessionContext sc)
          Creates a content resource at the position specified by resourceUri.
 java.lang.String getAttachmentName(java.lang.String uri, SessionContext sc)
           
 java.lang.String[] getChildrenNames(java.lang.String uri, SessionContext sc)
          Gets the names of the children of the folder specified by folderUri.
 java.util.Date getCreationDate(java.lang.String uri, SessionContext sc)
          Gets the date of the creation of the object specified by uri.
 java.util.Date getLastModified(java.lang.String uri, SessionContext sc)
          Gets the date of the last modiciation of the object specified by uri.
 java.lang.String getMimeType(java.lang.String path, java.lang.String name, SessionContext sc)
           
 java.io.InputStream getResourceContent(java.lang.String uri, SessionContext sc)
          Gets the content of the resource specified by resourceUri.
 long getResourceLength(java.lang.String uri, SessionContext sc)
          Gets the length of the content resource specified by resourceUri.
 boolean isFolder(java.lang.String uri, SessionContext sc)
          Checks if there is an object at the position specified by uri and if so if it is a folder.
 boolean isResource(java.lang.String uri, SessionContext sc)
          Checks if there is an object at the position specified by uri and if so if it is a content resource.
 boolean objectExists(java.lang.String uri, SessionContext sc)
          Checks if there is an object at the position specified by uri.
static java.lang.String removeLocaleCharacters(java.lang.String str)
          Remove national characters from sting except zipped file names
 void removeObject(java.lang.String uri, SessionContext sc)
          Removes the object specified by uri.
 void rollback()
          Indicates that all changes done inside this request shall be undone and any transactions, connections and other temporary resources shall be terminated.
 void setResourceContent(java.lang.String uri, java.io.InputStream is, java.lang.String contentType, java.lang.String characterEncoding, SessionContext sc)
          tries to save the given InputStream to the file at path "uri".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DAV_ROOT

public static final java.lang.String DAV_ROOT
See Also:
Constant Field Values

DAV_ROOT_TASK

public static final java.lang.String DAV_ROOT_TASK
See Also:
Constant Field Values

DAV_ROOT_USER

public static final java.lang.String DAV_ROOT_USER
See Also:
Constant Field Values

DAV_ZIP_FOLDER

public static final java.lang.String DAV_ZIP_FOLDER
See Also:
Constant Field Values

SESSION_ID

public static final java.lang.String SESSION_ID
See Also:
Constant Field Values

DELIM1

public static final java.lang.String DELIM1
See Also:
Constant Field Values
Constructor Detail

TSStorage

public TSStorage()
Method Detail

begin

public void begin(java.security.Principal principal,
                  java.util.Hashtable parameters,
                  SessionContext sc)
           throws java.lang.Exception
Description copied from interface: IWebdavStorage
Indicates that a new request or transaction with this store involved has been started. The request will be terminated by either IWebdavStorage.commit() or IWebdavStorage.rollback(). If only non-read methods have been called, the request will be terminated by a IWebdavStorage.commit(). This method will be called by (@link WebdavStoreAdapter} at the beginning of each request.

Specified by:
begin in interface IWebdavStorage
Parameters:
principal - the principal that started this request or null if there is non available
parameters - Hashtable containing the parameters' names and associated values configured in the from web.xml
Throws:
java.lang.Exception

checkAuthentication

public void checkAuthentication(SessionContext sc)
                         throws java.lang.SecurityException
Description copied from interface: IWebdavStorage
Checks if authentication information passed in IWebdavStorage.begin(Principal, Hashtable, SessionContext) is valid. If not throws an exception.

Specified by:
checkAuthentication in interface IWebdavStorage
Throws:
java.lang.SecurityException - if authentication is not valid

commit

public void commit()
            throws java.io.IOException
Description copied from interface: IWebdavStorage
Indicates that all changes done inside this request shall be made permanent and any transactions, connections and other temporary resources shall be terminated.

Specified by:
commit in interface IWebdavStorage
Throws:
java.io.IOException - if something goes wrong on the store level

rollback

public void rollback()
              throws java.io.IOException
Description copied from interface: IWebdavStorage
Indicates that all changes done inside this request shall be undone and any transactions, connections and other temporary resources shall be terminated.

Specified by:
rollback in interface IWebdavStorage
Throws:
java.io.IOException - if something goes wrong on the store level

objectExists

public boolean objectExists(java.lang.String uri,
                            SessionContext sc)
                     throws java.io.IOException
Description copied from interface: IWebdavStorage
Checks if there is an object at the position specified by uri.

Specified by:
objectExists in interface IWebdavStorage
Parameters:
uri - URI of the object to check
Returns:
true if the object at uri exists
Throws:
java.io.IOException - if something goes wrong on the store level

isFolder

public boolean isFolder(java.lang.String uri,
                        SessionContext sc)
                 throws java.io.IOException,
                        GranException
Description copied from interface: IWebdavStorage
Checks if there is an object at the position specified by uri and if so if it is a folder.

Specified by:
isFolder in interface IWebdavStorage
Parameters:
uri - URI of the object to check
Returns:
true if the object at uri exists and is a folder
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

isResource

public boolean isResource(java.lang.String uri,
                          SessionContext sc)
                   throws java.io.IOException,
                          GranException
Description copied from interface: IWebdavStorage
Checks if there is an object at the position specified by uri and if so if it is a content resource.

Specified by:
isResource in interface IWebdavStorage
Parameters:
uri - URI of the object to check
Returns:
true if the object at uri exists and is a content resource
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

createFolder

public void createFolder(java.lang.String uri,
                         SessionContext sc)
                  throws java.io.IOException
Description copied from interface: IWebdavStorage
Creates a folder at the position specified by folderUri.

Specified by:
createFolder in interface IWebdavStorage
Parameters:
uri - URI of the folder
Throws:
java.io.IOException - if the folder cannot be created

createResource

public void createResource(java.lang.String uri,
                           SessionContext sc)
                    throws java.io.IOException,
                           GranException
Description copied from interface: IWebdavStorage
Creates a content resource at the position specified by resourceUri.

Specified by:
createResource in interface IWebdavStorage
Parameters:
uri - URI of the content resource
Throws:
java.io.IOException - if the resource cannot be created
GranException

getLastModified

public java.util.Date getLastModified(java.lang.String uri,
                                      SessionContext sc)
                               throws java.io.IOException,
                                      GranException
Description copied from interface: IWebdavStorage
Gets the date of the last modiciation of the object specified by uri.

Specified by:
getLastModified in interface IWebdavStorage
Parameters:
uri - URI of the object, i.e. content resource or folder
Returns:
the lastModified Date
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

getCreationDate

public java.util.Date getCreationDate(java.lang.String uri,
                                      SessionContext sc)
                               throws java.io.IOException,
                                      GranException
Description copied from interface: IWebdavStorage
Gets the date of the creation of the object specified by uri.

Specified by:
getCreationDate in interface IWebdavStorage
Parameters:
uri - URI of the object, i.e. content resource or folder
Returns:
the lastModified date of the file, java.io.file does not support a creation date
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

removeLocaleCharacters

public static java.lang.String removeLocaleCharacters(java.lang.String str)
Remove national characters from sting except zipped file names

Parameters:
str -
Returns:

getChildrenNames

public java.lang.String[] getChildrenNames(java.lang.String uri,
                                           SessionContext sc)
                                    throws java.io.IOException,
                                           GranException
Description copied from interface: IWebdavStorage
Gets the names of the children of the folder specified by folderUri.

Specified by:
getChildrenNames in interface IWebdavStorage
Parameters:
uri - URI of the folder
Returns:
a (possibly empty) list of children, or null if the uri points to a file
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

getResourceContent

public java.io.InputStream getResourceContent(java.lang.String uri,
                                              SessionContext sc)
                                       throws java.io.IOException,
                                              GranException
Description copied from interface: IWebdavStorage
Gets the content of the resource specified by resourceUri.

Specified by:
getResourceContent in interface IWebdavStorage
Parameters:
uri - URI of the content resource
Returns:
an input stream to the specified resource
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

getAttachmentName

public java.lang.String getAttachmentName(java.lang.String uri,
                                          SessionContext sc)
                                   throws GranException
Throws:
GranException

setResourceContent

public void setResourceContent(java.lang.String uri,
                               java.io.InputStream is,
                               java.lang.String contentType,
                               java.lang.String characterEncoding,
                               SessionContext sc)
                        throws java.io.IOException,
                               GranException
tries to save the given InputStream to the file at path "uri". content type and charachter encoding are ignored

Specified by:
setResourceContent in interface IWebdavStorage
Parameters:
uri - URI of the resource where the content will be stored
is - input stream from which the content will be read from
contentType - content type of the resource or null if unknown
characterEncoding - character encoding of the resource or null if unknown or not applicable
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

getResourceLength

public long getResourceLength(java.lang.String uri,
                              SessionContext sc)
                       throws java.io.IOException,
                              GranException
Description copied from interface: IWebdavStorage
Gets the length of the content resource specified by resourceUri.

Specified by:
getResourceLength in interface IWebdavStorage
Parameters:
uri - URI of the content resource
Returns:
the size of the file
Throws:
java.io.IOException - if something goes wrong on the store level
GranException

removeObject

public void removeObject(java.lang.String uri,
                         SessionContext sc)
                  throws java.io.IOException,
                         GranException
Description copied from interface: IWebdavStorage
Removes the object specified by uri.

Specified by:
removeObject in interface IWebdavStorage
Parameters:
uri - URI of the object, i.e. content resource or folder
Throws:
java.io.IOException - if the deletion failed
GranException

getMimeType

public java.lang.String getMimeType(java.lang.String path,
                                    java.lang.String name,
                                    SessionContext sc)
                             throws java.io.IOException,
                                    GranException
Throws:
java.io.IOException
GranException


Copyright © 2002-2009 TrackStudio, Ltd. All Rights Reserved.