Package com.jalios.jcms.webdav
Class WebdavResource
- java.lang.Object
-
- com.jalios.jcms.webdav.WebdavResource
-
- All Implemented Interfaces:
java.lang.Comparable<WebdavResource>
- Direct Known Subclasses:
CatWebdavResource
,FileWebdavResource
public abstract class WebdavResource extends java.lang.Object implements java.lang.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
- Author:
- Jean-Philippe Encausse
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
possibleFile
protected java.lang.String
uri
-
Constructor Summary
Constructors Modifier Constructor Description protected
WebdavResource(java.lang.String uri, WebdavContext ctxt)
The resource must be a relative URI to the path folders starting and ending by '/'.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
checkUnlockAccess(WebdavContext ctxt)
Check unlock access for current context on this resourceint
compareTo(WebdavResource otherRes)
boolean
equals(java.lang.Object obj)
abstract java.util.Collection<WebdavResource>
getChildren(WebdavContext ctxt)
Return all the Children of the resource.java.lang.String
getContentLanguage(WebdavContext ctxt)
This method will return the content language Default implementation return nullabstract long
getContentLength(WebdavContext ctxt)
Return the size of the resource or 0 if there is no contentabstract java.lang.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).java.util.Collection<WebdavLock>
getDescendantLocks(WebdavContext ctxt)
Convenient method that delegate call to the WebdavFileSystemjava.lang.String
getETag(boolean strong, WebdavContext ctxt)
Return a etag representation usefull not to be read-only with ms-wordlong
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.java.util.Collection<WebdavLock>
getLocks(WebdavContext ctxt)
Convenient method that delegate call to the WebdavFileSystemjava.lang.String
getName(WebdavContext ctxt)
This method will return the name of the resource
ie /my/path/resource.ext -> resource.ext
ie /my/path/ -> pathWebdavResource
getParent(WebdavContext ctxt)
This method will return the Parent WebdavResource of the resource.java.lang.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 java.io.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 resourceboolean
hasLockAccess(WebdavContext ctxt)
Check lock access for current context on this resourceabstract 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 WebdavFileSystemWebdavLock
putLocks(WebdavLock lock, WebdavContext ctxt)
Convenient method that delegate call to the WebdavFileSystemvoid
setPath(java.lang.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(java.io.InputStream in, WebdavContext ctxt)
This method have to return an InputStream on the resource.java.lang.String
toString()
Override the toString() method
-
-
-
Constructor Detail
-
WebdavResource
protected WebdavResource(java.lang.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 urictxt
- the Webdav Context- See Also:
WebdavFileSystem.getResource(String, WebdavContext)
-
-
Method Detail
-
getLocks
public java.util.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 java.util.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 Lockctxt
- 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 Lockctxt
- 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 java.lang.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 etagctxt
- the Webdav Context- Returns:
- String the etag
-
getName
public java.lang.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 java.lang.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(java.lang.String uri, WebdavContext ctxt)
-
toString
public java.lang.String toString()
Override the toString() method- Overrides:
toString
in classjava.lang.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 readablectxt
- 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 writableoverwrite
- Inform that resources will be overwrited if existsctxt
- 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 java.lang.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 java.util.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 java.io.InputStream getResourceStream(WebdavContext ctxt) throws java.io.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:
java.io.IOException
-
setResourceStream
public abstract boolean setResourceStream(java.io.InputStream in, WebdavContext ctxt) throws java.io.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 InputStreamctxt
- the Webdav Context- Returns:
- boolean if the set has been correctly done
- Throws:
java.io.IOException
-
getContentType
public abstract java.lang.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 interfacejava.lang.Comparable<WebdavResource>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-