com.jalios.jcms.webdav
Class WebdavResource

java.lang.Object
  extended by com.jalios.jcms.webdav.WebdavResource
All Implemented Interfaces:
Comparable<WebdavResource>
Direct Known Subclasses:
CatWebdavResource, FileWebdavResource

public abstract class WebdavResource
extends Object
implements Comparable<WebdavResource>

This class is an Abstract Representation of a Webdav Resource doing all webdav specific task or delegating to WebdavFileSystem. It must be overrided by sub level Content Management Implementation.

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

Field Summary
protected  boolean possibleFile
           
static String REVISION
           
protected  String uri
           
 
Constructor Summary
protected WebdavResource(String uri, WebdavContext ctxt)
          The resource must be a relative URI to the path folders starting and ending by '/'.
 
Method Summary
 boolean checkUnlockAccess(WebdavContext ctxt)
          Check unlock access for current context on this resource
 int compareTo(WebdavResource otherRes)
           
 boolean equals(Object obj)
           
abstract  Collection<WebdavResource> getChildren(WebdavContext ctxt)
          Return all the Children of the resource.
 String getContentLanguage(WebdavContext ctxt)
          This method will return the content language Default implementation return null
abstract  long getContentLength(WebdavContext ctxt)
          Return the size of the resource or 0 if there is no content
abstract  String getContentType(WebdavContext ctxt)
          This method have to return the Content Type of the resource with the Content Encoding ie "text/html; charset=UTF-8" It is the media type defined in section 3.7 of [RFC2068] If no content type then return ""
abstract  long getCreationDate(WebdavContext ctxt)
          Return long representing the Creation of the resource It contains a timestamp of the moment when the resource was created (i.e., the moment it had non-null state).
 Collection<WebdavLock> getDescendantLocks(WebdavContext ctxt)
          Convenient method that delegate call to the WebdavFileSystem
 String getETag(boolean strong, WebdavContext ctxt)
          Return a etag representation usefull not to be read-only with ms-word
 long getLastAccessed(WebdavContext ctxt)
          This method will return a long representing the last time this resource was accessed.
abstract  long getLastModified(WebdavContext ctxt)
          Return long representing the LastModified of the resource Note that the last-modified date on a resource may reflect changes in any part of the state of the resource, not necessarily just a change to the response to the GET method.
 Collection<WebdavLock> getLocks(WebdavContext ctxt)
          Convenient method that delegate call to the WebdavFileSystem
 String getName(WebdavContext ctxt)
          This method will return the name of the resource
ie /my/path/resource.ext -> resource.ext
ie /my/path/ -> path
 WebdavResource getParent(WebdavContext ctxt)
          This method will return the Parent WebdavResource of the resource.
 String getPath(WebdavContext ctxt)
          This method will return the path of the resource
ie /my/path/resource.ext -> /my/path/resource.ext
ie /my/path/ -> /my/path/
abstract  InputStream getResourceStream(WebdavContext ctxt)
          This method have to return an InputStream on the resource.
 boolean hasExclusiveLockAccess(WebdavContext ctxt)
          Check that current user has an exclusive lock access for current context on this resource
 boolean hasLockAccess(WebdavContext ctxt)
          Check lock access for current context on this resource
abstract  boolean isExisting(WebdavContext ctxt)
          Check if the resource exists in the UserFileSystem This method is abstract and must be implemented by the UserFileSystem.
 boolean isFile(WebdavContext ctxt)
          This method will check if the resource is a File or a Folder.
 boolean isFolder(WebdavContext ctxt)
          This method will check if the resource is a File or a Folder.
 boolean isHidden(WebdavContext ctxt)
          This method will return true if the resource isHidden.
 boolean isPossibleFile()
           
 boolean isReadable(boolean recursive, WebdavContext ctxt)
          This method will return true if the resource can be read by the context.
 boolean isWritable(boolean recursive, boolean overwrite, WebdavContext ctxt)
          This method will return true if the resource can be write by the context.
 WebdavLock putLock(WebdavLock lock, WebdavContext ctxt)
          Convenient method that delegate call to the WebdavFileSystem
 WebdavLock putLocks(WebdavLock lock, WebdavContext ctxt)
          Convenient method that delegate call to the WebdavFileSystem
 void setPath(String uri, WebdavContext ctxt)
           
 void setPossibleContent(boolean isFile)
          Used by creation method to define the content may be a File or a Folder.
abstract  boolean setResourceStream(InputStream in, WebdavContext ctxt)
          This method have to return an InputStream on the resource.
 String toString()
          Override the toString() method
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

uri

protected String uri

possibleFile

protected boolean possibleFile
Constructor Detail

WebdavResource

protected WebdavResource(String uri,
                         WebdavContext ctxt)
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/

Parameters:
uri - the resource uri
ctxt - the Webdav Context
See Also:
WebdavFileSystem.getResource(String, WebdavContext)
Method Detail

getLocks

public Collection<WebdavLock> getLocks(WebdavContext ctxt)
Convenient method that delegate call to the WebdavFileSystem

Parameters:
ctxt - the Webdav Context
Returns:
Collection of WebdavLock on this resource

getDescendantLocks

public Collection<WebdavLock> getDescendantLocks(WebdavContext ctxt)
Convenient method that delegate call to the WebdavFileSystem

Parameters:
ctxt - the Webdav Context
Returns:
Collection of WebdavLock on this resource

putLock

public WebdavLock putLock(WebdavLock lock,
                          WebdavContext ctxt)
Convenient method that delegate call to the WebdavFileSystem

Parameters:
lock - the Webdav Lock
ctxt - the Webdav Context
Returns:
Collection of WebdavLock on this resource

putLocks

public WebdavLock putLocks(WebdavLock lock,
                           WebdavContext ctxt)
Convenient method that delegate call to the WebdavFileSystem

Parameters:
lock - the Webdav Lock
ctxt - the Webdav Context
Returns:
Collection of WebdavLock on this resource

hasExclusiveLockAccess

public boolean hasExclusiveLockAccess(WebdavContext ctxt)
Check that current user has an exclusive lock access for current context on this resource

Parameters:
ctxt - the WebdavContext
Returns:
true if operation is allowed to continue, false if a LOCK exists and user has not specified this locktoken
Since:
jcms-6.1

hasLockAccess

public boolean hasLockAccess(WebdavContext ctxt)
Check lock access for current context on this resource

Parameters:
ctxt - the WebdavContext
Returns:
true if operation is allowed to continue, false if a LOCK exists and user has not specified this locktoken
Since:
jcms-6.1

checkUnlockAccess

public boolean checkUnlockAccess(WebdavContext ctxt)
Check unlock access for current context on this resource

Parameters:
ctxt - the WebdavContext
Returns:
true if operation is allowed to continue, false if a LOCK
Since:
jcms-6.1

getETag

public String getETag(boolean strong,
                      WebdavContext ctxt)
Return a etag representation usefull not to be read-only with ms-word

Parameters:
strong - indicate the way to get the etag
ctxt - the Webdav Context
Returns:
String the etag

getName

public String getName(WebdavContext ctxt)
This method will return the name of the resource
ie /my/path/resource.ext -> resource.ext
ie /my/path/ -> path

Parameters:
ctxt - the Webdav Context
Returns:
String the Short Name

getPath

public String getPath(WebdavContext ctxt)
This method will return the path of the resource
ie /my/path/resource.ext -> /my/path/resource.ext
ie /my/path/ -> /my/path/

Parameters:
ctxt - the Webdav Context
Returns:
String the Full Name

setPath

public void setPath(String uri,
                    WebdavContext ctxt)

toString

public String toString()
Override the toString() method

Overrides:
toString in class Object
Returns:
String the value of the uri

setPossibleContent

public void setPossibleContent(boolean isFile)
Used by creation method to define the content may be a File or a Folder.

Parameters:
isFile - Content may be a file

isPossibleFile

public boolean isPossibleFile()

isFolder

public boolean isFolder(WebdavContext ctxt)
This method will check if the resource is a File or a Folder. Default implementation return !isFile()

Parameters:
ctxt - the Webdav Context
Returns:
true if the resource is a Folder (ie Collection)

isFile

public boolean isFile(WebdavContext ctxt)
This method will check if the resource is a File or a Folder. Default implementation assume a File is a Collection without children.

Parameters:
ctxt - the Webdav Context
Returns:
true if the resource is a File (ie Collection without children)

getParent

public WebdavResource getParent(WebdavContext ctxt)
This method will return the Parent WebdavResource of the resource. Default implementation will call WebdavFileSystem.getResource() with the parent path.

Parameters:
ctxt - the Webdav Context
Returns:
WebdavResource the parent Webdav Resource or null if none

isReadable

public boolean isReadable(boolean recursive,
                          WebdavContext ctxt)
This method will return true if the resource can be read by the context. Default implementation always return true to avoid security purpose.

Parameters:
recursive - Check if children are also readable
ctxt - the Webdav Context
Returns:
true if the resource can be read

isWritable

public boolean isWritable(boolean recursive,
                          boolean overwrite,
                          WebdavContext ctxt)
This method will return true if the resource can be write by the context. Default implementation always return true to avoid security purpose. Warning! Write also mean update or delete.

Parameters:
recursive - Check if children are also writable
overwrite - Inform that resources will be overwrited if exists
ctxt - the Webdav Context
Returns:
true if the resource can be write

isHidden

public boolean isHidden(WebdavContext ctxt)
This method will return true if the resource isHidden. Default implementation always return false to ignore this behavior. Warning! Hidden doesn't mean not readable but only hide from default user interface.

Parameters:
ctxt - the Webdav Context
Returns:
true if the resource is hidden

getLastAccessed

public long getLastAccessed(WebdavContext ctxt)
This method will return a long representing the last time this resource was accessed. If the implementation doesn't have ths information then return -1. Check for lastrefresh locks then check for last modified resource then return -1.

Parameters:
ctxt - the Webdav Context
Returns:
long the last resource access time

getContentLanguage

public String getContentLanguage(WebdavContext ctxt)
This method will return the content language Default implementation return null

Parameters:
ctxt - the Webdav Context
Returns:
String custom implenation or null

getChildren

public abstract Collection<WebdavResource> getChildren(WebdavContext ctxt)
Return all the Children of the resource. This method is abstract and must be implemented by the UserFileSystem.

Parameters:
ctxt - the Webdav Context
Returns:
Collection a Collection of WebdavResource

isExisting

public abstract boolean isExisting(WebdavContext ctxt)
Check if the resource exists in the UserFileSystem This method is abstract and must be implemented by the UserFileSystem.

Parameters:
ctxt - the Webdav Context
Returns:
true if the resource exists

getContentLength

public abstract long getContentLength(WebdavContext ctxt)
Return the size of the resource or 0 if there is no content

Parameters:
ctxt - the Webdav Context
Returns:
long the size of the file or 0 if it is a folder

getCreationDate

public abstract long getCreationDate(WebdavContext ctxt)
Return long representing the Creation of the resource It contains a timestamp of the moment when the resource was created (i.e., the moment it had non-null state).

Parameters:
ctxt - the Webdav Context
Returns:
long the LastModified of the resource

getLastModified

public abstract long getLastModified(WebdavContext ctxt)
Return long representing the LastModified of the resource Note that the last-modified date on a resource may reflect changes in any part of the state of the resource, not necessarily just a change to the response to the GET method. For example, a change in a property may cause the last-modified date to change.

Parameters:
ctxt - the Webdav Context
Returns:
long the LastModified of the resource

getResourceStream

public abstract InputStream getResourceStream(WebdavContext ctxt)
                                       throws IOException
This method have to return an InputStream on the resource. The Stream will be Buffered and Closed by the caller.

Parameters:
ctxt - the Webdav Context
Returns:
InputStream an open stream to the resource
Throws:
IOException

setResourceStream

public abstract boolean setResourceStream(InputStream in,
                                          WebdavContext ctxt)
                                   throws IOException
This method have to return an InputStream on the resource. The Stream will be Buffered and Closed by the caller. But this method may close the Stream.

Parameters:
in - the Request InputStream
ctxt - the Webdav Context
Returns:
boolean if the set has been correctly done
Throws:
IOException

getContentType

public abstract String getContentType(WebdavContext ctxt)
This method have to return the Content Type of the resource with the Content Encoding ie "text/html; charset=UTF-8" It is the media type defined in section 3.7 of [RFC2068] If no content type then return ""

Parameters:
ctxt - the Webdav Context
Returns:
String a String that describe the resource ContentType or "application/octet-stream"

compareTo

public int compareTo(WebdavResource otherRes)
Specified by:
compareTo in interface Comparable<WebdavResource>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


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