Merged BRANCHES/DEV/THOR1_SPRINTS to HEAD:

36060: THOR-1373: Proxied WebDAV must generate correct URLs when URL-rewriting is used.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@39078 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2012-07-11 14:30:25 +00:00
parent c923263bef
commit 91f9df2b23
6 changed files with 87 additions and 21 deletions

View File

@@ -424,39 +424,29 @@ public class WebDAV
* 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 path, boolean isCollection)
public static String getURLForPath(HttpServletRequest request, String urlPathPrefix, String path, boolean isCollection)
{
return getURLForPath(request, path, isCollection, null);
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 path, boolean isCollection, String userAgent)
public static String getURLForPath(HttpServletRequest request, String urlPathPrefix, String path, boolean isCollection, String userAgent)
{
StringBuilder urlStr = new StringBuilder(request.getRequestURI());
String servletPath = request.getServletPath();
int rootPos = urlStr.indexOf(servletPath);
if (rootPos != -1)
{
urlStr.setLength(rootPos + servletPath.length());
}
if (urlStr.charAt(urlStr.length() - 1) != PathSeperatorChar)
{
urlStr.append(PathSeperator);
}
StringBuilder urlStr = new StringBuilder(urlPathPrefix);
if (path.equals(RootPath) == false)
{
@@ -477,6 +467,8 @@ public class WebDAV
urlStr.append( PathSeperator);
}
logger.debug("getURLForPath() path:" + path + " => url:" + urlStr);
// Return the URL string
return urlStr.toString();
}