List of usage examples for org.dom4j.io XMLWriter endElement
public void endElement(String namespaceURI, String localName, String qName) throws SAXException
From source file:org.alfresco.repo.admin.patch.util.ImportFileUpdater.java
License:Open Source License
private void outputCurrentElement(XmlPullParser reader, XMLWriter writer, Work work, boolean checkForCallbacks) throws Exception { if (checkForCallbacks == false || checkForCallbacks(reader, writer) == false) { // Get the name details of the element String name = reader.getName(); String namespace = reader.getNamespace(); String prefix = reader.getPrefix(); // Sort out namespaces Map<String, String> nss = new HashMap<String, String>(); int nsStart = reader.getNamespaceCount(reader.getDepth() - 1); int nsEnd = reader.getNamespaceCount(reader.getDepth()); for (int i = nsStart; i < nsEnd; i++) { String nsPrefix = reader.getNamespacePrefix(i); String ns = reader.getNamespaceUri(i); nss.put(nsPrefix, ns);// w w w .j a v a 2 s. com } // Sort out attributes AttributesImpl attributes = new AttributesImpl(); for (int i = 0; i < reader.getAttributeCount(); i++) { String attributeName = reader.getAttributeName(i); String attributeNamespace = reader.getAttributeNamespace(i); String attributePrefix = reader.getAttributePrefix(i); String attributeType = reader.getAttributeType(i); String attributeValue = reader.getAttributeValue(i); attributes.addAttribute(attributeNamespace, attributeName, attributePrefix + ":" + attributeName, attributeType, attributeValue); } // Start the namespace prefixes for (Map.Entry<String, String> entry : nss.entrySet()) { writer.startPrefixMapping(entry.getKey(), entry.getValue()); } // Write the start of the element writer.startElement(namespace, name, prefix + ":" + name, attributes); // Do the work work.doWork(reader, writer); // Write the end of the element writer.endElement(namespace, name, prefix + ":" + name); // End the namespace prefixes for (String nsPrefix : nss.keySet()) { writer.endPrefixMapping(nsPrefix); } } }
From source file:org.alfresco.repo.webdav.PropFindMethod.java
License:Open Source License
/** * Execute the main WebDAV request processing * // w w w.j a v a2s. com * @exception WebDAVServerException */ protected void executeImpl() throws WebDAVServerException, Exception { m_response.setStatus(WebDAV.WEBDAV_SC_MULTI_STATUS); FileInfo pathNodeInfo = null; try { // Check that the path exists pathNodeInfo = getDAVHelper().getNodeForPath(getRootNodeRef(), m_strPath); } 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 // Note the null check, as root node may be null in cloud. if (pathNodeInfo.getNodeRef() != null && getFileFolderService().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 = getDAVHelper().getChildren(curNodeInfo); // 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 = null; if ((pathNodeInfo.getNodeRef() == null) && (curNodeInfo.getNodeRef() == null)) { // TODO review - note: can be null in case of Thor pathSnippet = "/"; } else { 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); }
From source file:org.alfresco.repo.webdav.PropFindMethod.java
License:Open Source License
/** * Generates the required response XML for the current node * //from www . java2 s .co m * @param xml XMLWriter * @param nodeInfo FileInfo * @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); }
From source file:org.alfresco.repo.webdav.PropFindMethod.java
License:Open Source License
/** * Generates the XML response for a PROPFIND request that asks for a * specific set of properties/*from w ww . j av a 2 s . co m*/ * * @param xml XMLWriter * @param nodeInfo FileInfo * @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(); Map<QName, String> deadProperties = null; // 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 // String qualifiedName = propNamespaceUri + WebDAV.NAMESPACE_SEPARATOR + propName; String value = (String) nodeInfo.getProperties().get(property.createQName()); if (value == null) { if (deadProperties == null) { deadProperties = loadDeadProperties(nodeInfo.getNodeRef()); } value = deadProperties.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); } }
From source file:org.alfresco.repo.webdav.PropFindMethod.java
License:Open Source License
/** * Generates the XML response for a PROPFIND request that asks for all known * properties//from w w w . j a v a 2s. co m * * @param xml XMLWriter * @param nodeInfo FileInfo * @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); }
From source file:org.alfresco.repo.webdav.PropFindMethod.java
License:Open Source License
/** * Output the supported lock types XML element * /*from ww w . ja v a 2 s . c o m*/ * @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 // Shared locks are not supported, as they cannot be supported by the LockService (relevant to ALF-16449). writeLock(xml, WebDAV.XML_NS_EXCLUSIVE); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_SUPPORTED_LOCK, WebDAV.XML_NS_SUPPORTED_LOCK); } catch (Exception ex) { throw new AlfrescoRuntimeException("XML write error", ex); } }
From source file:org.alfresco.repo.webdav.PropPatchMethod.java
License:Open Source License
@Override protected void generateResponseImpl() throws Exception { m_response.setStatus(WebDAV.WEBDAV_SC_MULTI_STATUS); // Set the response content type m_response.setContentType(WebDAV.XML_CONTENT_TYPE); // Create multistatus response XMLWriter xml = createXMLWriter(); xml.startDocument();//from w w w.j a v a 2 s . c om String nsdec = generateNamespaceDeclarations(m_namespaces); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_MULTI_STATUS + nsdec, WebDAV.XML_NS_MULTI_STATUS + nsdec, getDAVHelper().getNullAttributes()); // Output the response block for the current node xml.startElement(WebDAV.DAV_NS, WebDAV.XML_RESPONSE, WebDAV.XML_NS_RESPONSE, getDAVHelper().getNullAttributes()); 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); if (failedProperty != null) { generateError(xml); } for (PropertyAction propertyAction : m_propertyActions) { WebDAVProperty property = propertyAction.getProperty(); int statusCode = propertyAction.getStatusCode(); String statusCodeDescription = propertyAction.getStatusCodeDescription(); generatePropertyResponse(xml, property, statusCode, statusCodeDescription); } // Close off the response element xml.endElement(WebDAV.DAV_NS, WebDAV.XML_RESPONSE, WebDAV.XML_NS_RESPONSE); // Close the outer XML element xml.endElement(WebDAV.DAV_NS, WebDAV.XML_MULTI_STATUS, WebDAV.XML_NS_MULTI_STATUS); // Send remaining data flushXML(xml); }