diff --git a/source/java/org/alfresco/repo/webdav/WebDAV.java b/source/java/org/alfresco/repo/webdav/WebDAV.java index 0b7dce52f4..4ad5a74b43 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAV.java +++ b/source/java/org/alfresco/repo/webdav/WebDAV.java @@ -350,63 +350,6 @@ public class WebDAV } return value; } - - /** - * Returns a URL that could be used to access the given path. - * - * @param request HttpServletRequest - * @param urlPathPrefix - * @param path String - * @param isCollection boolean - * @return String - */ - public static String getURLForPath(HttpServletRequest request, String urlPathPrefix, String path, boolean isCollection) - { - return getURLForPath(request, urlPathPrefix, path, isCollection, null); - } - - /** - * Returns a URL that could be used to access the given path. - * - * @param request HttpServletRequest - * @param urlPathPrefix - * @param path String - * @param isCollection boolean - * @param userAgent String - * @return String - */ - public static String getURLForPath(HttpServletRequest request, String urlPathPrefix, String path, boolean isCollection, String userAgent) - { - if (!urlPathPrefix.endsWith(WebDAV.PathSeperator)) - { - urlPathPrefix = urlPathPrefix + WebDAV.PathSeperator; - } - StringBuilder urlStr = new StringBuilder(urlPathPrefix); - - if (path.equals(RootPath) == false) - { - // split the path and URL encode each path element - for (StringTokenizer t = new StringTokenizer(path, PathSeperator); t.hasMoreTokens(); /**/) - { - urlStr.append( WebDAVHelper.encodeURL(t.nextToken(), userAgent) ); - if (t.hasMoreTokens()) - { - urlStr.append(PathSeperator); - } - } - } - - // If the URL is to a collection add a trailing slash - if (isCollection && urlStr.charAt( urlStr.length() - 1) != PathSeperatorChar) - { - urlStr.append( PathSeperator); - } - - logger.debug("getURLForPath() path:" + path + " => url:" + urlStr); - - // Return the URL string - return urlStr.toString(); - } /** * Returns a context-relative path, beginning with a "/", that represents the canonical version diff --git a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java index a9ddbe02e2..aa4c48a6e5 100644 --- a/source/java/org/alfresco/repo/webdav/WebDAVHelper.java +++ b/source/java/org/alfresco/repo/webdav/WebDAVHelper.java @@ -284,9 +284,39 @@ public class WebDAVHelper return results; } - protected String getURLForPath(HttpServletRequest request, String path, boolean isFolder, String userAgent) + public String getURLForPath(HttpServletRequest request, String path, boolean isCollection) { - return WebDAV.getURLForPath(request, getUrlPathPrefix(request), path, isFolder, userAgent); + return getURLForPath(request, path, isCollection, null); + } + + public String getURLForPath(HttpServletRequest request, String path, boolean isCollection, String userAgent) + { + String urlPathPrefix = getUrlPathPrefix(request); + StringBuilder urlStr = new StringBuilder(urlPathPrefix); + + if (path.equals(WebDAV.RootPath) == false) + { + // split the path and URL encode each path element + for (StringTokenizer t = new StringTokenizer(path, PathSeperator); t.hasMoreTokens(); /**/) + { + urlStr.append( WebDAVHelper.encodeURL(t.nextToken(), userAgent) ); + if (t.hasMoreTokens()) + { + urlStr.append(PathSeperator); + } + } + } + + // If the URL is to a collection add a trailing slash + if (isCollection && urlStr.charAt( urlStr.length() - 1) != PathSeperatorChar) + { + urlStr.append( PathSeperator); + } + + logger.debug("getURLForPath() path:" + path + " => url:" + urlStr); + + // Return the URL string + return urlStr.toString(); } /**