Package org.alfresco.repo.webdav
Class WebDAVHelper
- java.lang.Object
-
- org.alfresco.repo.webdav.WebDAVHelper
-
public class WebDAVHelper extends java.lang.Object
WebDAV Protocol Helper ClassProvides helper methods for repository access using the WebDAV protocol.
- Author:
- GKSpencer
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BEAN_NAME
static java.lang.String
EMPTY_SITE_ID
protected static org.apache.commons.logging.Log
logger
static java.lang.String
PathSeperator
static char
PathSeperatorChar
-
Constructor Summary
Constructors Constructor Description WebDAVHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
checkDestinationURL(javax.servlet.http.HttpServletRequest request, java.lang.String urlStr)
Check that the destination path is on this server and is a valid WebDAV path for this serverorg.alfresco.service.cmr.model.FileInfo
createFile(org.alfresco.service.cmr.model.FileInfo parentNodeInfo, java.lang.String path)
static java.lang.String
decodeURL(java.lang.String s)
java.lang.String
determineSiteId(WebDAVMethod method)
java.lang.String
determineSiteId(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path)
java.lang.String
determineTenantDomain()
java.lang.String
determineTenantDomain(WebDAVMethod method)
Deprecated.static java.lang.String
encodeHTML(java.lang.String string)
Encodes the given string to valid HTML formatstatic java.lang.String
encodeURL(java.lang.String s)
Encodes the given string to valid URL formatstatic java.lang.String
encodeURL(java.lang.String s, java.lang.String userAgent)
static java.lang.String
encodeUrlReservedSymbols(java.lang.String string)
ALF-5333: Microsoft clients use ISO-8859-1 to decode WebDAV responses so this method should only be used for Microsoft user agents.org.alfresco.service.cmr.action.ActionService
getActionService()
org.alfresco.service.cmr.security.AuthenticationService
getAuthenticationService()
java.util.List<org.alfresco.service.cmr.model.FileInfo>
getChildren(org.alfresco.service.cmr.model.FileInfo fileInfo)
org.alfresco.service.cmr.repository.CopyService
getCopyService()
java.lang.String
getDestinationPath(java.lang.String contextPath, java.lang.String servletPath, java.lang.String destURL)
Extract the destination path for MOVE or COPY commands from the supplied destination URL header.org.alfresco.service.cmr.dictionary.DictionaryService
getDictionaryService()
org.alfresco.service.cmr.model.FileFolderService
getFileFolderService()
org.alfresco.repo.model.filefolder.HiddenAspect
getHiddenAspect()
WebDAVLockService
getLockService()
org.alfresco.service.cmr.repository.MimetypeService
getMimetypeService()
org.alfresco.service.namespace.NamespaceService
getNamespaceService()
org.alfresco.service.cmr.model.FileInfo
getNodeForPath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path)
Get the file info for the given pathsorg.alfresco.service.cmr.repository.NodeService
getNodeService()
org.xml.sax.helpers.AttributesImpl
getNullAttributes()
org.alfresco.service.cmr.model.FileInfo
getParentNodeForPath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path)
java.lang.String
getPathFromNode(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, org.alfresco.service.cmr.repository.NodeRef nodeRef)
Return the relative path for the node walking back to the specified root nodeorg.alfresco.service.cmr.security.PermissionService
getPermissionService()
org.alfresco.repo.policy.BehaviourFilter
getPolicyBehaviourFilter()
java.lang.String
getRepositoryPath(javax.servlet.http.HttpServletRequest request)
org.alfresco.service.cmr.search.SearchService
getSearchService()
org.alfresco.service.ServiceRegistry
getServiceRegistry()
long
getSizeLimit()
org.alfresco.repo.tenant.TenantService
getTenantService()
Retrieve theTenantService
held by the helper.java.lang.String
getURLForPath(javax.servlet.http.HttpServletRequest request, java.lang.String path, boolean isCollection)
java.lang.String
getURLForPath(javax.servlet.http.HttpServletRequest request, java.lang.String path, boolean isCollection, java.lang.String userAgent)
java.lang.String
getUrlPathPrefix(javax.servlet.http.HttpServletRequest request)
boolean
isLockedAndReadOnly(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Indicates if the node is unlocked or the current user has a WRITE_LOCKboolean
isRenameShuffle(java.lang.String newPath)
Checks a new path in a move operation to detect whether clients are starting a renaming shuffle - common during file saving on various clients.boolean
isRootPath(java.lang.String path, java.lang.String servletPath)
java.lang.String
makeETag(org.alfresco.service.cmr.model.FileInfo nodeInfo)
Make an ETag value for a node using the GUID and modify date/timeprotected void
makeETagString(org.alfresco.service.cmr.model.FileInfo nodeInfo, java.lang.StringBuilder etag)
Make an ETag value for a node using the GUID and modify date/timejava.lang.String
makeQuotedETag(org.alfresco.service.cmr.model.FileInfo nodeInfo)
Make an ETag value for a node using the GUID and modify date/timeprotected void
publishReadEvent(org.alfresco.service.cmr.model.FileInfo realNodeInfo, java.lang.String mimetype, java.lang.Long size, java.lang.String contentEncoding, java.lang.String range)
Notifies listeners that a read has taken placevoid
setActionService(org.alfresco.service.cmr.action.ActionService actionService)
void
setAuthenticationService(org.alfresco.service.cmr.security.AuthenticationService authService)
void
setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
void
setEventPublisher(org.alfresco.repo.events.EventPublisher eventPublisher)
void
setFileFolderService(org.alfresco.service.cmr.model.FileFolderService fileFolderService)
void
setHiddenAspect(org.alfresco.repo.model.filefolder.HiddenAspect hiddenAspect)
void
setLockService(WebDAVLockService lockService)
void
setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
void
setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
void
setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
void
setPermissionService(org.alfresco.service.cmr.security.PermissionService permissionService)
void
setPolicyBehaviourFilter(org.alfresco.repo.policy.BehaviourFilter behaviourFilter)
void
setPoster(org.alfresco.service.cmr.activities.ActivityPoster poster)
void
setRenameShufflePattern(java.util.regex.Pattern renameShufflePattern)
Set the regular expression that will be applied to filenames during renames to detect whether clients are performing a renaming shuffle - common during file saving on various clients.void
setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
void
setServiceRegistry(org.alfresco.service.ServiceRegistry serviceRegistry)
void
setSizeLimitString(java.lang.String limit)
This method sets a value for the limit.void
setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
void
setUrlPathPrefix(java.lang.String urlPathPrefix)
java.util.List<java.lang.String>
splitAllPaths(java.lang.String path)
Split the path into all the component directories and filenamejava.lang.String[]
splitPath(java.lang.String path)
Split the path into seperate directory path and file name strings.
-
-
-
Field Detail
-
BEAN_NAME
public static final java.lang.String BEAN_NAME
- See Also:
- Constant Field Values
-
PathSeperator
public static final java.lang.String PathSeperator
- See Also:
- Constant Field Values
-
PathSeperatorChar
public static final char PathSeperatorChar
- See Also:
- Constant Field Values
-
EMPTY_SITE_ID
public static final java.lang.String EMPTY_SITE_ID
- See Also:
- Constant Field Values
-
logger
protected static org.apache.commons.logging.Log logger
-
-
Method Detail
-
setSizeLimitString
public void setSizeLimitString(java.lang.String limit)
This method sets a value for the limit. If the string does notparse
to a java long.- Parameters:
limit
- a String representing a valid Java long.
-
setRenameShufflePattern
public void setRenameShufflePattern(java.util.regex.Pattern renameShufflePattern)
Set the regular expression that will be applied to filenames during renames to detect whether clients are performing a renaming shuffle - common during file saving on various clients. ALF-3856, ALF-7079, MNT-181- Parameters:
renameShufflePattern
- a regular expression filename match
-
getSizeLimit
public long getSizeLimit()
- Returns:
- Return the limit size
-
getAuthenticationService
public final org.alfresco.service.cmr.security.AuthenticationService getAuthenticationService()
- Returns:
- Return the authentication service
-
getServiceRegistry
public org.alfresco.service.ServiceRegistry getServiceRegistry()
- Returns:
- Return the service registry
-
getNodeService
public final org.alfresco.service.cmr.repository.NodeService getNodeService()
- Returns:
- Return the node service
-
getFileFolderService
public org.alfresco.service.cmr.model.FileFolderService getFileFolderService()
-
getSearchService
public final org.alfresco.service.cmr.search.SearchService getSearchService()
- Returns:
- Return the search service
-
getNamespaceService
public final org.alfresco.service.namespace.NamespaceService getNamespaceService()
- Returns:
- Return the namespace service
-
getDictionaryService
public final org.alfresco.service.cmr.dictionary.DictionaryService getDictionaryService()
- Returns:
- Return the dictionary service
-
getMimetypeService
public final org.alfresco.service.cmr.repository.MimetypeService getMimetypeService()
- Returns:
- Return the mimetype service
-
getLockService
public WebDAVLockService getLockService()
- Returns:
- Return the lock service
-
getActionService
public final org.alfresco.service.cmr.action.ActionService getActionService()
- Returns:
- Return the action service
-
getPermissionService
public final org.alfresco.service.cmr.security.PermissionService getPermissionService()
- Returns:
- Return the permission service
-
getHiddenAspect
public final org.alfresco.repo.model.filefolder.HiddenAspect getHiddenAspect()
- Returns:
- the hidden aspect bean
-
getTenantService
public org.alfresco.repo.tenant.TenantService getTenantService()
Retrieve theTenantService
held by the helper.- Returns:
- TenantService
-
getCopyService
public final org.alfresco.service.cmr.repository.CopyService getCopyService()
- Returns:
- Return the copy service
-
setTenantService
public void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
-
setServiceRegistry
public void setServiceRegistry(org.alfresco.service.ServiceRegistry serviceRegistry)
- Parameters:
serviceRegistry
- the service registry
-
setNodeService
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
- Parameters:
nodeService
- the node service
-
setFileFolderService
public void setFileFolderService(org.alfresco.service.cmr.model.FileFolderService fileFolderService)
- Parameters:
fileFolderService
- the fileFolder service
-
setSearchService
public void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
- Parameters:
searchService
- the search service
-
setNamespaceService
public void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
- Parameters:
namespaceService
- the namespace service
-
setEventPublisher
public void setEventPublisher(org.alfresco.repo.events.EventPublisher eventPublisher)
- Parameters:
eventPublisher
- the eventPublisher service
-
setPoster
public void setPoster(org.alfresco.service.cmr.activities.ActivityPoster poster)
- Parameters:
poster
- ActivityPoster
-
setDictionaryService
public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
- Parameters:
dictionaryService
- the dictionary service
-
setMimetypeService
public void setMimetypeService(org.alfresco.service.cmr.repository.MimetypeService mimetypeService)
- Parameters:
mimetypeService
- the mimetype service
-
setLockService
public void setLockService(WebDAVLockService lockService)
- Parameters:
lockService
- the lock service
-
setActionService
public void setActionService(org.alfresco.service.cmr.action.ActionService actionService)
- Parameters:
actionService
- the action service
-
setAuthenticationService
public void setAuthenticationService(org.alfresco.service.cmr.security.AuthenticationService authService)
- Parameters:
authService
- the authentication service
-
setPermissionService
public void setPermissionService(org.alfresco.service.cmr.security.PermissionService permissionService)
- Parameters:
permissionService
- the permission service
-
setHiddenAspect
public void setHiddenAspect(org.alfresco.repo.model.filefolder.HiddenAspect hiddenAspect)
- Parameters:
hiddenAspect
- the hiddenAspect to set
-
getPolicyBehaviourFilter
public org.alfresco.repo.policy.BehaviourFilter getPolicyBehaviourFilter()
-
setPolicyBehaviourFilter
public void setPolicyBehaviourFilter(org.alfresco.repo.policy.BehaviourFilter behaviourFilter)
-
isRenameShuffle
public boolean isRenameShuffle(java.lang.String newPath)
Checks a new path in a move operation to detect whether clients are starting a renaming shuffle - common during file saving on various clients. ALF-3856, ALF-7079, MNT-181
-
splitPath
public final java.lang.String[] splitPath(java.lang.String path)
Split the path into seperate directory path and file name strings. If the path is not empty, then there will always be an entry for the filename- Parameters:
path
- Full path string.- Returns:
- Returns a String[2] with the folder path and file path.
-
splitAllPaths
public java.util.List<java.lang.String> splitAllPaths(java.lang.String path)
Split the path into all the component directories and filename- Parameters:
path
- the string to split- Returns:
- an array of all the path components
-
getURLForPath
public java.lang.String getURLForPath(javax.servlet.http.HttpServletRequest request, java.lang.String path, boolean isCollection)
-
getURLForPath
public java.lang.String getURLForPath(javax.servlet.http.HttpServletRequest request, java.lang.String path, boolean isCollection, java.lang.String userAgent)
-
getNodeForPath
public org.alfresco.service.cmr.model.FileInfo getNodeForPath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path) throws org.alfresco.service.cmr.model.FileNotFoundException
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:
org.alfresco.service.cmr.model.FileNotFoundException
- if the path doesn't refer to a valid node
-
isRootPath
public boolean isRootPath(java.lang.String path, java.lang.String servletPath)
-
getParentNodeForPath
public final org.alfresco.service.cmr.model.FileInfo getParentNodeForPath(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path) throws org.alfresco.service.cmr.model.FileNotFoundException
- Throws:
org.alfresco.service.cmr.model.FileNotFoundException
-
getPathFromNode
public final java.lang.String getPathFromNode(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, org.alfresco.service.cmr.repository.NodeRef nodeRef) throws org.alfresco.service.cmr.model.FileNotFoundException
Return the relative path for the node walking back to the specified root node- Parameters:
rootNodeRef
- the root below which the path will be validnodeRef
- the node's path to get- Returns:
- Returns string of form /A/B/C where C represents the from node and
- Throws:
org.alfresco.service.cmr.model.FileNotFoundException
-
createFile
public org.alfresco.service.cmr.model.FileInfo createFile(org.alfresco.service.cmr.model.FileInfo parentNodeInfo, java.lang.String path) throws WebDAVServerException
- Throws:
WebDAVServerException
-
getChildren
public java.util.List<org.alfresco.service.cmr.model.FileInfo> getChildren(org.alfresco.service.cmr.model.FileInfo fileInfo) throws WebDAVServerException
- Throws:
WebDAVServerException
-
makeETag
public final java.lang.String makeETag(org.alfresco.service.cmr.model.FileInfo nodeInfo)
Make an ETag value for a node using the GUID and modify date/time
-
makeQuotedETag
public final java.lang.String makeQuotedETag(org.alfresco.service.cmr.model.FileInfo nodeInfo)
Make an ETag value for a node using the GUID and modify date/time
-
makeETagString
protected final void makeETagString(org.alfresco.service.cmr.model.FileInfo nodeInfo, java.lang.StringBuilder etag)
Make an ETag value for a node using the GUID and modify date/time
-
getNullAttributes
public final org.xml.sax.helpers.AttributesImpl getNullAttributes()
- Returns:
- Return the null XML attribute list
-
encodeURL
public static final java.lang.String encodeURL(java.lang.String s)
Encodes the given string to valid URL format- Parameters:
s
- the String to convert
-
encodeURL
public static final java.lang.String encodeURL(java.lang.String s, java.lang.String userAgent)
-
decodeURL
public static final java.lang.String decodeURL(java.lang.String s)
-
encodeHTML
public static final java.lang.String encodeHTML(java.lang.String string)
Encodes the given string to valid HTML format- Parameters:
string
- the String to convert
-
encodeUrlReservedSymbols
public static final java.lang.String encodeUrlReservedSymbols(java.lang.String string) throws java.io.UnsupportedEncodingException
ALF-5333: Microsoft clients use ISO-8859-1 to decode WebDAV responses so this method should only be used for Microsoft user agents.- Parameters:
string
- String- Returns:
- The encoded string for Microsoft clients
- Throws:
java.io.UnsupportedEncodingException
-
determineSiteId
public java.lang.String determineSiteId(WebDAVMethod method)
-
determineSiteId
public java.lang.String determineSiteId(org.alfresco.service.cmr.repository.NodeRef rootNodeRef, java.lang.String path)
-
determineTenantDomain
@Deprecated public java.lang.String determineTenantDomain(WebDAVMethod method)
Deprecated.
-
determineTenantDomain
public java.lang.String determineTenantDomain()
-
getDestinationPath
public java.lang.String getDestinationPath(java.lang.String contextPath, java.lang.String servletPath, java.lang.String destURL)
Extract the destination path for MOVE or COPY commands from the supplied destination URL header.- Parameters:
servletPath
- Path prefix of the WebDAV servlet.destURL
- The Destination header.- Returns:
- The path to move/copy the file to.
-
checkDestinationURL
public void checkDestinationURL(javax.servlet.http.HttpServletRequest request, java.lang.String urlStr) throws WebDAVServerException
Check that the destination path is on this server and is a valid WebDAV path for this server- Parameters:
request
- The request made against the WebDAV server.urlStr
- String- Throws:
WebDAVServerException
-
setUrlPathPrefix
public void setUrlPathPrefix(java.lang.String urlPathPrefix)
-
getUrlPathPrefix
public java.lang.String getUrlPathPrefix(javax.servlet.http.HttpServletRequest request)
-
publishReadEvent
protected void publishReadEvent(org.alfresco.service.cmr.model.FileInfo realNodeInfo, java.lang.String mimetype, java.lang.Long size, java.lang.String contentEncoding, java.lang.String range)
Notifies listeners that a read has taken place- Parameters:
realNodeInfo
- FileInfomimetype
- Stringsize
- LongcontentEncoding
- Stringrange
- String
-
getRepositoryPath
public java.lang.String getRepositoryPath(javax.servlet.http.HttpServletRequest request)
-
isLockedAndReadOnly
public boolean isLockedAndReadOnly(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Indicates if the node is unlocked or the current user has a WRITE_LOCK- Parameters:
nodeRef
- the node reference- See Also:
LockService.isLockedAndReadOnly(org.alfresco.service.cmr.repository.NodeRef)
-
-