Package org.alfresco.repo.webdav
Class WebDAVMethod
java.lang.Object
org.alfresco.repo.webdav.WebDAVMethod
- Direct Known Subclasses:
DeleteMethod,GetMethod,HierarchicalMethod,LockMethod,MkcolMethod,OptionsMethod,PropFindMethod,PutMethod,UnlockMethod
Abstract base class for all the WebDAV method handling classes
- Author:
- gavinc
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classClass used for storing conditions which comes with "If" header of the request -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static org.apache.commons.logging.Logprotected LinkedList<WebDAVMethod.Condition>protected WebDAVHelperprotected intprotected jakarta.servlet.http.HttpServletRequestprotected Stringprotected jakarta.servlet.http.HttpServletResponseprotected NodeRefprotected Stringprotected String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected LockInfoChecks if write operation can be performed on node.protected LockInfoChecks if write operation can be performed on node.protected final org.dom4j.io.XMLWriterCreate an XML writer for the responsevoidexecute()Executes the method, wrapping the call toexecuteImpl()in an appropriate transaction and handling the error conditions.protected abstract voidAccess the content repository to satisfy the request and generates the appropriate WebDAV response.protected final voidflushXML(org.dom4j.io.XMLWriter writer) Flushes all XML written so far to the responseprotected voidgenerateLockDiscoveryXML(org.dom4j.io.XMLWriter xml, FileInfo lockNodeInfo, boolean emptyNamespace, String scope, String depth, String lToken, String owner, Date expiryDate) Generates the lock discovery XML responseprotected voidgenerateLockDiscoveryXML(org.dom4j.io.XMLWriter xml, FileInfo lockNodeInfo, LockInfo lockInfo) Generates the lock discovery XML responseprotected StringgenerateNamespaceDeclarations(HashMap<String, String> nameSpaces) Generates a list of namespace declarations for the responseprotected voidDoes nothing unless overridden - for reasons of backwards compatibility.protected final ActionServiceConvenience method to return the action serviceprotected final AuthenticationServiceConvenience method to return the authentication serviceprotected final ContentServiceConvenience method to return the content serviceprotected final Stringprotected final WebDAVHelperReturn the WebDAV protocol helperprotected final WebDAVLockServiceRetrieve the (WebDAV protocol-level) locking service.final intgetDepth()Return the property find depthprotected final FileFolderServiceprotected final MimetypeServiceConvenience method to return the mimetype serviceprotected final org.alfresco.service.namespace.NamespaceServiceConvenience method to return the namespace serviceprotected FileInfogetNodeForPath(NodeRef rootNodeRef, String path) Get the file info for the given pathsprotected LockInfogetNodeLockInfo(FileInfo nodeInfo) Returns node Lock token in consideration of WebDav lock depth.protected final NodeServiceConvenience method to return the node servicegetPath()Return the relative pathprotected final PermissionServiceConvenience method to return the permission serviceprotected DocumentRetrieves the request body as an XML documentprotected final NodeRefReturn the root nodeprotected final SearchServiceConvenience method to return the search serviceprotected final ServiceRegistryReturn the service registryprotected final Stringprotected StringGet the site ID (short-name) that the current request relates to.protected intDetermines status code for AccessDeniedException based on client's HTTP headers.protected StringGet the tenant domain for the current user and request.protected final TransactionServiceConvenience method to return the transaction serviceprotected StringgetURLForPath(jakarta.servlet.http.HttpServletRequest request, String path, boolean isFolder) * Returns a URL that could be used to access the given path.protected FileInfogetWorkingCopy(NodeRef nodeRef) Returns a working copy of node for current user.protected org.dom4j.io.OutputFormatReturns the format required for an XML response.protected booleanOverride and return true if the method is a query method only.protected voidParses "Depth" request headerprotected voidParses "If" header of the request.protected abstract voidParses the given request body represented as an XML document and sets any necessary context ready for execution.protected abstract voidParses the HTTP headers of the request and sets any necessary context ready for execution.voidsetDetails(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, WebDAVHelper davHelper, NodeRef rootNode) Set the request/response detailsprotected booleanDetermines whether the XMLWriter should be flushed when XML is flushed.toString()
-
Field Details
-
logger
protected static org.apache.commons.logging.Log logger -
m_request
protected jakarta.servlet.http.HttpServletRequest m_request -
m_response
protected jakarta.servlet.http.HttpServletResponse m_response -
m_davHelper
-
m_rootNodeRef
-
m_strPath
-
m_userAgent
-
m_conditions
-
m_resourceTag
-
m_depth
protected int m_depth -
m_childToParent
-
m_parentLockInfo
-
-
Constructor Details
-
WebDAVMethod
public WebDAVMethod()Default constructor
-
-
Method Details
-
setDetails
public void setDetails(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp, WebDAVHelper davHelper, NodeRef rootNode) Set the request/response details- Parameters:
req- HttpServletRequestresp- HttpServletResponsedavHelper- WebDAVHelperrootNode- 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
Executes the method, wrapping the call toexecuteImpl()in an appropriate transaction and handling the error conditions.- Throws:
WebDAVServerException
-
executeImpl
Access the content repository to satisfy the request and generates the appropriate WebDAV response.- Throws:
WebDAVServerException- a general server exceptionException- any unhandled exception
-
generateResponseImpl
Does nothing unless overridden - for reasons of backwards compatibility. Subclasses implementing this method should separate the WebDAV method execution logic from response generation logic. Execution logic should be contained in theexecuteImpl()method and should NOT contain any code that writes to the response. Conversely response generation logic should NOT contain any code relating to the desired effect of the WebDAV method (e.g. setting properties on a node) and should be contained purely within this method.Older methods, until refactored will not override this method, relying only on
executeImpl().- Throws:
Exception
-
parseRequestBody
Parses the given request body represented as an XML document and sets any necessary context ready for execution.- Throws:
WebDAVServerException
-
parseRequestHeaders
Parses the HTTP headers of the request and sets any necessary context ready for execution.- Throws:
WebDAVServerException
-
getRequestBodyAsDocument
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
Parses "Depth" request header- Throws:
WebDAVServerException
-
parseIfHeader
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
Return the WebDAV protocol helper- Returns:
- WebDAVHelper
-
getServiceRegistry
Return the service registry- Returns:
- ServiceRegistry
-
getTransactionService
Convenience method to return the transaction service- Returns:
- TransactionService
-
getNodeService
Convenience method to return the node service- Returns:
- NodeService
-
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
- Returns:
- Returns the general file/folder manipulation service
-
getContentService
Convenience method to return the content service- Returns:
- ContentService
-
getMimetypeService
Convenience method to return the mimetype service- Returns:
- MimetypeService
-
getDAVLockService
Retrieve the (WebDAV protocol-level) locking service.- Returns:
- WebDAVLockService
-
getActionService
Convenience method to return the action service- Returns:
- ActionService
-
getPermissionService
Convenience method to return the permission service- Returns:
- PermissionService
-
getAuthenticationService
Convenience method to return the authentication service- Returns:
- AuthenticationService
-
getServletPath
- Returns:
- Returns the path of the servlet, e.g. /webdav
-
getContextPath
- Returns:
- Returns the context path of the servlet, e.g. /alfresco
-
getRootNodeRef
Return the root node- Returns:
- NodeRef
-
getPath
Return the relative path- Returns:
- String
-
getXMLOutputFormat
protected org.dom4j.io.OutputFormat getXMLOutputFormat()Returns the format required for an XML response. This may vary per method. -
createXMLWriter
Create an XML writer for the response- Returns:
- XMLWriter
- Throws:
IOException
-
generateLockDiscoveryXML
protected void generateLockDiscoveryXML(org.dom4j.io.XMLWriter xml, FileInfo lockNodeInfo, LockInfo lockInfo) throws Exception Generates the lock discovery XML response- Parameters:
xml- XMLWriterlockNodeInfo- FileInfolockInfo- LockInfo- Throws:
Exception
-
generateLockDiscoveryXML
protected void generateLockDiscoveryXML(org.dom4j.io.XMLWriter xml, FileInfo lockNodeInfo, boolean emptyNamespace, String scope, String depth, String lToken, String owner, Date expiryDate) throws Exception Generates the lock discovery XML response- Parameters:
xml- XMLWriterlockNodeInfo- FileInfoemptyNamespace- boolean True if namespace should be empty. Used to avoid bugs in WebDAV clients.scope- String lock scopedepth- String lock depthlToken- String locktokenowner- String lock ownerexpiryDate- the date/time the lock should expire- Throws:
Exception
-
generateNamespaceDeclarations
Generates a list of namespace declarations for the response -
checkNode
protected LockInfo checkNode(FileInfo fileInfo, boolean ignoreShared, boolean lockMethod) throws WebDAVServerException Checks if write operation can be performed on node.- Parameters:
fileInfo- - node's file infoignoreShared- - if true ignores shared lockslockMethod- - 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
Checks if write operation can be performed on node.- Parameters:
fileInfo- FileInfo- Returns:
- LockInfo
- Throws:
WebDAVServerException- if node has shared or exclusive lock or If header preconditions failed
-
getNodeLockInfo
Returns node Lock token in consideration of WebDav lock depth.- Parameters:
nodeInfo- FileInfo- Returns:
- String Lock token
-
getNodeForPath
Get the file info for the given paths- Parameters:
rootNodeRef- the acting webdav rootpath- the path to search for- Returns:
- Return the file info for the path
- Throws:
FileNotFoundException- if the path doesn't refer to a valid node
-
getURLForPath
protected String getURLForPath(jakarta.servlet.http.HttpServletRequest request, String path, boolean isFolder) * Returns a URL that could be used to access the given path.- Parameters:
request- HttpServletRequestpath- the path to search forisFolder- indicates file or folder is requested- Returns:
- URL that could be used to access the given path
-
shouldFlushXMLWriter
protected boolean shouldFlushXMLWriter()Determines whether the XMLWriter should be flushed when XML is flushed. For some reason this is method specific.- Returns:
trueif the XMLWriter should be flushed when XML is flushed
-
flushXML
Flushes all XML written so far to the response- Parameters:
writer- XMLWriter that should be flushed- Throws:
IOException
-
getWorkingCopy
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
-
getSiteId
Get the site ID (short-name) that the current request relates to. The site ID will beDEFAULT_SITE_IDif not specifically set.- Returns:
- The site ID
-
getTenantDomain
Get the tenant domain for the current user and request. The tenant domain will beTenantService.DEFAULT_DOMAINif not specifically set.- Returns:
- The tenant domain.
-