Package org.alfresco.repo.webdav
Class WebDAVHelper
java.lang.Object
org.alfresco.repo.webdav.WebDAVHelper
WebDAV Protocol Helper Class
Provides helper methods for repository access using the WebDAV protocol.
- Author:
- GKSpencer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkDestinationURL
(javax.servlet.http.HttpServletRequest request, String urlStr) Check that the destination path is on this server and is a valid WebDAV path for this servercreateFile
(FileInfo parentNodeInfo, String path) static final String
determineSiteId
(WebDAVMethod method) determineSiteId
(NodeRef rootNodeRef, String path) determineTenantDomain
(WebDAVMethod method) Deprecated.static final String
encodeHTML
(String string) Encodes the given string to valid HTML formatstatic final String
Encodes the given string to valid URL formatstatic final String
static final String
encodeUrlReservedSymbols
(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.final ActionService
final AuthenticationService
getChildren
(FileInfo fileInfo) final CopyService
getDestinationPath
(String contextPath, String servletPath, String destURL) Extract the destination path for MOVE or COPY commands from the supplied destination URL header.final org.alfresco.service.cmr.dictionary.DictionaryService
final HiddenAspect
final MimetypeService
final org.alfresco.service.namespace.NamespaceService
getNodeForPath
(NodeRef rootNodeRef, String path) Get the file info for the given pathsfinal NodeService
final AttributesImpl
final FileInfo
getParentNodeForPath
(NodeRef rootNodeRef, String path) final String
getPathFromNode
(NodeRef rootNodeRef, NodeRef nodeRef) Return the relative path for the node walking back to the specified root nodefinal PermissionService
getRepositoryPath
(javax.servlet.http.HttpServletRequest request) final SearchService
long
Retrieve theTenantService
held by the helper.getURLForPath
(javax.servlet.http.HttpServletRequest request, String path, boolean isCollection) getURLForPath
(javax.servlet.http.HttpServletRequest request, String path, boolean isCollection, String userAgent) getUrlPathPrefix
(javax.servlet.http.HttpServletRequest request) boolean
isLockedAndReadOnly
(NodeRef nodeRef) Indicates if the node is unlocked or the current user has a WRITE_LOCKboolean
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.boolean
isRootPath
(String path, String servletPath) final String
Make an ETag value for a node using the GUID and modify date/timeprotected final void
makeETagString
(FileInfo nodeInfo, StringBuilder etag) Make an ETag value for a node using the GUID and modify date/timefinal String
makeQuotedETag
(FileInfo nodeInfo) Make an ETag value for a node using the GUID and modify date/timeprotected void
publishReadEvent
(FileInfo realNodeInfo, String mimetype, Long size, String contentEncoding, String range) Notifies listeners that a read has taken placevoid
setActionService
(ActionService actionService) void
setAuthenticationService
(AuthenticationService authService) void
setDictionaryService
(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService) void
setEventPublisher
(org.alfresco.sync.repo.events.EventPublisher eventPublisher) void
setFileFolderService
(FileFolderService fileFolderService) void
setHiddenAspect
(HiddenAspect hiddenAspect) void
setLockService
(WebDAVLockService lockService) void
setMimetypeService
(MimetypeService mimetypeService) void
setNamespaceService
(org.alfresco.service.namespace.NamespaceService namespaceService) void
setNodeService
(NodeService nodeService) void
setPermissionService
(PermissionService permissionService) void
setPolicyBehaviourFilter
(BehaviourFilter behaviourFilter) void
setPoster
(ActivityPoster poster) 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.void
setSearchService
(SearchService searchService) void
setServiceRegistry
(ServiceRegistry serviceRegistry) void
setSizeLimitString
(String limit) This method sets a value for the limit.void
setTenantService
(TenantService tenantService) void
setUrlPathPrefix
(String urlPathPrefix) splitAllPaths
(String path) Split the path into all the component directories and filenamefinal String[]
Split the path into seperate directory path and file name strings.
-
Field Details
-
BEAN_NAME
- See Also:
-
PathSeperator
- See Also:
-
PathSeperatorChar
public static final char PathSeperatorChar- See Also:
-
EMPTY_SITE_ID
- See Also:
-
logger
protected static org.apache.commons.logging.Log logger
-
-
Constructor Details
-
WebDAVHelper
public WebDAVHelper()
-
-
Method Details
-
setSizeLimitString
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
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
- Returns:
- Return the authentication service
-
getServiceRegistry
- Returns:
- Return the service registry
-
getNodeService
- Returns:
- Return the node service
-
getFileFolderService
-
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
- Returns:
- Return the mimetype service
-
getLockService
- Returns:
- Return the lock service
-
getActionService
- Returns:
- Return the action service
-
getPermissionService
- Returns:
- Return the permission service
-
getHiddenAspect
- Returns:
- the hidden aspect bean
-
getTenantService
Retrieve theTenantService
held by the helper.- Returns:
- TenantService
-
getCopyService
- Returns:
- Return the copy service
-
setTenantService
-
setServiceRegistry
- Parameters:
serviceRegistry
- the service registry
-
setNodeService
- Parameters:
nodeService
- the node service
-
setFileFolderService
- Parameters:
fileFolderService
- the fileFolder service
-
setSearchService
- 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
- Parameters:
poster
- ActivityPoster
-
setDictionaryService
public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService) - Parameters:
dictionaryService
- the dictionary service
-
setMimetypeService
- Parameters:
mimetypeService
- the mimetype service
-
setLockService
- Parameters:
lockService
- the lock service
-
setActionService
- Parameters:
actionService
- the action service
-
setAuthenticationService
- Parameters:
authService
- the authentication service
-
setPermissionService
- Parameters:
permissionService
- the permission service
-
setHiddenAspect
- Parameters:
hiddenAspect
- the hiddenAspect to set
-
getPolicyBehaviourFilter
-
setPolicyBehaviourFilter
-
isRenameShuffle
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
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
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
-
getURLForPath
-
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
-
isRootPath
-
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
- Throws:
WebDAVServerException
-
getChildren
- Throws:
WebDAVServerException
-
makeETag
Make an ETag value for a node using the GUID and modify date/time -
makeQuotedETag
Make an ETag value for a node using the GUID and modify date/time -
makeETagString
Make an ETag value for a node using the GUID and modify date/time -
getNullAttributes
- Returns:
- Return the null XML attribute list
-
encodeURL
Encodes the given string to valid URL format- Parameters:
s
- the String to convert
-
encodeURL
-
decodeURL
-
encodeHTML
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
-
determineSiteId
-
determineTenantDomain
Deprecated. -
determineTenantDomain
-
getDestinationPath
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 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
-
getUrlPathPrefix
-
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
-
isLockedAndReadOnly
Indicates if the node is unlocked or the current user has a WRITE_LOCK- Parameters:
nodeRef
- the node reference- See Also:
-