com.jalios.jcms.webdav.cat
Class CatWebdavFileSystem

java.lang.Object
  extended by com.jalios.jcms.webdav.WebdavFileSystem
      extended by com.jalios.jcms.webdav.cat.CatWebdavFileSystem

public class CatWebdavFileSystem
extends WebdavFileSystem

A JCMS Representation of a Webdav FileSystem The root directory will be defined by servlet configuration parameter "RootPath"

Since:
jcms-5.5.0
Version:
$Revision: 30870 $
Author:
Jean-Philippe Encausse

Field Summary
static String REVISION
           
protected  Data root
           
protected static org.apache.oro.text.regex.Pattern silentFilterPattern
           
 
Fields inherited from class com.jalios.jcms.webdav.WebdavFileSystem
resourceLocks
 
Constructor Summary
CatWebdavFileSystem(WebdavContext ctxt)
           
 
Method Summary
 void addFileDocument(Set<Data> childrenSet, Member loggedMember, Workspace workspace, Category category)
           
 boolean canBeReadBy(Data data, Member loggedMember)
           
 boolean canReadData(Data data, boolean recursive, WebdavContext ctxt)
          Check if the data can be read given the current context
protected  boolean checkSetNewWorkspace(Workspace oldWS, Workspace newWS, Set<Category> pubCatSet)
           
 boolean copyFolder(WebdavResource src, WebdavResource tgt, boolean overwrite, boolean recursive, WebdavContext ctxt)
           
 boolean copyMoveFile(WebdavResource src, WebdavResource tgt, boolean move, WebdavContext ctxt)
          This method Copy/Move a resource to a given target location
 boolean createFile(WebdavResource res, WebdavContext ctxt)
          Create a resource child of a given folder with the given name If child already exists in JCMS then recaterize it
 boolean createFolder(WebdavResource res, WebdavContext ctxt)
          Create a given target folder
 boolean deleteFile(WebdavResource res, WebdavContext ctxt)
          Delete a given target file
 boolean deleteFolder(WebdavResource res, WebdavContext ctxt)
          Delete a given target folder
 boolean doCopy(WebdavResource source, WebdavResource target, boolean overwrite, boolean recursive, WebdavContext ctxt)
          This method perform copy from one Webdav Resource to an Other
 boolean doCreate(WebdavResource resource, boolean overwrite, boolean isFolder, WebdavContext ctxt)
          This method perform create from one Webdav Resource
 boolean doDelete(WebdavResource resource, boolean recursive, WebdavContext ctxt)
          This method perform delete from one Webdav Resource
 boolean doMove(WebdavResource source, WebdavResource target, boolean overwrite, boolean recursive, WebdavContext ctxt)
          This method perform move from one Webdav Resource to an Other
 long getContentLength(Data data, WebdavContext ctxt)
          This method return the length of the ressource
 String getContentType(Data data, WebdavContext ctxt)
          This method return the content type of the ressource
 Collection<Data> getDataChildrenSet(Data parent, WebdavContext ctxt)
           
 Data getDataFromName(String name, Data parent, boolean onlyFolders, WebdavContext ctxt)
          Return the Data represented by the given short uri
 Data getDataFromUri(String uri, WebdavContext ctxt)
          Retrieve the Data from the given URI Starting from the given root.
 String getNameFromData(Data data, WebdavContext ctxt)
          This method return the short name of the given data (Category or FileDocument) for this implementation
 WebdavResource getResource(String uri, WebdavContext ctxt)
          Lookup the resource represented by the given URI.
 InputStream getResourceStream(Data data, WebdavContext ctxt)
          This method return the resource input stream
 Workspace getWorkspaceFromURI(String uri, WebdavContext ctxt)
          This method return the Workspace bind to the given URI.
 void init()
          Called after authentication for each request.
 boolean isExisting(Data data, WebdavContext ctxt)
          This method return true if the Data is existing
 boolean isFile(Data data, WebdavContext ctxt)
          This method return true if the Data is a File
 boolean isFolder(Data data, WebdavContext ctxt)
          This method return true if the Data is a Folder
 boolean isReadable(WebdavResource res, boolean recursive, WebdavContext ctxt)
          Check if the resource is Readable
 boolean isReadOnly(WebdavContext ctxt)
          Check if the FileSystem is ReadOnly.
 boolean isWritable(WebdavResource res, boolean recursive, boolean overwrite, WebdavContext ctxt)
          Check if the resource is Writable
 boolean moveFolder(WebdavResource src, WebdavResource tgt, boolean overwrite, boolean recursive, WebdavContext ctxt)
          This method will move a given source to target location If target folder already exists then: - Copy all children of the target under source - Then copy all children of source under target - Then remove source
 WebdavLock newLock(WebdavResource resource, WebdavContext ctxt)
          This method will return a new WebdavLock implementation
 boolean renameFile(WebdavResource src, WebdavResource tgt, WebdavContext ctxt)
          Rename the given WebdavResource file to the given target resource
 boolean renameFolder(WebdavResource src, WebdavResource tgt, WebdavContext ctxt)
          Rename the given WebdavResource folder to the given target resource
 boolean setResourceStream(Data data, File tmp, WebdavContext ctxt)
          Update/Override the FileDocument
protected  boolean silentFilterResource(WebdavResource resource, WebdavContext ctxt)
          Return true if the resource should be silently ignored.
 
Methods inherited from class com.jalios.jcms.webdav.WebdavFileSystem
afterDoDelete, afterDoMove, doLock, doPut, doUnlock, getAbsoluteUri, getDescendantLocks, getLocks, getRelativeUri, hasInternalLock, isInternallyLocked, isListing, matchesIfHeaderCondition, normalize, putLock, putLocks, refreshLock, removeLock, removeLocks
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

root

protected Data root

silentFilterPattern

protected static final org.apache.oro.text.regex.Pattern silentFilterPattern
See Also:
WebdavFileSystem.silentFilterResource(WebdavResource, WebdavContext)
Constructor Detail

CatWebdavFileSystem

public CatWebdavFileSystem(WebdavContext ctxt)
Method Detail

init

public void init()
Description copied from class: WebdavFileSystem
Called after authentication for each request. Used to initialized cached data.

Overrides:
init in class WebdavFileSystem
See Also:
WebdavFileSystem.init()

getResource

public WebdavResource getResource(String uri,
                                  WebdavContext ctxt)
Description copied from class: WebdavFileSystem
Lookup the resource represented by the given URI. The resource must be a relative URI to the path folders starting and ending by '/'. ie /my/path/resource.ext -> /my/path/resource.ext
ie /my/path/ -> /my/path/

Specified by:
getResource in class WebdavFileSystem
Parameters:
uri - the resource URI
ctxt - the Webdav Context
Returns:
WebdavResource the resource representing the given URI
See Also:
WebdavFileSystem.getResource(String, WebdavContext)

doCopy

public boolean doCopy(WebdavResource source,
                      WebdavResource target,
                      boolean overwrite,
                      boolean recursive,
                      WebdavContext ctxt)
Description copied from class: WebdavFileSystem
This method perform copy from one Webdav Resource to an Other

Overrides:
doCopy in class WebdavFileSystem
Parameters:
source - a Webdav Resource
target - a Webdav Resource
overwrite - a boolean indicate to overite or not the resource
recursive - is it a recursive copy
ctxt - the Webdav Context
Returns:
boolean true if the copy has been done otherwise false
See Also:
WebdavFileSystem.doCopy(WebdavResource, WebdavResource, boolean, boolean, WebdavContext)

doMove

public boolean doMove(WebdavResource source,
                      WebdavResource target,
                      boolean overwrite,
                      boolean recursive,
                      WebdavContext ctxt)
Description copied from class: WebdavFileSystem
This method perform move from one Webdav Resource to an Other

Overrides:
doMove in class WebdavFileSystem
Parameters:
source - a Webdav Resource
target - a Webdav Resource
overwrite - a boolean indicate to overite or not the resource
recursive - is it a recursive copy
ctxt - the Webdav Context
Returns:
boolean true if the move has been done otherwise false
See Also:
WebdavFileSystem.doMove(WebdavResource, WebdavResource, boolean, boolean, WebdavContext)

doCreate

public boolean doCreate(WebdavResource resource,
                        boolean overwrite,
                        boolean isFolder,
                        WebdavContext ctxt)
Description copied from class: WebdavFileSystem
This method perform create from one Webdav Resource

Specified by:
doCreate in class WebdavFileSystem
Parameters:
resource - the Webdav Resource
overwrite - a boolean indicate to ovewrite the resource
isFolder - create a File or a Folder
Returns:
boolean true if the create has been done otherwise false
See Also:
WebdavFileSystem.doCreate(WebdavResource, boolean, boolean, WebdavContext)

doDelete

public boolean doDelete(WebdavResource resource,
                        boolean recursive,
                        WebdavContext ctxt)
Description copied from class: WebdavFileSystem
This method perform delete from one Webdav Resource

Overrides:
doDelete in class WebdavFileSystem
Parameters:
resource - the Webdav Resource
recursive - is it a recursive delete
Returns:
boolean true if the delete has been done otherwise false
See Also:
WebdavFileSystem.doDelete(WebdavResource, boolean, WebdavContext)

isReadOnly

public boolean isReadOnly(WebdavContext ctxt)
Description copied from class: WebdavFileSystem
Check if the FileSystem is ReadOnly. Default implementation always return false

Overrides:
isReadOnly in class WebdavFileSystem
Parameters:
ctxt - the Webdav Context
Returns:
true if the FileSystem is Read Only

getDataFromUri

public Data getDataFromUri(String uri,
                           WebdavContext ctxt)
Retrieve the Data from the given URI Starting from the given root.

Parameters:
uri - the relative uri
ctxt - the Webdav Context
Returns:
Data the Data for the given URI

getDataFromName

public Data getDataFromName(String name,
                            Data parent,
                            boolean onlyFolders,
                            WebdavContext ctxt)
Return the Data represented by the given short uri

Parameters:
name - the short uri name
parent - the Parent Data
onlyFolders - if true only folders data are returned
ctxt - the Webdav Context
Returns:
Data the Data targeted by the given name

getNameFromData

public String getNameFromData(Data data,
                              WebdavContext ctxt)
This method return the short name of the given data (Category or FileDocument) for this implementation

Parameters:
data - the given Data
ctxt - the Webdav Context
Returns:
String the name of the Data

canReadData

public boolean canReadData(Data data,
                           boolean recursive,
                           WebdavContext ctxt)
Check if the data can be read given the current context

Parameters:
data - the given Data
recursive - check parent and children
ctxt - the Webdav Context
Returns:
true if resource can be read

canBeReadBy

public boolean canBeReadBy(Data data,
                           Member loggedMember)

isExisting

public boolean isExisting(Data data,
                          WebdavContext ctxt)
This method return true if the Data is existing

Parameters:
data - the given Data
ctxt - the Webdav Context
Returns:
boolean true if it exists

isFolder

public boolean isFolder(Data data,
                        WebdavContext ctxt)
This method return true if the Data is a Folder

Parameters:
data - the given Data
ctxt - the Webdav Context
Returns:
boolean true if it is a folder

isFile

public boolean isFile(Data data,
                      WebdavContext ctxt)
This method return true if the Data is a File

Parameters:
data - the given Data
ctxt - the Webdav Context
Returns:
boolean true if it is a file

getContentLength

public long getContentLength(Data data,
                             WebdavContext ctxt)
This method return the length of the ressource

Parameters:
data - the given Data
ctxt - the Webdav Context
Returns:
long the length of the resource

getContentType

public String getContentType(Data data,
                             WebdavContext ctxt)
This method return the content type of the ressource

Parameters:
data - the given Data
ctxt - the Webdav Context
Returns:
String the content type of the resource

getDataChildrenSet

public Collection<Data> getDataChildrenSet(Data parent,
                                           WebdavContext ctxt)

addFileDocument

public void addFileDocument(Set<Data> childrenSet,
                            Member loggedMember,
                            Workspace workspace,
                            Category category)

getWorkspaceFromURI

public Workspace getWorkspaceFromURI(String uri,
                                     WebdavContext ctxt)
This method return the Workspace bind to the given URI.

Parameters:
uri - the resource URI
ctxt - the WebdavContext
Returns:
Workspace

getResourceStream

public InputStream getResourceStream(Data data,
                                     WebdavContext ctxt)
                              throws IOException
This method return the resource input stream

Parameters:
data - the given Data
ctxt - the Webdav Context
Returns:
InputStream the InputStream content of the resource
Throws:
IOException

setResourceStream

public boolean setResourceStream(Data data,
                                 File tmp,
                                 WebdavContext ctxt)
                          throws FileNotFoundException
Update/Override the FileDocument

Parameters:
data - the given Data
tmp - the temporary downloaded file
ctxt - the Webdav Context
Returns:
boolean true if resource stream has been correctly set
Throws:
FileNotFoundException

silentFilterResource

protected boolean silentFilterResource(WebdavResource resource,
                                       WebdavContext ctxt)
Description copied from class: WebdavFileSystem
Return true if the resource should be silently ignored.

Overrides:
silentFilterResource in class WebdavFileSystem
Parameters:
resource - the WebdavResource
ctxt - the WebdavContext
Returns:
boolean true to ignore resource

createFolder

public boolean createFolder(WebdavResource res,
                            WebdavContext ctxt)
Create a given target folder

Parameters:
res - the Webdav Resource
ctxt - the Webdav Context
Returns:
true if folder has been created

createFile

public boolean createFile(WebdavResource res,
                          WebdavContext ctxt)
Create a resource child of a given folder with the given name If child already exists in JCMS then recaterize it

Parameters:
res - the Webdav Resource
ctxt - the Webdav Context
Returns:
true if file has been created

deleteFolder

public boolean deleteFolder(WebdavResource res,
                            WebdavContext ctxt)
Delete a given target folder

Parameters:
res - the Webdav Resource
ctxt - the Webdav Context
Returns:
true if flder has been deleted

deleteFile

public boolean deleteFile(WebdavResource res,
                          WebdavContext ctxt)
Delete a given target file

Parameters:
res - the Webdav Resource
ctxt - the WebdavContext
Returns:
true if flder has been deleted

renameFile

public boolean renameFile(WebdavResource src,
                          WebdavResource tgt,
                          WebdavContext ctxt)
Rename the given WebdavResource file to the given target resource

Parameters:
src - a Webdav Resource
tgt - a Webdav Resource
ctxt - a Webdav Context
Returns:
true if renaming is done

renameFolder

public boolean renameFolder(WebdavResource src,
                            WebdavResource tgt,
                            WebdavContext ctxt)
Rename the given WebdavResource folder to the given target resource

Parameters:
src - a Webdav Resource
tgt - a Webdav Resource
ctxt - a Webdav Context
Returns:
true if renaming is done

copyFolder

public boolean copyFolder(WebdavResource src,
                          WebdavResource tgt,
                          boolean overwrite,
                          boolean recursive,
                          WebdavContext ctxt)
Parameters:
src - Source Folder
tgt - Target Folder
overwrite - boolean to overwrite target
recursive - boolean to do a recursive move
ctxt - the Webdav Context
Returns:
true if move has been done

moveFolder

public boolean moveFolder(WebdavResource src,
                          WebdavResource tgt,
                          boolean overwrite,
                          boolean recursive,
                          WebdavContext ctxt)
This method will move a given source to target location If target folder already exists then: - Copy all children of the target under source - Then copy all children of source under target - Then remove source

Parameters:
src - Source Folder
tgt - Target Folder
overwrite - boolean to overwrite target
recursive - boolean to do a recursive move
ctxt - the Webdav Context
Returns:
true if move has been done

copyMoveFile

public boolean copyMoveFile(WebdavResource src,
                            WebdavResource tgt,
                            boolean move,
                            WebdavContext ctxt)
This method Copy/Move a resource to a given target location

Parameters:
src - the webdav source
tgt - the webdav target
move - the action to do
ctxt - the Webdav Context
Returns:
true if action has been done correctly

checkSetNewWorkspace

protected boolean checkSetNewWorkspace(Workspace oldWS,
                                       Workspace newWS,
                                       Set<Category> pubCatSet)

isReadable

public boolean isReadable(WebdavResource res,
                          boolean recursive,
                          WebdavContext ctxt)
Check if the resource is Readable

Parameters:
res - the Webdav Resource
recursive - recursive check
ctxt - the Webdav Context
Returns:
true if the WebdavResource is Writable

isWritable

public boolean isWritable(WebdavResource res,
                          boolean recursive,
                          boolean overwrite,
                          WebdavContext ctxt)
Check if the resource is Writable

Parameters:
res - the Webdav Resource
recursive - recursive check
overwrite - overwrite flag
ctxt - the Webdav Context
Returns:
true if the WebdavResource is Writable

newLock

public WebdavLock newLock(WebdavResource resource,
                          WebdavContext ctxt)
Description copied from class: WebdavFileSystem
This method will return a new WebdavLock implementation

Specified by:
newLock in class WebdavFileSystem
Parameters:
resource - the Webdav Resource
ctxt - the Webdav Context
Returns:
a new WebdavLock
See Also:
WebdavFileSystem.newLock(WebdavResource, WebdavContext)


Copyright © 2001-2010 Jalios SA. All Rights Reserved.