Package org.alfresco.repo.webdav
Class WebDAVHelper
- java.lang.Object
-
- org.alfresco.repo.webdav.WebDAVHelper
-
public class WebDAVHelper extends 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 StringBEAN_NAMEstatic StringEMPTY_SITE_IDprotected static org.apache.commons.logging.Logloggerstatic StringPathSeperatorstatic charPathSeperatorChar
-
Constructor Summary
Constructors Constructor Description WebDAVHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcheckDestinationURL(javax.servlet.http.HttpServletRequest request, String urlStr)Check that the destination path is on this server and is a valid WebDAV path for this serverFileInfocreateFile(FileInfo parentNodeInfo, String path)static StringdecodeURL(String s)StringdetermineSiteId(WebDAVMethod method)StringdetermineSiteId(NodeRef rootNodeRef, String path)StringdetermineTenantDomain()StringdetermineTenantDomain(WebDAVMethod method)Deprecated.static StringencodeHTML(String string)Encodes the given string to valid HTML formatstatic StringencodeURL(String s)Encodes the given string to valid URL formatstatic StringencodeURL(String s, String userAgent)static StringencodeUrlReservedSymbols(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.ActionServicegetActionService()AuthenticationServicegetAuthenticationService()List<FileInfo>getChildren(FileInfo fileInfo)CopyServicegetCopyService()StringgetDestinationPath(String contextPath, String servletPath, String destURL)Extract the destination path for MOVE or COPY commands from the supplied destination URL header.org.alfresco.service.cmr.dictionary.DictionaryServicegetDictionaryService()FileFolderServicegetFileFolderService()HiddenAspectgetHiddenAspect()WebDAVLockServicegetLockService()MimetypeServicegetMimetypeService()org.alfresco.service.namespace.NamespaceServicegetNamespaceService()FileInfogetNodeForPath(NodeRef rootNodeRef, String path)Get the file info for the given pathsNodeServicegetNodeService()AttributesImplgetNullAttributes()FileInfogetParentNodeForPath(NodeRef rootNodeRef, String path)StringgetPathFromNode(NodeRef rootNodeRef, NodeRef nodeRef)Return the relative path for the node walking back to the specified root nodePermissionServicegetPermissionService()BehaviourFiltergetPolicyBehaviourFilter()StringgetRepositoryPath(javax.servlet.http.HttpServletRequest request)SearchServicegetSearchService()ServiceRegistrygetServiceRegistry()longgetSizeLimit()TenantServicegetTenantService()Retrieve theTenantServiceheld by the helper.StringgetURLForPath(javax.servlet.http.HttpServletRequest request, String path, boolean isCollection)StringgetURLForPath(javax.servlet.http.HttpServletRequest request, String path, boolean isCollection, String userAgent)StringgetUrlPathPrefix(javax.servlet.http.HttpServletRequest request)booleanisLockedAndReadOnly(NodeRef nodeRef)Indicates if the node is unlocked or the current user has a WRITE_LOCKbooleanisRenameShuffle(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.booleanisRootPath(String path, String servletPath)StringmakeETag(FileInfo nodeInfo)Make an ETag value for a node using the GUID and modify date/timeprotected voidmakeETagString(FileInfo nodeInfo, StringBuilder etag)Make an ETag value for a node using the GUID and modify date/timeStringmakeQuotedETag(FileInfo nodeInfo)Make an ETag value for a node using the GUID and modify date/timeprotected voidpublishReadEvent(FileInfo realNodeInfo, String mimetype, Long size, String contentEncoding, String range)Notifies listeners that a read has taken placevoidsetActionService(ActionService actionService)voidsetAuthenticationService(AuthenticationService authService)voidsetDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)voidsetEventPublisher(org.alfresco.sync.repo.events.EventPublisher eventPublisher)voidsetFileFolderService(FileFolderService fileFolderService)voidsetHiddenAspect(HiddenAspect hiddenAspect)voidsetLockService(WebDAVLockService lockService)voidsetMimetypeService(MimetypeService mimetypeService)voidsetNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)voidsetNodeService(NodeService nodeService)voidsetPermissionService(PermissionService permissionService)voidsetPolicyBehaviourFilter(BehaviourFilter behaviourFilter)voidsetPoster(ActivityPoster poster)voidsetRenameShufflePattern(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.voidsetSearchService(SearchService searchService)voidsetServiceRegistry(ServiceRegistry serviceRegistry)voidsetSizeLimitString(String limit)This method sets a value for the limit.voidsetTenantService(TenantService tenantService)voidsetUrlPathPrefix(String urlPathPrefix)List<String>splitAllPaths(String path)Split the path into all the component directories and filenameString[]splitPath(String path)Split the path into seperate directory path and file name strings.
-
-
-
Field Detail
-
BEAN_NAME
public static final String BEAN_NAME
- See Also:
- Constant Field Values
-
PathSeperator
public static final String PathSeperator
- See Also:
- Constant Field Values
-
PathSeperatorChar
public static final char PathSeperatorChar
- See Also:
- Constant Field Values
-
EMPTY_SITE_ID
public static final String EMPTY_SITE_ID
- See Also:
- Constant Field Values
-
logger
protected static org.apache.commons.logging.Log logger
-
-
Method Detail
-
setSizeLimitString
public void setSizeLimitString(String limit)
This method sets a value for the limit. If the string does notparseto a java long.- Parameters:
limit- a String representing a valid Java long.
-
setRenameShufflePattern
public void setRenameShufflePattern(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 AuthenticationService getAuthenticationService()
- Returns:
- Return the authentication service
-
getServiceRegistry
public ServiceRegistry getServiceRegistry()
- Returns:
- Return the service registry
-
getNodeService
public final NodeService getNodeService()
- Returns:
- Return the node service
-
getFileFolderService
public FileFolderService getFileFolderService()
-
getSearchService
public final 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 MimetypeService getMimetypeService()
- Returns:
- Return the mimetype service
-
getLockService
public WebDAVLockService getLockService()
- Returns:
- Return the lock service
-
getActionService
public final ActionService getActionService()
- Returns:
- Return the action service
-
getPermissionService
public final PermissionService getPermissionService()
- Returns:
- Return the permission service
-
getHiddenAspect
public final HiddenAspect getHiddenAspect()
- Returns:
- the hidden aspect bean
-
getTenantService
public TenantService getTenantService()
Retrieve theTenantServiceheld by the helper.- Returns:
- TenantService
-
getCopyService
public final CopyService getCopyService()
- Returns:
- Return the copy service
-
setTenantService
public void setTenantService(TenantService tenantService)
-
setServiceRegistry
public void setServiceRegistry(ServiceRegistry serviceRegistry)
- Parameters:
serviceRegistry- the service registry
-
setNodeService
public void setNodeService(NodeService nodeService)
- Parameters:
nodeService- the node service
-
setFileFolderService
public void setFileFolderService(FileFolderService fileFolderService)
- Parameters:
fileFolderService- the fileFolder service
-
setSearchService
public void setSearchService(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.sync.repo.events.EventPublisher eventPublisher)
- Parameters:
eventPublisher- the eventPublisher service
-
setPoster
public void setPoster(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(MimetypeService mimetypeService)
- Parameters:
mimetypeService- the mimetype service
-
setLockService
public void setLockService(WebDAVLockService lockService)
- Parameters:
lockService- the lock service
-
setActionService
public void setActionService(ActionService actionService)
- Parameters:
actionService- the action service
-
setAuthenticationService
public void setAuthenticationService(AuthenticationService authService)
- Parameters:
authService- the authentication service
-
setPermissionService
public void setPermissionService(PermissionService permissionService)
- Parameters:
permissionService- the permission service
-
setHiddenAspect
public void setHiddenAspect(HiddenAspect hiddenAspect)
- Parameters:
hiddenAspect- the hiddenAspect to set
-
getPolicyBehaviourFilter
public BehaviourFilter getPolicyBehaviourFilter()
-
setPolicyBehaviourFilter
public void setPolicyBehaviourFilter(BehaviourFilter behaviourFilter)
-
isRenameShuffle
public boolean isRenameShuffle(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 String[] splitPath(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 List<String> splitAllPaths(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 String getURLForPath(javax.servlet.http.HttpServletRequest request, String path, boolean isCollection)
-
getURLForPath
public String getURLForPath(javax.servlet.http.HttpServletRequest request, String path, boolean isCollection, String userAgent)
-
getNodeForPath
public FileInfo getNodeForPath(NodeRef rootNodeRef, String path) throws 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:
FileNotFoundException- if the path doesn't refer to a valid node
-
getParentNodeForPath
public final FileInfo getParentNodeForPath(NodeRef rootNodeRef, String path) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getPathFromNode
public final String getPathFromNode(NodeRef rootNodeRef, NodeRef nodeRef) throws 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:
FileNotFoundException
-
createFile
public FileInfo createFile(FileInfo parentNodeInfo, String path) throws WebDAVServerException
- Throws:
WebDAVServerException
-
getChildren
public List<FileInfo> getChildren(FileInfo fileInfo) throws WebDAVServerException
- Throws:
WebDAVServerException
-
makeETag
public final String makeETag(FileInfo nodeInfo)
Make an ETag value for a node using the GUID and modify date/time
-
makeQuotedETag
public final String makeQuotedETag(FileInfo nodeInfo)
Make an ETag value for a node using the GUID and modify date/time
-
makeETagString
protected final void makeETagString(FileInfo nodeInfo, StringBuilder etag)
Make an ETag value for a node using the GUID and modify date/time
-
getNullAttributes
public final AttributesImpl getNullAttributes()
- Returns:
- Return the null XML attribute list
-
encodeURL
public static final String encodeURL(String s)
Encodes the given string to valid URL format- Parameters:
s- the String to convert
-
encodeHTML
public static final String encodeHTML(String string)
Encodes the given string to valid HTML format- Parameters:
string- the String to convert
-
encodeUrlReservedSymbols
public static final String encodeUrlReservedSymbols(String string) throws 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:
UnsupportedEncodingException
-
determineSiteId
public String determineSiteId(WebDAVMethod method)
-
determineTenantDomain
@Deprecated public String determineTenantDomain(WebDAVMethod method)
Deprecated.
-
determineTenantDomain
public String determineTenantDomain()
-
getDestinationPath
public String getDestinationPath(String contextPath, String servletPath, 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, String urlStr) throws WebDAVServerExceptionCheck 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(String urlPathPrefix)
-
getUrlPathPrefix
public String getUrlPathPrefix(javax.servlet.http.HttpServletRequest request)
-
publishReadEvent
protected void publishReadEvent(FileInfo realNodeInfo, String mimetype, Long size, String contentEncoding, String range)
Notifies listeners that a read has taken place- Parameters:
realNodeInfo- FileInfomimetype- Stringsize- LongcontentEncoding- Stringrange- String
-
getRepositoryPath
public String getRepositoryPath(javax.servlet.http.HttpServletRequest request)
-
isLockedAndReadOnly
public boolean isLockedAndReadOnly(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)
-
-