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
*
@@ -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.
String siteId = getSiteId();
NodeRef deletedNodeRef = fileInfo.getNodeRef();
FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), path, getServletPath());
FileInfo parentFile = getDAVHelper().getParentNodeForPath(getRootNodeRef(), path);
// Delete it
fileFolderService.delete(deletedNodeRef);
// 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
*
@@ -163,12 +163,11 @@ public class GetMethod extends WebDAVMethod
FileFolderService fileFolderService = getFileFolderService();
NodeRef rootNodeRef = getRootNodeRef();
String path = getPath();
String servletPath = getServletPath();
FileInfo nodeInfo = null;
try
{
nodeInfo = getDAVHelper().getNodeForPath(rootNodeRef, path, servletPath);
nodeInfo = getDAVHelper().getNodeForPath(rootNodeRef, path);
}
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
*
@@ -228,7 +228,7 @@ public class LockMethod extends WebDAVMethod
try
{
// Check if the path exists
lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), m_request.getServletPath());
lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
}
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
*
@@ -81,7 +81,7 @@ public class MkcolMethod extends WebDAVMethod implements ActivityPostProducer
// see if it exists
try
{
getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath());
getDAVHelper().getNodeForPath(getRootNodeRef(), getPath());
// already exists
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);
try
{
FileInfo parentFileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), parentPath, m_request.getServletPath());
FileInfo parentFileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), parentPath);
parentNodeRef = parentFileInfo.getNodeRef();
}
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
*
@@ -63,7 +63,6 @@ public class MoveMethod extends HierarchicalMethod
protected final void executeImpl() throws WebDAVServerException, Exception
{
NodeRef rootNodeRef = getRootNodeRef();
String servletPath = getServletPath();
// Debug
if (logger.isDebugEnabled())
{
@@ -75,14 +74,14 @@ public class MoveMethod extends HierarchicalMethod
FileInfo sourceInfo = null;
try
{
sourceInfo = getDAVHelper().getNodeForPath(rootNodeRef, sourcePath, servletPath);
sourceInfo = getDAVHelper().getNodeForPath(rootNodeRef, sourcePath);
}
catch (FileNotFoundException e)
{
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
String destPath = getDestinationPath();
@@ -93,7 +92,7 @@ public class MoveMethod extends HierarchicalMethod
{
destPath = destPath.substring(0, destPath.length() - 1);
}
destParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, destPath, servletPath);
destParentInfo = getDAVHelper().getParentNodeForPath(rootNodeRef, destPath);
}
catch (FileNotFoundException e)
{
@@ -109,7 +108,7 @@ public class MoveMethod extends HierarchicalMethod
boolean destExists = false;
try
{
destInfo = getDAVHelper().getNodeForPath(rootNodeRef, destPath, servletPath);
destInfo = getDAVHelper().getNodeForPath(rootNodeRef, destPath);
if (!destInfo.getNodeRef().equals(sourceInfo.getNodeRef()))
{
// 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
*
@@ -87,7 +87,7 @@ public class OptionsMethod extends WebDAVMethod
{
try
{
FileInfo fileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath());
FileInfo fileInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath());
return fileInfo.isFolder();
}
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
*
@@ -187,7 +187,7 @@ public class PropFindMethod extends WebDAVMethod
try
{
// Check that the path exists
pathNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), m_strPath, m_request.getServletPath());
pathNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), m_strPath);
}
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
*
@@ -62,7 +62,7 @@ public class PropPatchMethod extends PropFindMethod
try
{
// Check that the path exists
pathNodeInfo = getNodeForPath(getRootNodeRef(), m_strPath, m_request.getServletPath());
pathNodeInfo = getNodeForPath(getRootNodeRef(), m_strPath);
}
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
*
@@ -111,7 +111,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
FileInfo contentNodeInfo = null;
try
{
contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), getServletPath());
contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
checkNode(contentNodeInfo);
final NodeRef nodeRef = contentNodeInfo.getNodeRef();
if (getNodeService().hasAspect(contentNodeInfo.getNodeRef(), ContentModel.ASPECT_WEBDAV_NO_CONTENT))
@@ -157,7 +157,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
LockInfo nodeLockInfo = null;
try
{
contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), getServletPath());
contentNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
// make sure that we are not trying to use a folder
if (contentNodeInfo.isFolder())
{
@@ -180,7 +180,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
String[] paths = getDAVHelper().splitPath(getPath());
try
{
FileInfo parentNodeInfo = getNodeForPath(getRootNodeRef(), paths[0], getServletPath());
FileInfo parentNodeInfo = getNodeForPath(getRootNodeRef(), paths[0]);
// create file
contentNodeInfo = fileFolderService.create(parentNodeInfo.getNodeRef(), paths[1], ContentModel.TYPE_CONTENT);
created = true;
@@ -390,7 +390,7 @@ public class PutMethod extends WebDAVMethod implements ActivityPostProducer
FileInfo contentNodeInfo = null;
try
{
contentNodeInfo = getNodeForPath(getRootNodeRef(), path, getServletPath());
contentNodeInfo = getNodeForPath(getRootNodeRef(), path);
NodeRef nodeRef = contentNodeInfo.getNodeRef();
// Don't post activity data for hidden files, resource forks etc.
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
*
@@ -123,7 +123,7 @@ public class UnlockMethod extends WebDAVMethod
FileInfo lockNodeInfo = null;
try
{
lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), getServletPath());
lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath());
}
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
*
@@ -464,12 +464,11 @@ public class WebDAVHelper
*
* @param rootNodeRef the acting webdav root
* @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
* @throws FileNotFoundException
* 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)
{
@@ -482,23 +481,11 @@ public class WebDAVHelper
FileFolderService fileFolderService = getFileFolderService();
// 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);
}
// 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
List<String> splitPath = splitAllPaths(path);
@@ -511,13 +498,12 @@ public class WebDAVHelper
logger.debug("Fetched node for path: \n" +
" root: " + rootNodeRef + "\n" +
" path: " + path + "\n" +
" servlet path: " + servletPath + "\n" +
" result: " + 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)
{
@@ -529,7 +515,7 @@ public class WebDAVHelper
}
// shorten the 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;
try
{
FileInfo fileInfo = getNodeForPath(method.getRootNodeRef(), method.getPath(), method.getServletPath());
FileInfo fileInfo = getNodeForPath(method.getRootNodeRef(), method.getPath());
SiteInfo siteInfo = siteService.getSite(fileInfo.getNodeRef());
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
*
@@ -1432,17 +1432,15 @@ public abstract class WebDAVMethod
*
* @param rootNodeRef the acting webdav root
* @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
* @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 path the path to search for