diff --git a/source/java/org/alfresco/repo/webdav/WebDAV.java b/source/java/org/alfresco/repo/webdav/WebDAV.java index ba62d6a53e..2237908bd1 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAV.java +++ b/source/java/org/alfresco/repo/webdav/WebDAV.java @@ -352,74 +352,6 @@ public class WebDAV return value; } - - /** - * Maps the current HTTP request to a path that can be used to access a content repository - * - * @param request HTTP request - * @return A content repository path - */ - public static String getRepositoryPath(HttpServletRequest request) - { - // Try and get the path - - String strPath = null; - - try - { - strPath = WebDAVHelper.decodeURL(request.getRequestURI()); - } - catch (Exception ex) {} - - // Find the servlet path and trim from the request path - - String servletPath = request.getServletPath(); - - int rootPos = strPath.indexOf(servletPath); - if ( rootPos != -1) - { - strPath = strPath.substring( rootPos); - } - - // If we failed to get the path from the request try and get the path from the servlet path - - if (strPath == null) - { - strPath = request.getServletPath(); - } - - if (strPath == null || strPath.length() == 0) - { - // If we still have not got a path then default to the root directory - strPath = RootPath; - } - else if (strPath.startsWith(request.getServletPath())) - { - // Check if the path starts with the base servlet path - int len = request.getServletPath().length(); - - if (strPath.length() > len) - { - strPath = strPath.substring(len); - } - else - { - strPath = RootPath; - } - } - - // Make sure there are no trailing slashes - - if (strPath.length() > 1 && strPath.endsWith(DIR_SEPARATOR)) - { - strPath = strPath.substring(0, strPath.length() - 1); - } - - // Return the path - - return strPath; - } - /** * Returns a URL that could be used to access the given path. * diff --git a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java index d42a970530..89e28fd878 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java +++ b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java @@ -867,6 +867,62 @@ public class WebDAVHelper public String getRepositoryPath(HttpServletRequest request) { - return WebDAV.getRepositoryPath(request); + // Try and get the path + + String strPath = null; + + try + { + strPath = WebDAVHelper.decodeURL(request.getRequestURI()); + } + catch (Exception ex) {} + + // Find the servlet path and trim from the request path + + String servletPath = request.getServletPath(); + + int rootPos = strPath.indexOf(servletPath); + if ( rootPos != -1) + { + strPath = strPath.substring( rootPos); + } + + // If we failed to get the path from the request try and get the path from the servlet path + + if (strPath == null) + { + strPath = request.getServletPath(); + } + + if (strPath == null || strPath.length() == 0) + { + // If we still have not got a path then default to the root directory + strPath = RootPath; + } + else if (strPath.startsWith(request.getServletPath())) + { + // Check if the path starts with the base servlet path + int len = request.getServletPath().length(); + + if (strPath.length() > len) + { + strPath = strPath.substring(len); + } + else + { + strPath = RootPath; + } + } + + // Make sure there are no trailing slashes + + if (strPath.length() > 1 && strPath.endsWith(DIR_SEPARATOR)) + { + strPath = strPath.substring(0, strPath.length() - 1); + } + + // Return the path + + return strPath; } }