Class WebDAVHelper

java.lang.Object
org.alfresco.repo.webdav.WebDAVHelper

public class WebDAVHelper extends Object
WebDAV Protocol Helper Class

Provides helper methods for repository access using the WebDAV protocol.

Author:
GKSpencer
  • Field Details

  • Constructor Details

    • WebDAVHelper

      public WebDAVHelper()
  • Method Details

    • setSizeLimitString

      public void setSizeLimitString(String limit)
      This method sets a value for the limit. If the string does not parse to 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 the TenantService held 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 root
      path - 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

      public boolean isRootPath(String path, String servletPath)
    • 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 valid
      nodeRef - 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
    • encodeURL

      public static final String encodeURL(String s, String userAgent)
    • decodeURL

      public static final String decodeURL(String s)
    • 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)
    • determineSiteId

      public String determineSiteId(NodeRef rootNodeRef, String path)
    • 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 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(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 - FileInfo
      mimetype - String
      size - Long
      contentEncoding - String
      range - 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: