org.alfresco.repo.webdav
Class WebDAVMethod

java.lang.Object
  extended by org.alfresco.repo.webdav.WebDAVMethod
Direct Known Subclasses:
DeleteMethod, GetMethod, HierarchicalMethod, LockMethod, MkcolMethod, OptionsMethod, PropFindMethod, PutMethod, UnlockMethod

public abstract class WebDAVMethod
extends java.lang.Object

Abstract base class for all the WebDAV method handling classes


Nested Class Summary
protected  class WebDAVMethod.Condition
          Class used for storing conditions which comes with "If" header of the request
 
Field Summary
protected static org.apache.commons.logging.Log logger
           
protected  java.util.Map m_childToParent
           
protected  java.util.LinkedList m_conditions
           
protected  WebDAVHelper m_davHelper
           
protected  int m_depth
           
protected  java.util.Map m_parentLockInfo
           
protected  javax.servlet.http.HttpServletRequest m_request
           
protected  java.lang.String m_resourceTag
           
protected  javax.servlet.http.HttpServletResponse m_response
           
protected  org.alfresco.service.cmr.repository.NodeRef m_rootNodeRef
           
protected  java.lang.String m_strPath
           
protected  java.lang.String m_userAgent
           
 
Constructor Summary
WebDAVMethod()
          Default constructor
 
Method Summary
protected  LockInfo checkNode(org.alfresco.service.cmr.model.FileInfo fileInfo)
          Checks if write operation can be performed on node.
protected  LockInfo checkNode(org.alfresco.service.cmr.model.FileInfo fileInfo, boolean ignoreShared, boolean lockMethod)
          Checks if write operation can be performed on node.
protected  org.dom4j.io.XMLWriter createXMLWriter()
          Create an XML writer for the response
 void execute()
          Executes the method, wrapping the call to WebDAVMethod.executeImpl() in an appropriate transaction and handling the error conditions.
protected abstract  void executeImpl()
          Access the content repository to satisfy the request and generates the appropriate WebDAV response.
protected  void flushXML(org.dom4j.io.XMLWriter xml)
          Flushs a XML Writer.
protected  void generateLockDiscoveryXML(org.dom4j.io.XMLWriter xml, org.alfresco.service.cmr.model.FileInfo lockNodeInfo, boolean emptyNamespace, java.lang.String scope, java.lang.String depth, java.lang.String lToken, java.lang.String owner)
          Generates the lock discovery XML response
protected  void generateLockDiscoveryXML(org.dom4j.io.XMLWriter xml, org.alfresco.service.cmr.model.FileInfo lockNodeInfo, LockInfo lockInfo)
          Generates the lock discovery XML response
protected  java.lang.String generateNamespaceDeclarations(java.util.HashMap nameSpaces)
          Generates a list of namespace declarations for the response
protected  org.alfresco.service.cmr.action.ActionService getActionService()
          Convenience method to return the action service
protected  org.alfresco.service.cmr.security.AuthenticationService getAuthenticationService()
          Convenience method to return the authentication service
protected  org.alfresco.service.cmr.repository.ContentService getContentService()
          Convenience method to return the content service
protected  WebDAVHelper getDAVHelper()
          Return the WebDAV protocol helper
 int getDepth()
          Return the property find depth
protected  org.alfresco.service.cmr.model.FileFolderService getFileFolderService()
           
protected  org.alfresco.service.cmr.lock.LockService getLockService()
          Convenience method to return the lock service
protected  org.alfresco.service.cmr.repository.MimetypeService getMimetypeService()
          Convenience method to return the mimetype service
protected  org.alfresco.service.namespace.NamespaceService getNamespaceService()
          Convenience method to return the namespace service
protected  org.alfresco.service.cmr.model.FileInfo getNodeForPath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path, java.lang.String servletPath)
          Get the file info for the given paths
protected  LockInfo getNodeLockInfo(org.alfresco.service.cmr.model.FileInfo nodeInfo)
          Returns node Lock token in consideration of WebDav lock depth.
protected  org.alfresco.service.cmr.repository.NodeService getNodeService()
          Convenience method to return the node service
protected  java.lang.String getPath()
          Return the relative path
protected  org.alfresco.service.cmr.security.PermissionService getPermissionService()
          Convenience method to return the permission service
protected  org.w3c.dom.Document getRequestBodyAsDocument()
          Retrieves the request body as an XML document
protected  org.alfresco.service.cmr.repository.NodeRef getRootNodeRef()
          Return the root node
protected  org.alfresco.service.cmr.search.SearchService getSearchService()
          Convenience method to return the search service
protected  org.alfresco.service.ServiceRegistry getServiceRegistry()
          Return the service registry
protected  java.lang.String getServletPath()
           
protected  int getStatusForAccessDeniedException()
          Determines status code for AccessDeniedException based on client's HTTP headers.
protected  org.alfresco.service.transaction.TransactionService getTransactionService()
          Convenience method to return the transaction service
protected  java.lang.String getURLForPath(javax.servlet.http.HttpServletRequest request, java.lang.String path, boolean isFolder)
          Returns a URL that could be used to access the given path.
protected  org.alfresco.service.cmr.model.FileInfo getWorkingCopy(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Returns a working copy of node for current user.
protected  boolean isReadOnly()
          Override and return true if the method is a query method only.
protected  void parseDepthHeader()
          Parses "Depth" request header
protected  void parseIfHeader()
          Parses "If" header of the request.
protected abstract  void parseRequestBody()
          Parses the given request body represented as an XML document and sets any necessary context ready for execution.
protected abstract  void parseRequestHeaders()
          Parses the HTTP headers of the request and sets any necessary context ready for execution.
 void setDetails(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, WebDAVHelper davHelper, org.alfresco.service.cmr.repository.NodeRef rootNode)
          Set the request/response details
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static org.apache.commons.logging.Log logger

m_request

protected javax.servlet.http.HttpServletRequest m_request

m_response

protected javax.servlet.http.HttpServletResponse m_response

m_davHelper

protected WebDAVHelper m_davHelper

m_rootNodeRef

protected org.alfresco.service.cmr.repository.NodeRef m_rootNodeRef

m_strPath

protected java.lang.String m_strPath

m_userAgent

protected java.lang.String m_userAgent

m_conditions

protected java.util.LinkedList m_conditions

m_resourceTag

protected java.lang.String m_resourceTag

m_depth

protected int m_depth

m_childToParent

protected java.util.Map m_childToParent

m_parentLockInfo

protected java.util.Map m_parentLockInfo
Constructor Detail

WebDAVMethod

public WebDAVMethod()
Default constructor

Method Detail

setDetails

public void setDetails(javax.servlet.http.HttpServletRequest req,
                       javax.servlet.http.HttpServletResponse resp,
                       WebDAVHelper davHelper,
                       org.alfresco.service.cmr.repository.NodeRef rootNode)
Set the request/response details

Parameters:
req - HttpServletRequest
resp - HttpServletResponse
registry - ServiceRegistry
rootNode - NodeRef

isReadOnly

protected boolean isReadOnly()
Override and return true if the method is a query method only. The default implementation returns false.

Returns:
Returns true if the method transaction may be read-only

getDepth

public final int getDepth()
Return the property find depth

Returns:
int

execute

public void execute()
             throws WebDAVServerException
Executes the method, wrapping the call to WebDAVMethod.executeImpl() in an appropriate transaction and handling the error conditions.

Throws:
WebDAVServerException

executeImpl

protected abstract void executeImpl()
                             throws WebDAVServerException,
                                    java.lang.Exception
Access the content repository to satisfy the request and generates the appropriate WebDAV response.

Throws:
WebDAVServerException - a general server exception
java.lang.Exception - any unhandled exception

parseRequestBody

protected abstract void parseRequestBody()
                                  throws WebDAVServerException
Parses the given request body represented as an XML document and sets any necessary context ready for execution.

Throws:
WebDAVServerException

parseRequestHeaders

protected abstract void parseRequestHeaders()
                                     throws WebDAVServerException
Parses the HTTP headers of the request and sets any necessary context ready for execution.

Throws:
WebDAVServerException

getRequestBodyAsDocument

protected org.w3c.dom.Document getRequestBodyAsDocument()
                                                 throws WebDAVServerException
Retrieves the request body as an XML document

Returns:
The body of the request as an XML document or null if there isn't a body
Throws:
WebDAVServerException

parseDepthHeader

protected void parseDepthHeader()
                         throws WebDAVServerException
Parses "Depth" request header

Throws:
WebDAVServerException

parseIfHeader

protected void parseIfHeader()
                      throws WebDAVServerException
Parses "If" header of the request. Stores conditions that should be checked. Parses both No-tag-list and Tagged-list formats See "10.4.2 Syntax" paragraph of the WebDAV specification for "If" header format.

Throws:
WebDAVServerException

getDAVHelper

protected final WebDAVHelper getDAVHelper()
Return the WebDAV protocol helper

Returns:
WebDAVHelper

getServiceRegistry

protected final org.alfresco.service.ServiceRegistry getServiceRegistry()
Return the service registry

Returns:
ServiceRegistry

getTransactionService

protected final org.alfresco.service.transaction.TransactionService getTransactionService()
Convenience method to return the transaction service

Returns:
TransactionService

getNodeService

protected final org.alfresco.service.cmr.repository.NodeService getNodeService()
Convenience method to return the node service

Returns:
NodeService

getSearchService

protected final org.alfresco.service.cmr.search.SearchService getSearchService()
Convenience method to return the search service

Returns:
SearchService

getNamespaceService

protected final org.alfresco.service.namespace.NamespaceService getNamespaceService()
Convenience method to return the namespace service

Returns:
NamespaceService

getFileFolderService

protected final org.alfresco.service.cmr.model.FileFolderService getFileFolderService()
Returns:
Returns the general file/folder manipulation service

getContentService

protected final org.alfresco.service.cmr.repository.ContentService getContentService()
Convenience method to return the content service

Returns:
ContentService

getMimetypeService

protected final org.alfresco.service.cmr.repository.MimetypeService getMimetypeService()
Convenience method to return the mimetype service

Returns:
MimetypeService

getLockService

protected final org.alfresco.service.cmr.lock.LockService getLockService()
Convenience method to return the lock service

Returns:
LockService

getActionService

protected final org.alfresco.service.cmr.action.ActionService getActionService()
Convenience method to return the action service

Returns:
ActionService

getPermissionService

protected final org.alfresco.service.cmr.security.PermissionService getPermissionService()
Convenience method to return the permission service

Returns:
PermissionService

getAuthenticationService

protected final org.alfresco.service.cmr.security.AuthenticationService getAuthenticationService()
Convenience method to return the authentication service

Returns:
AuthenticationService

getServletPath

protected final java.lang.String getServletPath()
Returns:
Returns the path of the servlet

getRootNodeRef

protected final org.alfresco.service.cmr.repository.NodeRef getRootNodeRef()
Return the root node

Returns:
NodeRef

getPath

protected java.lang.String getPath()
Return the relative path

Returns:
String

createXMLWriter

protected org.dom4j.io.XMLWriter createXMLWriter()
                                          throws java.io.IOException
Create an XML writer for the response

Returns:
XMLWriter
Throws:
java.io.IOException

generateLockDiscoveryXML

protected void generateLockDiscoveryXML(org.dom4j.io.XMLWriter xml,
                                        org.alfresco.service.cmr.model.FileInfo lockNodeInfo,
                                        LockInfo lockInfo)
                                 throws java.lang.Exception
Generates the lock discovery XML response

Parameters:
xml - XMLWriter
lockNode - NodeRef
Throws:
java.lang.Exception

generateLockDiscoveryXML

protected void generateLockDiscoveryXML(org.dom4j.io.XMLWriter xml,
                                        org.alfresco.service.cmr.model.FileInfo lockNodeInfo,
                                        boolean emptyNamespace,
                                        java.lang.String scope,
                                        java.lang.String depth,
                                        java.lang.String lToken,
                                        java.lang.String owner)
                                 throws java.lang.Exception
Generates the lock discovery XML response

Parameters:
xml - XMLWriter
lockNode - NodeRef
emptyNamespace - boolean True if namespace should be empty. Used to avoid bugs in WebDAV clients.
scope - String lock scope
depth - String lock depth
lToken - String locktoken
owner - String lock owner
Throws:
java.lang.Exception

generateNamespaceDeclarations

protected java.lang.String generateNamespaceDeclarations(java.util.HashMap nameSpaces)
Generates a list of namespace declarations for the response


checkNode

protected LockInfo checkNode(org.alfresco.service.cmr.model.FileInfo fileInfo,
                             boolean ignoreShared,
                             boolean lockMethod)
                      throws WebDAVServerException
Checks if write operation can be performed on node.

Parameters:
fileInfo - - node's file info
ignoreShared - - if true ignores shared locks
lockMethod - - must be true if used from lock method
Returns:
node's lock info
Throws:
WebDAVServerException - if node has shared or exclusive lock or If header preconditions failed

checkNode

protected LockInfo checkNode(org.alfresco.service.cmr.model.FileInfo fileInfo)
                      throws WebDAVServerException
Checks if write operation can be performed on node.

Parameters:
fileInfo -
Returns:
Throws:
WebDAVServerException - if node has shared or exclusive lock or If header preconditions failed

getNodeLockInfo

protected LockInfo getNodeLockInfo(org.alfresco.service.cmr.model.FileInfo nodeInfo)
Returns node Lock token in consideration of WebDav lock depth.

Parameters:
fileInfo - node
Returns:
String Lock token

getNodeForPath

protected org.alfresco.service.cmr.model.FileInfo getNodeForPath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef,
                                                                 java.lang.String path,
                                                                 java.lang.String servletPath)
                                                          throws org.alfresco.service.cmr.model.FileNotFoundException
Get the file info for the given paths

Parameters:
rootNodeRef - the acting webdav root
path - the path to search for
servletPath - the base servlet path, which may be null or empty
Returns:
Return the file info for the path
Throws:
org.alfresco.service.cmr.model.FileNotFoundException - if the path doesn't refer to a valid node

getURLForPath

protected java.lang.String getURLForPath(javax.servlet.http.HttpServletRequest request,
                                         java.lang.String path,
                                         boolean isFolder)
Returns a URL that could be used to access the given path.

Parameters:
request - HttpServletRequest
path - the path to search for
isFolder - indicates file or folder is requested
Returns:
URL that could be used to access the given path

flushXML

protected void flushXML(org.dom4j.io.XMLWriter xml)
                 throws java.io.IOException
Flushs a XML Writer.

Parameters:
xml - XMLWriter that should be flushed
Throws:
java.io.IOException

getWorkingCopy

protected org.alfresco.service.cmr.model.FileInfo getWorkingCopy(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Returns a working copy of node for current user.

Parameters:
nodeRef - node reference
Returns:
Returns the working copy's file information

getStatusForAccessDeniedException

protected int getStatusForAccessDeniedException()
Determines status code for AccessDeniedException based on client's HTTP headers.

Returns:
Returns status code

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.