Merged DEV/TEMPORARY to HEAD

23222: ALF-3707: Alfresco Sharepoint protocol and Office 2010 issue
      Problem related to incorrect response of VTI WebDAV Lock method for Windows 7 clients was fixed. 
      Requested refactoring was done:
      - Code duplication was removed from VTI Lock, Unlock, PropPatch methods. 
      - Changes related to inheritance were added to original WebDAV methods.
      - VTI Propfind implementation was detached from original WebDAV PropFind
      - Logging was added for empty catch blocks 
      - Unused import was removed
      - Unnecessary empty catch blocks were removed


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@23225 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2010-10-22 11:21:40 +00:00
parent 61079d3769
commit ea8e5bdfc6
4 changed files with 87 additions and 15 deletions

View File

@@ -33,6 +33,7 @@ import org.alfresco.service.cmr.model.FileFolderUtil;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException; import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.dom4j.io.XMLWriter; import org.dom4j.io.XMLWriter;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@@ -221,7 +222,7 @@ public class LockMethod extends WebDAVMethod
try try
{ {
// Check if the path exists // Check if the path exists
lockNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), m_request.getServletPath()); lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), m_request.getServletPath());
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
@@ -252,7 +253,7 @@ public class LockMethod extends WebDAVMethod
} }
// create the file // create the file
lockNodeInfo = fileFolderService.create(dirInfo.getNodeRef(), splitPath[1], ContentModel.TYPE_CONTENT); lockNodeInfo = createNode(dirInfo.getNodeRef(), splitPath[1], ContentModel.TYPE_CONTENT);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -293,6 +294,20 @@ public class LockMethod extends WebDAVMethod
generateResponse(lockNodeInfo.getNodeRef(), userName); generateResponse(lockNodeInfo.getNodeRef(), userName);
} }
/**
* Create a new node
*
* @param parentNodeRef the parent node.
* @param name the name of the node
* @param typeQName the type to create
* @return Returns the new node's file information
*
*/
protected FileInfo createNode(NodeRef parentNodeRef, String name, QName typeQName)
{
return getFileFolderService().create(parentNodeRef, name, ContentModel.TYPE_CONTENT);
}
/** /**
* Create a new lock * Create a new lock
* *
@@ -400,10 +415,9 @@ public class LockMethod extends WebDAVMethod
} }
// Send the XML back to the client // Send the XML back to the client
xml.flush(); flushXML(xml);
} }
/** /**
* Generates a list of namespace declarations for the response * Generates a list of namespace declarations for the response
*/ */

View File

@@ -54,7 +54,7 @@ public class PropPatchMethod extends PropFindMethod
try try
{ {
// Check that the path exists // Check that the path exists
pathNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), m_strPath, m_request.getServletPath()); pathNodeInfo = getNodeForPath(getRootNodeRef(), m_strPath, m_request.getServletPath());
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
@@ -95,7 +95,7 @@ public class PropPatchMethod extends PropFindMethod
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_MULTI_STATUS, WebDAV.XML_NS_MULTI_STATUS); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_MULTI_STATUS, WebDAV.XML_NS_MULTI_STATUS);
// Send remaining data // Send remaining data
xml.flush(); flushXML(xml);
} }
/** /**
@@ -216,7 +216,7 @@ public class PropPatchMethod extends PropFindMethod
getDAVHelper().getNullAttributes()); getDAVHelper().getNullAttributes());
// Build the href string for the current node // Build the href string for the current node
String strHRef = WebDAV.getURLForPath(m_request, path, isFolder); String strHRef = getURLForPath(m_request, path, isFolder);
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_HREF, WebDAV.XML_NS_HREF, getDAVHelper().getNullAttributes()); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_HREF, WebDAV.XML_NS_HREF, getDAVHelper().getNullAttributes());
xml.write(strHRef); xml.write(strHRef);

View File

@@ -117,7 +117,7 @@ public class UnlockMethod extends WebDAVMethod
FileInfo lockNodeInfo = null; FileInfo lockNodeInfo = null;
try try
{ {
lockNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), getPath(), getServletPath()); lockNodeInfo = getNodeForPath(getRootNodeRef(), getPath(), getServletPath());
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {

View File

@@ -48,6 +48,7 @@ import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockStatus; import org.alfresco.service.cmr.lock.LockStatus;
import org.alfresco.service.cmr.model.FileFolderService; import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.MimetypeService; import org.alfresco.service.cmr.repository.MimetypeService;
@@ -663,7 +664,7 @@ public abstract class WebDAVMethod
* *
* @return String * @return String
*/ */
protected final String getPath() protected String getPath()
{ {
return m_strPath; return m_strPath;
} }
@@ -674,7 +675,7 @@ public abstract class WebDAVMethod
* @return XMLWriter * @return XMLWriter
* @exception IOException * @exception IOException
*/ */
protected final XMLWriter createXMLWriter() throws IOException protected XMLWriter createXMLWriter() throws IOException
{ {
// Check if debug output or XML pretty printing is enabled // Check if debug output or XML pretty printing is enabled
@@ -1142,11 +1143,68 @@ public abstract class WebDAVMethod
} }
} }
/**
* Get the file info for the given paths
*
* @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
{
return getDAVHelper().getNodeForPath(rootNodeRef, path, servletPath);
}
/**
* Returns a URL that could be used to access the given path.
*
* @param request HttpServletRequest
* @param path the path to search for
* @param isFolder indicates file or folder is requested
* @return URL that could be used to access the given path
*/
protected String getURLForPath(HttpServletRequest request, String path, boolean isFolder)
{
return WebDAV.getURLForPath(request, path, isFolder);
}
/**
* Flushs a XML Writer.
*
* @param xml XMLWriter that should be flushed
*/
protected void flushXML(XMLWriter xml) throws IOException
{
xml.flush();
}
/**
* Returns a working copy of node for current user.
*
* @param nodeRef node reference
* @return Returns the working copy's file information
*/
protected FileInfo getWorkingCopy(NodeRef nodeRef)
{
FileInfo result = null;
NodeRef workingCopy = getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(nodeRef);
if (workingCopy != null)
{
String workingCopyOwner = getNodeService().getProperty(workingCopy, ContentModel.PROP_WORKING_COPY_OWNER).toString();
if (workingCopyOwner.equals(getAuthenticationService().getCurrentUserName()))
{
result = getFileFolderService().getFileInfo(workingCopy);
}
}
return result;
}
/** /**
* Class used for storing conditions which comes with "If" header of the request * Class used for storing conditions which comes with "If" header of the request
* *
* @author ivanry * @author ivanry
*
*/ */
protected class Condition protected class Condition
{ {