mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
43386: ALF-13091: Prevent bean post processor propagation to child application contexts. Remove Jsr250BeanPostPorcessor from the CXF configuration, to prevent strange interaction with component scanning. 43402: Merged DEV to V4.1-BUG-FIX 43330: ALF-16073: Share forms renders is slow when using sets. Optimize performance for fieldsVisibleInAnyMode populating in getFields and FormField obtaining in getVisibleFieldNamesFor. 43412: ALF-16680 ImageMagick exit code 255 is not seen as an error 43420: ALF-16627 SOLR indexing does not provide TransformationOption when converting content to plain text for indexing 43452: Fix for ALF-16296 - On site customization page, when a page containing apostrophe (') is renamed, a backslash (\) is added to the name 43453: Fix for ALF-16105 - Disabled 'Follow' feature does not disable it for existing users 43462: ALF-16715 : Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.3) 43461: ALF-16713 Cannot disable metadata extractors 43464: ALF-16715 : Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.3) 43463: ALF-16713 Cannot disable metadata extractors - fix test failures - none set mimetypeService 43471: Fix for ALF-16542 - Web application context for the onlineEditUrl variable is hard-coded to alfresco: Merged BRANCHES/DEV/CLOUD1_SP to BRANCHES/DEV/V4.1-BUG-FIX 40565: CLOUD-23: core changes to allow overriding of "edit online" button's URL generation. 43475: Fix for ALF-15859 - UploadContentServlet servlet /alfresco/upload can update the content, mime type and encoding but not the locale 43476: Merged DEV to V4.1-BUG-FIX 43401 : ALF-16587 GreenMail IMAP server does not clean up session handlers - memory leak 43478: MNT-181: Now WebDAV will ALWAYS preserve the original metadata and versions of ANY node that is temporarily 'moved out' in ANY kind of 'shuffle' operation - To make the source node temporarily invisible to WebDAV the client specific HIDDEN aspect features are used - WebDAVHelper.isRenameShuffle() method introduced, to parallel ALF-3856 CIFS fix and using similar system.webdav.renameShufflePattern global property to detect the start of a shuffle - WebDAVHelper converted to use proper dependency injection - CopyMethod has become a simple subclass of MoveMethod as all the hidden aspect munging is done by it - DeleteMethod now preserves hidden nodes - PropFindMethod now ignores hidden nodes - Listing methods will hide hidden nodes from WebDAV 43483: MNT-181: Corrected typo 43498: Fix for ALF-16648 - Alfresco Enterprise artifacts in artifacts.alfresco.com do not provide POM files / dependencies declarations: Merged HEAD to V4.1-BUG-FIX (4.1.2) 43380: -- added site content for alfresco-platform-distribution POM 43379: -- added site documentation for alfresco-platform-distribution POM 43378: -- added site documentation for alfresco-platform-distribution POM -- deployed site for 4.2.b Community at https://artifacts.alfresco.com/nexus/content/repositories/alfresco-docs/alfresco-platform-distribution/latest/index.html -- created repository for Enterprise docs and added url in the appropriate edition properties 43273: Use property to define POI version 42966: ALF-14353 - Added platform distribution POM to standard maven-deploy procedure 42965: ALF-14353 - added alfresco-platform-distribution to provide a Maven release descriptor (dependencyManagement) per each Community / Enterprise release -- moved maven-ant-tasks not to be in the runtime lib -- added platform distribution pom in the SDK folder -- updated maven.xml to deploy filter and deploy the appropriate platform-distribution POM per each releae -- in maven.xml moved configure-release and configure-snapshot goals to maven-env-prerequisites -- updated sdk readme to explain the presence of alfresco-platform-distribution POM 42912: -- updated README header on the POM specifying it's NOT usable to build Alfresco -- make a clear reference to the POMs that get deployed by pom-experimental.xml being usable for development 42842: ALF-14353: Fix artifactId alfresco-jlan -> alfresco-jlan-embed 41883: ALF-14353 - fixed multiple Maven build issues. Now mvn clean install -f pom-experimental.xml works fine. Also deployed Spring Surf 1.2.0-SNAPSHOT so proper Surf version is retrieved 41882: added pre-requisites to build POMs successfully with mvn clean install -f pom-experimental.xml 43499: Upgrade version in POM files to 4.1.3-SNAPSHOT 43520: ALF-16694 POI becoming responsiveness and causing jvm to freeze for a while with certain XLS (fraction formats) - Patched POI to: - limit the length of fractions to four digits (more than that takes too long to process) e.g. "# #/#####" is too long and will be reduced to "# #/####" which still takes about a second! - handle the -ve fraction format part (i.e. n in p;n;z), so its length is not interpret as part of the fraction format of the +ve fraction part. - handle custom formats a bit better (strip them) rather than interpret the text length as part of the fraction format - handle -ve fractions (just did not work) - limitations: - custom text gets stripped (still better than before) - formats that have p (+ve) and n (-ve) parts must include a fraction format in each part. Otherwise +ve and -ve values are not formatted as a fraction (still better than before) 43523: MNT-181: Corrections - WebDAVLockService.unlock() made 'harmless' to call on already-unlocked nodes - Delete method hides rather than deletes versioned nodes and working copes in case it is called by OSX Finder during a 'replace' operation 43524: MNT-181: Correction - PutMethod now 'unhides' hidden nodes and behaves as though it created them 43541: Merged DEV to V4.1-BUG-FIX 43536: ALF-16200: WQS delete fails to publish to live projects onDeleteNode behavior The condition of "if" operator was modified. Now "if" operator evaluate to true if least one of the nodesToTransfer or nodesToRemoveOnTransfer sets is not empty. beforeDeleteNode() methods were updated for check for the ASPECT_PENDING_DELETE aspect on the node. enqueueRemovedNodes() call was moved from onDeleteNode() into beforeDeleteNode(). These fixes allow to automatically update the sites published to (i.e. live projects) to include the removal of the file and removal of file from any collection (asset list) when a content was deleted from an editorial project. 43542: Fix for ALF-16618 - ScriptableHashMap does not have hasOwnProperty method 43555: Fix for ALF-16494 - site collaborator has rights to modify comments made by another user. 43556: ALF-15859: Prevent NPE on upload without NodeRef 43558: ALF-16694 POI becoming irresponsive and causing jvm to freeze with XLS that includes fraction formats - Original jar did not get removed in previous commit << NO NEED TO MERGE TO CLOUD1-BUG-FIX as there was a tree conflict and the original jar was removed. >> 43570: MNT-181: More corrections researched by Valery - Don't treat all moves to temporary locations as copies - just those from non-temporary locations. Avoids initial upload leaving lots of hidden files around. - Only copy the content, not the whole node including aspects to avoid versioning temporary files! - Don't version on changes to sys:clientVisibilityMask - avoids 'double versioning' - Recognize Mac .TemporaryItems folder and ._ files as temporary 43575: Fix for ALF-9317 - Links: Delete Link button in Selected Items menu is available for Consumer, Contributor and Collaborator 43577: Upgrade POM files after following changes: 43401: ALF-16587 patch greenmail 43520: ALF-16694 Uprade POI and patch it 43584: Merged V4.1 to V4.1-BUG-FIX <<Record Only>> 43582: Merged V4.1-BUG-FIX to V4.1 (4.1.2) 43402: Merged DEV to V4.1-BUG-FIX 43330: ALF-16073: Share forms renders is slow when using sets. Optimize performance for fieldsVisibleInAnyMode populating in getFields and FormField obtaining in getVisibleFieldNamesFor. 43557: Merged V4.1-BUG-FIX to V4.1 43555: Fix for ALF-16494 - site collaborator has rights to modify comments made by another user. 43586: MNT-181: Final correction researched by Valery - Corrected system.webdav.renameShufflePattern so that it matches .TemporaryItems folder and ._ files as a full match 43591: ALF-16772: If the WebDAV path of a document exceeds 255 characters, documents opened in MSOffice cannot be saved back - Interpret null nodeLockToken as not locked. 43594: Merged DEV to V4.1-BUG-FIX 43540: ALF-12425: Can't launch activiti workflow console from Share when external / ntlm / kerberos authentication is used. New webscript that redirects to activiti admin console with URL holding current ticket. The webscript resides below wcs and allows to use alfresco connector in Share. 43562: ALF-12425: Can't launch activiti workflow console from Share when external / ntlm / kerberos authentication is used. Activiti admin console webscript that allows admin console to be invoked behind wcs authentication. 43595: Merged V4.1 to V4.1-BUG-FIX 43376: Merged DEV to V4.1 43339: ALF-16590 : java.lang.IllegalArgumentException while initiating In-Place import FilesystemContentDataFactory#contentIsInStore method was modified. Now files' absolute paths are compared. 43390: ALF-15856: Test org.alfresco.repo.node.NodeServiceTest does not finish on DB2 - Now inner-nested retrying transaction in testConcurrentArchive passes its exception straight through to the outer transaction, which unwraps and retries it if necessary 43397: ALF-16021: RuleServiceImplTest never ends on DB2 - Added endTransaction() call so that testDeleteSpaceWithExecuteScriptRule() doesn't hang indefinitely waiting for the outer transaction to complete 43398: ALF-15856: Test org.alfresco.repo.node.NodeServiceTest does not finish on DB2 - Now inner-nested retrying transaction runs in its own thread and we don't wait forever for it 43404: ALF-16666: IMAP subsystem startup causes Tomcat crash - Stopped IMAP subsystem from depending on itself by using private rather than public IMapService! 43408: Fixed latest DB2 hangs for Samuel (concurrent nested transactions) 43424: Fixed latest DB2 hang for Samuel (concurrent nested transactions) 43426: ALF-16692: Merged HEAD to V4.1 (with corrections) 43425: Fixes issue with YUI SWF files (see: IT-9441) 43450: Possible fix for workflow tests on DB2 - retrying txns where necessary 43484: ALF-16702: Restored missing index in DB2 schema reference 43596: Merged V4.1 to V4.1-BUG-FIX (RECORD ONLY) 43589: Merged V4.1-BUG-FIX to V4.1 43575: Fix for ALF-9317 - Links: Delete Link button in Selected Items menu is available for Consumer, Contributor and Collaborator git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@43601 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
971 lines
38 KiB
Java
971 lines
38 KiB
Java
/*
|
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
*
|
|
* This file is part of Alfresco
|
|
*
|
|
* Alfresco is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* Alfresco is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package org.alfresco.repo.webdav;
|
|
|
|
import java.io.IOException;
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import org.alfresco.error.AlfrescoRuntimeException;
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.SessionUser;
|
|
import org.alfresco.repo.webdav.auth.AuthenticationFilter;
|
|
import org.alfresco.service.cmr.model.FileFolderService;
|
|
import org.alfresco.service.cmr.model.FileInfo;
|
|
import org.alfresco.service.cmr.model.FileNotFoundException;
|
|
import org.alfresco.service.cmr.repository.ContentData;
|
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
|
import org.alfresco.service.cmr.repository.datatype.TypeConverter;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.dom4j.DocumentHelper;
|
|
import org.dom4j.io.OutputFormat;
|
|
import org.dom4j.io.XMLWriter;
|
|
import org.w3c.dom.Document;
|
|
import org.w3c.dom.Element;
|
|
import org.w3c.dom.Node;
|
|
import org.w3c.dom.NodeList;
|
|
import org.xml.sax.Attributes;
|
|
import org.xml.sax.SAXException;
|
|
import org.xml.sax.helpers.AttributesImpl;
|
|
|
|
/**
|
|
* Implements the WebDAV PROPFIND method
|
|
*
|
|
* @author Gavin Cornwell
|
|
*/
|
|
public class PropFindMethod extends WebDAVMethod
|
|
{
|
|
// Request types
|
|
protected static final int GET_ALL_PROPS = 0;
|
|
protected static final int GET_NAMED_PROPS = 1;
|
|
protected static final int FIND_PROPS = 2;
|
|
|
|
// Find request type
|
|
protected int m_mode = GET_ALL_PROPS;
|
|
|
|
// Requested properties
|
|
protected ArrayList<WebDAVProperty> m_properties = null;
|
|
|
|
// Available namespaces list
|
|
protected HashMap<String, String> m_namespaces = null;
|
|
|
|
/**
|
|
* Default constructor
|
|
*/
|
|
public PropFindMethod()
|
|
{
|
|
m_namespaces = new HashMap<String, String>();
|
|
}
|
|
|
|
/**
|
|
* Return the find mode
|
|
*
|
|
* @return int
|
|
*/
|
|
public final int getMode()
|
|
{
|
|
return m_mode;
|
|
}
|
|
|
|
/**
|
|
* Parse the request headers
|
|
*
|
|
* @exception WebDAVServerException
|
|
*/
|
|
protected void parseRequestHeaders() throws WebDAVServerException
|
|
{
|
|
// Store the Depth header as this is used by several WebDAV methods
|
|
|
|
parseDepthHeader();
|
|
|
|
}
|
|
|
|
/**
|
|
* Parse the request body
|
|
*
|
|
* @exception WebDAVServerException
|
|
*/
|
|
protected void parseRequestBody() throws WebDAVServerException
|
|
{
|
|
Document body = getRequestBodyAsDocument();
|
|
if (body != null)
|
|
{
|
|
Element rootElement = body.getDocumentElement();
|
|
NodeList childList = rootElement.getChildNodes();
|
|
Node node = null;
|
|
|
|
for (int i = 0; i < childList.getLength(); i++)
|
|
{
|
|
Node currentNode = childList.item(i);
|
|
switch (currentNode.getNodeType())
|
|
{
|
|
case Node.TEXT_NODE:
|
|
break;
|
|
case Node.ELEMENT_NODE:
|
|
if (currentNode.getNodeName().endsWith(WebDAV.XML_ALLPROP))
|
|
{
|
|
m_mode = GET_ALL_PROPS;
|
|
}
|
|
else if (currentNode.getNodeName().endsWith(WebDAV.XML_PROP))
|
|
{
|
|
m_mode = GET_NAMED_PROPS;
|
|
node = currentNode;
|
|
}
|
|
else if (currentNode.getNodeName().endsWith(WebDAV.XML_PROPNAME))
|
|
{
|
|
m_mode = FIND_PROPS;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_mode == GET_NAMED_PROPS)
|
|
{
|
|
m_properties = new ArrayList<WebDAVProperty>();
|
|
childList = node.getChildNodes();
|
|
|
|
for (int i = 0; i < childList.getLength(); i++)
|
|
{
|
|
Node currentNode = childList.item(i);
|
|
switch (currentNode.getNodeType())
|
|
{
|
|
case Node.TEXT_NODE:
|
|
break;
|
|
case Node.ELEMENT_NODE:
|
|
m_properties.add(createProperty(currentNode));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return Returns <tt>true</tt> always
|
|
*/
|
|
@Override
|
|
protected boolean isReadOnly()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Execute the main WebDAV request processing
|
|
*
|
|
* @exception WebDAVServerException
|
|
*/
|
|
protected void executeImpl() throws WebDAVServerException, Exception
|
|
{
|
|
m_response.setStatus(WebDAV.WEBDAV_SC_MULTI_STATUS);
|
|
|
|
FileFolderService fileFolderService = getFileFolderService();
|
|
|
|
FileInfo pathNodeInfo = null;
|
|
try
|
|
{
|
|
// Check that the path exists
|
|
pathNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), m_strPath, m_request.getServletPath());
|
|
}
|
|
catch (FileNotFoundException e)
|
|
{
|
|
// The path is not valid - send a 404 error back to the client
|
|
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
|
|
}
|
|
|
|
// A node hidden during a 'shuffle' operation - send a 404 error back to the client, as some Mac clients need
|
|
// this
|
|
if (isHidden(pathNodeInfo.getNodeRef()))
|
|
{
|
|
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
|
|
}
|
|
|
|
// Set the response content type
|
|
|
|
m_response.setContentType(WebDAV.XML_CONTENT_TYPE);
|
|
|
|
// Create multistatus response
|
|
|
|
XMLWriter xml = createXMLWriter();
|
|
|
|
xml.startDocument();
|
|
|
|
String nsdec = generateNamespaceDeclarations(m_namespaces);
|
|
xml.startElement(
|
|
WebDAV.DAV_NS,
|
|
WebDAV.XML_MULTI_STATUS + nsdec,
|
|
WebDAV.XML_NS_MULTI_STATUS + nsdec,
|
|
getDAVHelper().getNullAttributes());
|
|
|
|
// Create the path for the current location in the tree
|
|
StringBuilder baseBuild = new StringBuilder(256);
|
|
baseBuild.append(getPath());
|
|
if (baseBuild.length() == 0 || baseBuild.charAt(baseBuild.length() - 1) != WebDAVHelper.PathSeperatorChar)
|
|
{
|
|
baseBuild.append(WebDAVHelper.PathSeperatorChar);
|
|
}
|
|
String basePath = baseBuild.toString();
|
|
|
|
// Output the response for the root node, depth zero
|
|
generateResponseForNode(xml, pathNodeInfo, basePath);
|
|
|
|
// If additional levels are required and the root node is a folder then recurse to the required
|
|
// level and output node details a level at a time
|
|
if (getDepth() != WebDAV.DEPTH_0 && pathNodeInfo.isFolder())
|
|
{
|
|
// Create the initial list of nodes to report
|
|
List<FileInfo> nodeInfos = new ArrayList<FileInfo>(10);
|
|
nodeInfos.add(pathNodeInfo);
|
|
|
|
int curDepth = WebDAV.DEPTH_1;
|
|
|
|
// Save the base path length
|
|
int baseLen = baseBuild.length();
|
|
|
|
// List of next level of nodes to report
|
|
List<FileInfo> nextNodeInfos = null;
|
|
if (getDepth() > WebDAV.DEPTH_1)
|
|
{
|
|
nextNodeInfos = new ArrayList<FileInfo>(10);
|
|
}
|
|
|
|
// Loop reporting each level of nodes to the requested depth
|
|
while (curDepth <= getDepth() && nodeInfos != null)
|
|
{
|
|
// Clear out the next level of nodes, if required
|
|
if (nextNodeInfos != null)
|
|
{
|
|
nextNodeInfos.clear();
|
|
}
|
|
|
|
// Output the current level of node(s), the node list should
|
|
// only contain folder nodes
|
|
|
|
for (FileInfo curNodeInfo : nodeInfos)
|
|
{
|
|
// Get the list of child nodes for the current node
|
|
List<FileInfo> childNodeInfos = fileFolderService.list(curNodeInfo.getNodeRef());
|
|
|
|
// can skip the current node if it doesn't have children
|
|
if (childNodeInfos.size() == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// Output the child node details
|
|
// Generate the base path for the current parent node
|
|
|
|
baseBuild.setLength(baseLen);
|
|
try
|
|
{
|
|
String pathSnippet = getDAVHelper().getPathFromNode(pathNodeInfo.getNodeRef(), curNodeInfo.getNodeRef());
|
|
baseBuild.append(pathSnippet);
|
|
}
|
|
catch (FileNotFoundException e)
|
|
{
|
|
// move to the next node
|
|
continue;
|
|
}
|
|
|
|
int curBaseLen = baseBuild.length();
|
|
|
|
// Output the child node details
|
|
for (FileInfo curChildInfo : childNodeInfos)
|
|
{
|
|
// Build the path for the current child node
|
|
baseBuild.setLength(curBaseLen);
|
|
|
|
baseBuild.append(curChildInfo.getName());
|
|
|
|
// Output the current child node details
|
|
generateResponseForNode(xml, curChildInfo, baseBuild.toString());
|
|
|
|
// If the child is a folder add it to the list of next level nodes
|
|
if (nextNodeInfos != null && curChildInfo.isFolder())
|
|
{
|
|
nextNodeInfos.add(curChildInfo);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update the current tree depth
|
|
curDepth++;
|
|
|
|
// Move the next level of nodes to the current node list
|
|
nodeInfos = nextNodeInfos;
|
|
}
|
|
}
|
|
|
|
// Close the outer XML element
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_MULTI_STATUS, WebDAV.XML_NS_MULTI_STATUS);
|
|
|
|
// Send remaining data
|
|
flushXML(xml);
|
|
}
|
|
|
|
@Override
|
|
protected OutputFormat getXMLOutputFormat()
|
|
{
|
|
String userAgent = m_request.getHeader("User-Agent");
|
|
return ((null != userAgent) && userAgent.toLowerCase().startsWith("microsoft-webdav-miniredir/5.1.")) ? OutputFormat.createCompactFormat() : super.getXMLOutputFormat();
|
|
|
|
}
|
|
|
|
/**
|
|
* Creates a WebDAVProperty from the given XML node
|
|
*/
|
|
protected WebDAVProperty createProperty(Node node)
|
|
{
|
|
WebDAVProperty property = null;
|
|
|
|
String strName = node.getLocalName();
|
|
String strNamespaceUri = node.getNamespaceURI();
|
|
|
|
if (WebDAV.DEFAULT_NAMESPACE_URI.equals(strNamespaceUri))
|
|
{
|
|
property = new WebDAVProperty(strName);
|
|
}
|
|
else
|
|
{
|
|
property = new WebDAVProperty(strName, strNamespaceUri, getNamespaceName(strNamespaceUri));
|
|
}
|
|
|
|
return property;
|
|
}
|
|
|
|
/**
|
|
* Retrieves the namespace name for the given namespace URI, one is
|
|
* generated if it doesn't exist
|
|
*/
|
|
private String getNamespaceName(String strNamespaceUri)
|
|
{
|
|
if (strNamespaceUri == null)
|
|
{
|
|
return null;
|
|
}
|
|
String strNamespaceName = m_namespaces.get(strNamespaceUri);
|
|
if (strNamespaceName == null)
|
|
{
|
|
strNamespaceName = "ns" + m_namespaces.size();
|
|
m_namespaces.put(strNamespaceUri, strNamespaceName);
|
|
}
|
|
|
|
return strNamespaceName;
|
|
}
|
|
|
|
/**
|
|
* Generates the required response XML for the current node
|
|
*
|
|
* @param xml XMLWriter
|
|
* @param node NodeRef
|
|
* @param path String
|
|
*/
|
|
protected void generateResponseForNode(XMLWriter xml, FileInfo nodeInfo, String path) throws Exception
|
|
{
|
|
boolean isFolder = nodeInfo.isFolder();
|
|
|
|
// Output the response block for the current node
|
|
xml.startElement(
|
|
WebDAV.DAV_NS,
|
|
WebDAV.XML_RESPONSE,
|
|
WebDAV.XML_NS_RESPONSE,
|
|
getDAVHelper().getNullAttributes());
|
|
|
|
// Build the href string for the current node
|
|
String strHRef = getURLForPath(m_request, path, isFolder);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_HREF, WebDAV.XML_NS_HREF, getDAVHelper().getNullAttributes());
|
|
xml.write(strHRef);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_HREF, WebDAV.XML_NS_HREF);
|
|
|
|
switch (m_mode)
|
|
{
|
|
case GET_NAMED_PROPS:
|
|
generateNamedPropertiesResponse(xml, nodeInfo, isFolder);
|
|
break;
|
|
case GET_ALL_PROPS:
|
|
generateAllPropertiesResponse(xml, nodeInfo, isFolder);
|
|
break;
|
|
case FIND_PROPS:
|
|
generateFindPropertiesResponse(xml, nodeInfo, isFolder);
|
|
break;
|
|
}
|
|
|
|
// Close off the response element
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_RESPONSE, WebDAV.XML_NS_RESPONSE);
|
|
}
|
|
|
|
/**
|
|
* Generates the XML response for a PROPFIND request that asks for a
|
|
* specific set of properties
|
|
*
|
|
* @param xml XMLWriter
|
|
* @param node NodeRef
|
|
* @param isDir boolean
|
|
*/
|
|
private void generateNamedPropertiesResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir) throws Exception
|
|
{
|
|
// Get the properties for the node
|
|
Map<QName, Serializable> props = nodeInfo.getProperties();
|
|
|
|
// Output the start of the properties element
|
|
Attributes nullAttr = getDAVHelper().getNullAttributes();
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr);
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr);
|
|
|
|
ArrayList<WebDAVProperty> propertiesNotFound = new ArrayList<WebDAVProperty>();
|
|
|
|
TypeConverter typeConv = DefaultTypeConverter.INSTANCE;
|
|
|
|
// Loop through the requested property list
|
|
for (WebDAVProperty property : m_properties)
|
|
{
|
|
// Get the requested property details
|
|
|
|
String propName = property.getName();
|
|
String propNamespaceUri = property.getNamespaceUri();
|
|
|
|
// Check if the property is a standard WebDAV property
|
|
|
|
Object davValue = null;
|
|
|
|
if (WebDAV.DEFAULT_NAMESPACE_URI.equals(propNamespaceUri))
|
|
{
|
|
// Check if the client is requesting lock information
|
|
if (propName.equals(WebDAV.XML_LOCK_DISCOVERY)) // && metaData.isLocked())
|
|
{
|
|
generateLockDiscoveryResponse(xml, nodeInfo, isDir);
|
|
}
|
|
else if (propName.equals(WebDAV.XML_SUPPORTED_LOCK))
|
|
{
|
|
// Output the supported lock types
|
|
writeLockTypes(xml);
|
|
}
|
|
|
|
// Check if the client is requesting the resource type
|
|
|
|
else if (propName.equals(WebDAV.XML_RESOURCE_TYPE))
|
|
{
|
|
// If the node is a folder then return as a collection type
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE, nullAttr);
|
|
if (isDir)
|
|
{
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_COLLECTION));
|
|
}
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE);
|
|
}
|
|
else if (propName.equals(WebDAV.XML_DISPLAYNAME))
|
|
{
|
|
// Get the node name
|
|
if (getRootNodeRef().equals(nodeInfo.getNodeRef()))
|
|
{
|
|
// Output an empty name for the root node
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SOURCE));
|
|
}
|
|
else
|
|
{
|
|
// Get the node name
|
|
davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_DISPLAYNAME);
|
|
|
|
// Output the node name
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME, nullAttr);
|
|
if (davValue != null)
|
|
{
|
|
String name = typeConv.convert(String.class, davValue);
|
|
if (name == null || name.length() == 0)
|
|
{
|
|
logger.error("WebDAV name is null, value=" + davValue.getClass().getName() + ", node=" + nodeInfo.getNodeRef());
|
|
}
|
|
xml.write(name);
|
|
}
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME);
|
|
}
|
|
}
|
|
else if (propName.equals(WebDAV.XML_SOURCE))
|
|
{
|
|
// NOTE: source is always a no content element in our
|
|
// implementation
|
|
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SOURCE));
|
|
}
|
|
else if (propName.equals(WebDAV.XML_GET_LAST_MODIFIED))
|
|
{
|
|
// Get the modifed date/time
|
|
|
|
davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_LAST_MODIFIED);
|
|
|
|
// Output the last modified date of the node
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED,
|
|
nullAttr);
|
|
if (davValue != null)
|
|
xml.write(WebDAV.formatModifiedDate(typeConv.convert(Date.class, davValue)));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED);
|
|
}
|
|
else if (propName.equals(WebDAV.XML_GET_CONTENT_LANGUAGE) && !isDir)
|
|
{
|
|
// Get the content language
|
|
// TODO:
|
|
// Output the content language
|
|
xml.startElement(
|
|
WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE,
|
|
WebDAV.XML_NS_GET_CONTENT_LANGUAGE, nullAttr);
|
|
// TODO:
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE, WebDAV.XML_NS_GET_CONTENT_LANGUAGE);
|
|
}
|
|
else if (propName.equals(WebDAV.XML_GET_CONTENT_TYPE) && !isDir)
|
|
{
|
|
// Get the content type
|
|
davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_CONTENT_TYPE);
|
|
|
|
// Output the content type
|
|
xml.startElement(
|
|
WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE,
|
|
WebDAV.XML_NS_GET_CONTENT_TYPE, nullAttr);
|
|
if (davValue != null)
|
|
xml.write(typeConv.convert(String.class, davValue));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE, WebDAV.XML_NS_GET_CONTENT_TYPE);
|
|
}
|
|
else if (propName.equals(WebDAV.XML_GET_ETAG) && !isDir)
|
|
{
|
|
// Output the etag
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG, nullAttr);
|
|
xml.write(getDAVHelper().makeETag(nodeInfo));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG);
|
|
}
|
|
else if (propName.equals(WebDAV.XML_GET_CONTENT_LENGTH))
|
|
{
|
|
// Get the content length, if it's not a folder
|
|
long len = 0;
|
|
|
|
if (!isDir)
|
|
{
|
|
ContentData contentData = (ContentData) props.get(ContentModel.PROP_CONTENT);
|
|
if (contentData != null)
|
|
len = contentData.getSize();
|
|
}
|
|
|
|
// Output the content length
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH,
|
|
nullAttr);
|
|
xml.write("" + len);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH);
|
|
}
|
|
else if (propName.equals(WebDAV.XML_CREATION_DATE))
|
|
{
|
|
// Get the creation date
|
|
davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_CREATION_DATE);
|
|
|
|
// Output the creation date
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE, nullAttr);
|
|
if (davValue != null)
|
|
xml.write(WebDAV.formatCreationDate(typeConv.convert(Date.class, davValue)));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE);
|
|
}
|
|
else if ( propName.equals( WebDAV.XML_ALF_AUTHTICKET))
|
|
{
|
|
// Get the users authentication ticket
|
|
|
|
SessionUser davUser = (SessionUser) m_request.getSession().getAttribute( AuthenticationFilter.AUTHENTICATION_USER);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET, nullAttr);
|
|
if ( davUser != null)
|
|
xml.write( davUser.getTicket());
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET);
|
|
}
|
|
else
|
|
{
|
|
// Could not map the requested property to an Alfresco property
|
|
if (property.getName().equals(WebDAV.XML_HREF) == false)
|
|
propertiesNotFound.add(property);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Look in the custom properties
|
|
|
|
// TODO: Custom properties lookup
|
|
// String qualifiedName = propNamespaceUri + WebDAV.NAMESPACE_SEPARATOR + propName;
|
|
|
|
String value = (String) nodeInfo.getProperties().get(property.createQName());
|
|
if (value == null)
|
|
{
|
|
propertiesNotFound.add(property);
|
|
}
|
|
else
|
|
{
|
|
if (property.hasNamespaceName())
|
|
{
|
|
xml.startElement(property.getNamespaceName(), property.getName(), property.getNamespaceName() + WebDAV.NAMESPACE_SEPARATOR + property.getName(), nullAttr);
|
|
xml.write(value);
|
|
xml.endElement(property.getNamespaceName(), property.getName(), property.getNamespaceName() + WebDAV.NAMESPACE_SEPARATOR + property.getName());
|
|
}
|
|
else
|
|
{
|
|
xml.startElement("", property.getName(), property.getName(), nullAttr);
|
|
xml.write(value);
|
|
xml.endElement("", property.getName(), property.getName());
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
// Close off the successful part of the response
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr);
|
|
xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_OK + " " + WebDAV.SC_OK_DESC);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS);
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT);
|
|
|
|
// If some of the requested properties were not found return another
|
|
// status section
|
|
|
|
if (propertiesNotFound.size() > 0)
|
|
{
|
|
// Start the second status section
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr);
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr);
|
|
|
|
// Loop through the list of properties that were not found
|
|
|
|
for (WebDAVProperty property : propertiesNotFound)
|
|
{
|
|
// Output the property not found status block
|
|
|
|
String propName = property.getName();
|
|
String propNamespaceName = property.getNamespaceName();
|
|
String propQName = propName;
|
|
if (propNamespaceName != null && propNamespaceName.length() > 0)
|
|
propQName = propNamespaceName + ":" + propName;
|
|
|
|
xml.write(DocumentHelper.createElement(propQName));
|
|
}
|
|
|
|
// Close the unsuccessful part of the response
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr);
|
|
xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_NOT_FOUND + " " + WebDAV.SC_NOT_FOUND_DESC);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS);
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Generates the XML response for a PROPFIND request that asks for all known
|
|
* properties
|
|
*
|
|
* @param xml XMLWriter
|
|
* @param node NodeRef
|
|
* @param isDir boolean
|
|
*/
|
|
protected void generateAllPropertiesResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir) throws Exception
|
|
{
|
|
// Get the properties for the node
|
|
|
|
Map<QName, Serializable> props = nodeInfo.getProperties();
|
|
|
|
// Output the start of the properties element
|
|
|
|
Attributes nullAttr = getDAVHelper().getNullAttributes();
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr);
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr);
|
|
|
|
// Generate a lock status report, if locked
|
|
|
|
generateLockDiscoveryResponse(xml, nodeInfo, isDir);
|
|
|
|
// Output the supported lock types
|
|
|
|
writeLockTypes(xml);
|
|
|
|
// If the node is a folder then return as a collection type
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE, nullAttr);
|
|
if (isDir)
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_COLLECTION));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE);
|
|
|
|
// Get the node name
|
|
|
|
Object davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_DISPLAYNAME);
|
|
|
|
TypeConverter typeConv = DefaultTypeConverter.INSTANCE;
|
|
|
|
// Output the node name
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME, nullAttr);
|
|
if (davValue != null)
|
|
{
|
|
String name = typeConv.convert(String.class, davValue);
|
|
if (name == null || name.length() == 0)
|
|
{
|
|
logger.error("WebDAV name is null, value=" + davValue.getClass().getName() + ", node=" + nodeInfo.getNodeRef());
|
|
}
|
|
xml.write(name);
|
|
}
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME);
|
|
|
|
// Output the source
|
|
//
|
|
// NOTE: source is always a no content element in our implementation
|
|
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SOURCE));
|
|
|
|
// Get the creation date
|
|
|
|
davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_CREATION_DATE);
|
|
|
|
// Output the creation date
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE, nullAttr);
|
|
if (davValue != null)
|
|
xml.write(WebDAV.formatCreationDate(typeConv.convert(Date.class, davValue)));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE);
|
|
|
|
// Get the modifed date/time
|
|
|
|
davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_LAST_MODIFIED);
|
|
|
|
// Output the last modified date of the node
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED, nullAttr);
|
|
if (davValue != null)
|
|
xml.write(WebDAV.formatModifiedDate(typeConv.convert(Date.class, davValue)));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED);
|
|
|
|
// For a file node output the content language and content type
|
|
|
|
if (isDir == false)
|
|
{
|
|
// Get the content language
|
|
|
|
// TODO:
|
|
// Output the content language
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE, WebDAV.XML_NS_GET_CONTENT_LANGUAGE,
|
|
nullAttr);
|
|
// TODO:
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE, WebDAV.XML_NS_GET_CONTENT_LANGUAGE);
|
|
|
|
// Get the content type
|
|
davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_CONTENT_TYPE);
|
|
|
|
// Output the content type
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE, WebDAV.XML_NS_GET_CONTENT_TYPE, nullAttr);
|
|
if (davValue != null)
|
|
xml.write(typeConv.convert(String.class, davValue));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE, WebDAV.XML_NS_GET_CONTENT_TYPE);
|
|
|
|
// Output the etag
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG, nullAttr);
|
|
xml.write(getDAVHelper().makeETag(nodeInfo));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG);
|
|
}
|
|
|
|
// Get the content length, if it's not a folder
|
|
|
|
long len = 0;
|
|
|
|
if (isDir == false)
|
|
{
|
|
ContentData contentData = (ContentData) props.get(ContentModel.PROP_CONTENT);
|
|
if (contentData != null)
|
|
len = contentData.getSize();
|
|
}
|
|
|
|
// Output the content length
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH, nullAttr);
|
|
xml.write("" + len);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH);
|
|
|
|
// Print out all the custom properties
|
|
|
|
SessionUser davUser = (SessionUser) m_request.getSession().getAttribute( AuthenticationFilter.AUTHENTICATION_USER);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET, nullAttr);
|
|
if ( davUser != null)
|
|
xml.write( davUser.getTicket());
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET);
|
|
|
|
// Close off the response
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr);
|
|
xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_OK + " " + WebDAV.SC_OK_DESC);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS);
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT);
|
|
}
|
|
|
|
/**
|
|
* Generates the XML response for a PROPFIND request that asks for a list of
|
|
* all known properties
|
|
*
|
|
* @param xml XMLWriter
|
|
* @param node NodeRef
|
|
* @param isDir boolean
|
|
*/
|
|
protected void generateFindPropertiesResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir)
|
|
{
|
|
try
|
|
{
|
|
// Output the start of the properties element
|
|
|
|
Attributes nullAttr = getDAVHelper().getNullAttributes();
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr);
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr);
|
|
|
|
// Output the well-known properties
|
|
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_LOCK_DISCOVERY));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SUPPORTED_LOCK));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_RESOURCE_TYPE));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_DISPLAYNAME));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_LAST_MODIFIED));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_LENGTH));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_CREATION_DATE));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_ETAG));
|
|
|
|
if (isDir)
|
|
{
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_LANGUAGE));
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_TYPE));
|
|
}
|
|
|
|
// Output the custom properties
|
|
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_ALF_AUTHTICKET));
|
|
|
|
// Close off the response
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr);
|
|
xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_OK + " " + WebDAV.SC_OK_DESC);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS);
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// Convert to a runtime exception
|
|
|
|
throw new AlfrescoRuntimeException("XML processing error", ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Generates the XML response snippet showing the lock information for the
|
|
* given path
|
|
*
|
|
* @param xml XMLWriter
|
|
* @param node NodeRef
|
|
* @param isDir boolean
|
|
*/
|
|
protected void generateLockDiscoveryResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir) throws Exception
|
|
{
|
|
// Output the lock status response
|
|
|
|
LockInfo lockInfo = getNodeLockInfo(nodeInfo);
|
|
lockInfo.getRWLock().readLock().lock();
|
|
try
|
|
{
|
|
if (lockInfo.isLocked())
|
|
{
|
|
generateLockDiscoveryXML(xml, nodeInfo, lockInfo);
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
lockInfo.getRWLock().readLock().unlock();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Output the supported lock types XML element
|
|
*
|
|
* @param xml XMLWriter
|
|
*/
|
|
protected void writeLockTypes(XMLWriter xml)
|
|
{
|
|
try
|
|
{
|
|
AttributesImpl nullAttr = getDAVHelper().getNullAttributes();
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_SUPPORTED_LOCK, WebDAV.XML_NS_SUPPORTED_LOCK, nullAttr);
|
|
|
|
// Output exclusive lock
|
|
writeLock(xml, WebDAV.XML_NS_EXCLUSIVE);
|
|
// Output shared lock
|
|
writeLock(xml, WebDAV.XML_NS_SHARED);
|
|
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_SUPPORTED_LOCK, WebDAV.XML_NS_SUPPORTED_LOCK);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new AlfrescoRuntimeException("XML write error", ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Output the lockentry element of the specified type
|
|
* @param xml XMLWriter
|
|
* @param lockType lock type. Can be WebDAV.XML_NS_EXCLUSIVE or WebDAV.XML_NS_SHARED
|
|
* @param lockType lock type containing namespace
|
|
* @throws SAXException
|
|
* @throws IOException
|
|
*/
|
|
private void writeLock(XMLWriter xml, String lockType) throws SAXException, IOException
|
|
{
|
|
AttributesImpl nullAttr = getDAVHelper().getNullAttributes();
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_ENTRY, WebDAV.XML_NS_LOCK_ENTRY, nullAttr);
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_SCOPE, WebDAV.XML_NS_LOCK_SCOPE, nullAttr);
|
|
xml.write(DocumentHelper.createElement(lockType));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_SCOPE, WebDAV.XML_NS_LOCK_SCOPE);
|
|
|
|
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_TYPE, WebDAV.XML_NS_LOCK_TYPE, nullAttr);
|
|
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_WRITE));
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_TYPE, WebDAV.XML_NS_LOCK_TYPE);
|
|
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_ENTRY, WebDAV.XML_NS_LOCK_ENTRY);
|
|
}
|
|
}
|