WebDAV: removed static WebDAV.getRepositoryPath() method. Only use the non-static version.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@39172 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Matt Ward
2012-07-12 09:39:05 +00:00
parent b89348b1ad
commit e67f40a573
2 changed files with 57 additions and 69 deletions

View File

@@ -352,74 +352,6 @@ public class WebDAV
return value; 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. * Returns a URL that could be used to access the given path.
* *

View File

@@ -867,6 +867,62 @@ public class WebDAVHelper
public String getRepositoryPath(HttpServletRequest request) 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;
} }
} }