ALF-12253: Incorrect path is generated if folder with name "webdav" is created

- Pointless servletPath argument removed from WebDAVHelper.getNodeForPath()
- Analysis by Vadim confirms it's not needed and results in mis-handling of root folders called alfresco or webdav

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@46201 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2013-02-04 16:46:48 +00:00
parent 9c2ea7ea04
commit ccf8d7c3e2
12 changed files with 37 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2012 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -121,7 +121,7 @@ public class DeleteMethod extends WebDAVMethod implements ActivityPostProducer
// As this content will be deleted, we need to extract some info before it's no longer available. // As this content will be deleted, we need to extract some info before it's no longer available.
String siteId = getSiteId(); String siteId = getSiteId();
NodeRef deletedNodeRef = fileInfo.getNodeRef(); NodeRef deletedNodeRef = fileInfo.getNodeRef();
FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), path, getServletPath()); FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), path);
// Delete it // Delete it
fileFolderService.delete(deletedNodeRef); fileFolderService.delete(deletedNodeRef);
// Don't post activity data for hidden files, resource forks etc. // Don't post activity data for hidden files, resource forks etc.

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -163,12 +163,11 @@ public class GetMethod extends WebDAVMethod
FileFolderService fileFolderService = getFileFolderService(); FileFolderService fileFolderService = getFileFolderService();
NodeRef rootNodeRef = getRootNodeRef(); NodeRef rootNodeRef = getRootNodeRef();
String path = getPath(); String path = getPath();
String servletPath = getServletPath();
FileInfo nodeInfo = null; FileInfo nodeInfo = null;
try try
{ {
nodeInfo = getDAVHelper().getNodeForPath(rootNodeRef, path, servletPath); nodeInfo = getDAVHelper().getNodeForPath(rootNodeRef, path);
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -228,7 +228,7 @@ public class LockMethod extends WebDAVMethod
try try
{ {
// Check if the path exists // Check if the path exists
lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), m_request.getServletPath()); lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2012 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -81,7 +81,7 @@ public class MkcolMethod extends WebDAVMethod implements ActivityPostProducer
// see if it exists // see if it exists
try try
{ {
getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); getDAVHelper().getNodeForPath(getRootNodeRef(), getPath());
// already exists // already exists
throw new WebDAVServerException(HttpServletResponse.SC_METHOD_NOT_ALLOWED); throw new WebDAVServerException(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
} }
@@ -109,7 +109,7 @@ public class MkcolMethod extends WebDAVMethod implements ActivityPostProducer
parentPath = parentPath.substring(0, lastPos + 1); parentPath = parentPath.substring(0, lastPos + 1);
try try
{ {
FileInfo parentFileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), parentPath, m_request.getServletPath()); FileInfo parentFileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), parentPath);
parentNodeRef = parentFileInfo.getNodeRef(); parentNodeRef = parentFileInfo.getNodeRef();
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -63,7 +63,6 @@ public class MoveMethod extends HierarchicalMethod
protected final void executeImpl() throws WebDAVServerException, Exception protected final void executeImpl() throws WebDAVServerException, Exception
{ {
NodeRef rootNodeRef = getRootNodeRef(); NodeRef rootNodeRef = getRootNodeRef();
String servletPath = getServletPath();
// Debug // Debug
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -75,14 +74,14 @@ public class MoveMethod extends HierarchicalMethod
FileInfo sourceInfo = null; FileInfo sourceInfo = null;
try try
{ {
sourceInfo = getDAVHelper().getNodeForPath(rootNodeRef, sourcePath, servletPath); sourceInfo = getDAVHelper().getNodeForPath(rootNodeRef, sourcePath);
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND); throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
} }
FileInfo sourceParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, sourcePath, servletPath); FileInfo sourceParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, sourcePath);
// the destination parent must exist // the destination parent must exist
String destPath = getDestinationPath(); String destPath = getDestinationPath();
@@ -93,7 +92,7 @@ public class MoveMethod extends HierarchicalMethod
{ {
destPath = destPath.substring(0, destPath.length() - 1); destPath = destPath.substring(0, destPath.length() - 1);
} }
destParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, destPath, servletPath); destParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, destPath);
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
@@ -109,7 +108,7 @@ public class MoveMethod extends HierarchicalMethod
boolean destExists = false; boolean destExists = false;
try try
{ {
destInfo = getDAVHelper().getNodeForPath(rootNodeRef, destPath, servletPath); destInfo = getDAVHelper().getNodeForPath(rootNodeRef, destPath);
if (!destInfo.getNodeRef().equals(sourceInfo.getNodeRef())) if (!destInfo.getNodeRef().equals(sourceInfo.getNodeRef()))
{ {
// ALF-7079 fix, if destInfo is a hidden shuffle target then pretend it's not there // ALF-7079 fix, if destInfo is a hidden shuffle target then pretend it's not there

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -87,7 +87,7 @@ public class OptionsMethod extends WebDAVMethod
{ {
try try
{ {
FileInfo fileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); FileInfo fileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath());
return fileInfo.isFolder(); return fileInfo.isFolder();
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -187,7 +187,7 @@ public class PropFindMethod extends WebDAVMethod
try try
{ {
// Check that the path exists // Check that the path exists
pathNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), m_strPath, m_request.getServletPath()); pathNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), m_strPath);
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -62,7 +62,7 @@ public class PropPatchMethod extends PropFindMethod
try try
{ {
// Check that the path exists // Check that the path exists
pathNodeInfo = getNodeForPath(getRootNodeRef(), m_strPath, m_request.getServletPath()); pathNodeInfo = getNodeForPath(getRootNodeRef(), m_strPath);
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -111,7 +111,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
FileInfo contentNodeInfo = null; FileInfo contentNodeInfo = null;
try try
{ {
contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
checkNode(contentNodeInfo); checkNode(contentNodeInfo);
final NodeRef nodeRef = contentNodeInfo.getNodeRef(); final NodeRef nodeRef = contentNodeInfo.getNodeRef();
if (getNodeService().hasAspect(contentNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT)) if (getNodeService().hasAspect(contentNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT))
@@ -157,7 +157,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
LockInfo nodeLockInfo = null; LockInfo nodeLockInfo = null;
try try
{ {
contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
// make sure that we are not trying to use a folder // make sure that we are not trying to use a folder
if (contentNodeInfo.isFolder()) if (contentNodeInfo.isFolder())
{ {
@@ -180,7 +180,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
String[] paths = getDAVHelper().splitPath(getPath()); String[] paths = getDAVHelper().splitPath(getPath());
try try
{ {
FileInfo parentNodeInfo = getNodeForPath(getRootNodeRef(), paths[0], getServletPath()); FileInfo parentNodeInfo = getNodeForPath(getRootNodeRef(), paths[0]);
// create file // create file
contentNodeInfo = fileFolderService.create(parentNodeInfo.getNodeRef(), paths[1], ContentModel.TYPE_CONTENT); contentNodeInfo = fileFolderService.create(parentNodeInfo.getNodeRef(), paths[1], ContentModel.TYPE_CONTENT);
created = true; created = true;
@@ -390,7 +390,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
FileInfo contentNodeInfo = null; FileInfo contentNodeInfo = null;
try try
{ {
contentNodeInfo = getNodeForPath(getRootNodeRef(), path, getServletPath()); contentNodeInfo = getNodeForPath(getRootNodeRef(), path);
NodeRef nodeRef = contentNodeInfo.getNodeRef(); NodeRef nodeRef = contentNodeInfo.getNodeRef();
// Don't post activity data for hidden files, resource forks etc. // Don't post activity data for hidden files, resource forks etc.
if (!getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN)) if (!getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN))

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -123,7 +123,7 @@ public class UnlockMethod extends WebDAVMethod
FileInfo lockNodeInfo = null; FileInfo lockNodeInfo = null;
try try
{ {
lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -464,12 +464,11 @@ public class WebDAVHelper
* *
* @param rootNodeRef the acting webdav root * @param rootNodeRef the acting webdav root
* @param path the path to search for * @param path the path to search for
* @param servletPath the base servlet path, which may be null or empty
* @return Return the file info for the path * @return Return the file info for the path
* @throws FileNotFoundException * @throws FileNotFoundException
* if the path doesn't refer to a valid node * if the path doesn't refer to a valid node
*/ */
public final FileInfo getNodeForPath(NodeRef rootNodeRef, String path, String servletPath) throws FileNotFoundException public final FileInfo getNodeForPath(NodeRef rootNodeRef, String path) throws FileNotFoundException
{ {
if (rootNodeRef == null) if (rootNodeRef == null)
{ {
@@ -482,23 +481,11 @@ public class WebDAVHelper
FileFolderService fileFolderService = getFileFolderService(); FileFolderService fileFolderService = getFileFolderService();
// Check for the root path // Check for the root path
if ( path.length() == 0 || path.equals(PathSeperator) || EqualsHelper.nullSafeEquals(path, servletPath)) if ( path.length() == 0 || path.equals(PathSeperator))
{ {
return fileFolderService.getFileInfo(rootNodeRef); return fileFolderService.getFileInfo(rootNodeRef);
} }
// Remove the servlet path from the path, assuming it hasn't already been done
if (servletPath != null && servletPath.length() > 0)
{
// Need to ensure we don't strip /alfresco from a site of /alfresco_name/
String comparePath = servletPath + "/";
if (path.startsWith(comparePath))
{
// Strip the servlet path from the relative path
path = path.substring(servletPath.length());
}
}
// split the paths up // split the paths up
List<String> splitPath = splitAllPaths(path); List<String> splitPath = splitAllPaths(path);
@@ -511,13 +498,12 @@ public class WebDAVHelper
logger.debug("Fetched node for path: \n" + logger.debug("Fetched node for path: \n" +
" root: " + rootNodeRef + "\n" + " root: " + rootNodeRef + "\n" +
" path: " + path + "\n" + " path: " + path + "\n" +
" servlet path: " + servletPath + "\n" +
" result: " + fileInfo); " result: " + fileInfo);
} }
return fileInfo; return fileInfo;
} }
public final FileInfo getParentNodeForPath(NodeRef rootNodeRef, String path, String servletPath) throws FileNotFoundException public final FileInfo getParentNodeForPath(NodeRef rootNodeRef, String path) throws FileNotFoundException
{ {
if (rootNodeRef == null) if (rootNodeRef == null)
{ {
@@ -529,7 +515,7 @@ public class WebDAVHelper
} }
// shorten the path // shorten the path
String[] paths = splitPath(path); String[] paths = splitPath(path);
return getNodeForPath(rootNodeRef, paths[0], servletPath); return getNodeForPath(rootNodeRef, paths[0]);
} }
/** /**
@@ -796,7 +782,7 @@ public class WebDAVHelper
String siteId; String siteId;
try try
{ {
FileInfo fileInfo = getNodeForPath(method.getRootNodeRef(), method.getPath(), method.getServletPath()); FileInfo fileInfo = getNodeForPath(method.getRootNodeRef(), method.getPath());
SiteInfo siteInfo = siteService.getSite(fileInfo.getNodeRef()); SiteInfo siteInfo = siteService.getSite(fileInfo.getNodeRef());
if (siteInfo != null) if (siteInfo != null)
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2012 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -1432,17 +1432,15 @@ public abstract class WebDAVMethod
* *
* @param rootNodeRef the acting webdav root * @param rootNodeRef the acting webdav root
* @param path the path to search for * @param path the path to search for
* @param servletPath the base servlet path, which may be null or empty
* @return Return the file info for the path * @return Return the file info for the path
* @throws FileNotFoundException if the path doesn't refer to a valid node * @throws FileNotFoundException if the path doesn't refer to a valid node
*/ */
protected FileInfo getNodeForPath(NodeRef rootNodeRef, String path, String servletPath) throws FileNotFoundException protected FileInfo getNodeForPath(NodeRef rootNodeRef, String path) throws FileNotFoundException
{ {
return getDAVHelper().getNodeForPath(rootNodeRef, path, servletPath); return getDAVHelper().getNodeForPath(rootNodeRef, path);
} }
/** /** * Returns a URL that could be used to access the given path.
* Returns a URL that could be used to access the given path.
* *
* @param request HttpServletRequest * @param request HttpServletRequest
* @param path the path to search for * @param path the path to search for