本文整理汇总了Java中org.dom4j.io.XMLWriter.startElement方法的典型用法代码示例。如果您正苦于以下问题:Java XMLWriter.startElement方法的具体用法?Java XMLWriter.startElement怎么用?Java XMLWriter.startElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.io.XMLWriter
的用法示例。
在下文中一共展示了XMLWriter.startElement方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeLockTypes
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* 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
// 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);
}
}
示例2: generateError
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the error tag
*
* @param xml XMLWriter
*/
protected void generateError(XMLWriter xml)
{
try
{
// Output the start of the error element
Attributes nullAttr = getDAVHelper().getNullAttributes();
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_ERROR, WebDAV.XML_NS_ERROR, nullAttr);
// Output error
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_CANNOT_MODIFY_PROTECTED_PROPERTY));
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_ERROR, WebDAV.XML_NS_ERROR);
}
catch (Exception ex)
{
// Convert to a runtime exception
throw new AlfrescoRuntimeException("XML processing error", ex);
}
}
示例3: generateLockDiscoveryResponse
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the XML response snippet showing the lock information for the
* given path
*
* @param xml XMLWriter
* @param nodeInfo FileInfo
* @param isDir boolean
*/
protected void generateLockDiscoveryResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir) throws Exception
{
// Get the lock status for the node
LockInfo lockInfo = getNodeLockInfo(nodeInfo);
// Output the lock status response
if (lockInfo.isLocked())
{
generateLockDiscoveryXML(xml, nodeInfo, lockInfo);
}
else
{
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_DISCOVERY, WebDAV.XML_NS_LOCK_DISCOVERY, getDAVHelper().getNullAttributes());
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_DISCOVERY, WebDAV.XML_NS_LOCK_DISCOVERY);
if (isDir)
{
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_SUPPORTED_LOCK, WebDAV.XML_NS_SUPPORTED_LOCK, getDAVHelper().getNullAttributes());
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_SUPPORTED_LOCK, WebDAV.XML_NS_SUPPORTED_LOCK);
}
}
}
示例4: generateResponseForNode
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the required response XML for the current node
*
* @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);
}
示例5: writeLock
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Output the lockentry element of the specified type
* @param xml XMLWriter
* @param lockType lock type containing namespace. Can be WebDAV.XML_NS_EXCLUSIVE or WebDAV.XML_NS_SHARED
* @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);
}
示例6: generatePropertyResponse
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the XML response for a PROPFIND request that asks for a list of
* all known properties
*
* @param xml XMLWriter
* @param property WebDAVProperty
* @param status int
* @param description String
*/
protected void generatePropertyResponse(XMLWriter xml, WebDAVProperty property, int status, String description)
{
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);
// Output property name
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr);
if (property.hasNamespaceName())
{
xml.write(DocumentHelper.createElement(property.getNamespaceName() + WebDAV.NAMESPACE_SEPARATOR + property.getName()));
}
else
{
xml.write(DocumentHelper.createElement(property.getName()));
}
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
// Output action result status
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr);
xml.write(WebDAV.HTTP1_1 + " " + status + " " + description);
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);
}
}
示例7: generateResponseForNode
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the required response XML for the current node
*
* @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());
path = URLDecoder.decode(m_request.getRequestURI()).replaceFirst(alfrescoContext, "") + path;
path = path.replaceAll("//", "/");
// Build the href string for the current node
String relativeUrl = getDAVHelper().getURLForPath(m_request, path, isFolder);
String strHRef = urlHelper.getExternalURLHostOnly() + relativeUrl;
if (nodeInfo.isFolder())
{
strHRef = strHRef.substring(0, strHRef.length() - 1);
}
strHRef = strHRef.endsWith("/") ? strHRef.substring(0, strHRef.length() - 1) : strHRef;
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);
generateAllPropertiesResponse(xml, nodeInfo, isFolder);
// Close off the response element
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_RESPONSE, WebDAV.XML_NS_RESPONSE);
xml.write("\n");
}
示例8: writeLockTypes
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* 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);
xml.startElement(WebDAV.DAV_NS, "lockentry", "D:lockentry", nullAttr);
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_SCOPE, WebDAV.XML_NS_LOCK_SCOPE, nullAttr);
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_EXCLUSIVE));
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, "lockentry", "D:lockentry");
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_SUPPORTED_LOCK, WebDAV.XML_NS_SUPPORTED_LOCK);
}
catch (Exception ex)
{
throw new AlfrescoRuntimeException("XML write error", ex);
}
}
示例9: generateResponse
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the XML lock discovery response body
*/
protected void generateResponse(FileInfo lockNodeInfo, String userName) throws Exception
{
String scope;
String lt;
String owner;
Date expiry;
if (lockToken != null)
{
// In case of lock creation take the scope from request header
scope = this.createExclusive ? WebDAV.XML_EXCLUSIVE : WebDAV.XML_SHARED;
// Output created lock
lt = lockToken;
}
else
{
// In case of lock refreshing take the scope from previously stored lock
scope = this.lockInfo.getScope();
// Output refreshed lock
lt = this.lockInfo.getExclusiveLockToken();
}
owner = lockInfo.getOwner();
expiry = lockInfo.getExpires();
XMLWriter xml = createXMLWriter();
xml.startDocument();
String nsdec = generateNamespaceDeclarations(null);
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP + nsdec, WebDAV.XML_NS_PROP + nsdec, getDAVHelper().getNullAttributes());
// Output the lock details
generateLockDiscoveryXML(xml, lockNodeInfo, false, scope, WebDAV.getDepthName(m_depth), lt, owner, expiry);
// Close off the XML
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP);
// Send remaining data
flushXML(xml);
}
示例10: generateFindPropertiesResponse
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the XML response for a PROPFIND request that asks for a list of
* all known properties
*
* @param xml XMLWriter
* @param nodeInfo FileInfo
* @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);
}
}
示例11: generateResponseImpl
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
@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();
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);
}
示例12: generateLockDiscoveryXML
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the lock discovery XML response
*
* @param xml XMLWriter
* @param lockNodeInfo FileInfo
* @param emptyNamespace boolean True if namespace should be empty. Used to avoid bugs in WebDAV clients.
* @param scope String lock scope
* @param depth String lock depth
* @param lToken String locktoken
* @param owner String lock owner
* @param expiryDate the date/time the lock should expire
*/
protected void generateLockDiscoveryXML(XMLWriter xml, FileInfo lockNodeInfo, boolean emptyNamespace,
String scope, String depth, String lToken, String owner, Date expiryDate) throws Exception
{
Attributes nullAttr= getDAVHelper().getNullAttributes();
String ns = emptyNamespace ? "" : WebDAV.DAV_NS;
if (lockNodeInfo != null)
{
// Output the XML response
xml.startElement(ns, WebDAV.XML_LOCK_DISCOVERY, emptyNamespace ? WebDAV.XML_LOCK_DISCOVERY : WebDAV.XML_NS_LOCK_DISCOVERY, nullAttr);
xml.startElement(ns, WebDAV.XML_ACTIVE_LOCK, emptyNamespace ? WebDAV.XML_ACTIVE_LOCK : WebDAV.XML_NS_ACTIVE_LOCK, nullAttr);
xml.startElement(ns, WebDAV.XML_LOCK_TYPE, emptyNamespace ? WebDAV.XML_LOCK_TYPE : WebDAV.XML_NS_LOCK_TYPE, nullAttr);
xml.write(DocumentHelper.createElement(emptyNamespace ? WebDAV.XML_WRITE : WebDAV.XML_NS_WRITE));
xml.endElement(ns, WebDAV.XML_LOCK_TYPE, emptyNamespace ? WebDAV.XML_LOCK_TYPE : WebDAV.XML_NS_LOCK_TYPE);
xml.startElement(ns, WebDAV.XML_LOCK_SCOPE, emptyNamespace ? WebDAV.XML_LOCK_SCOPE : WebDAV.XML_NS_LOCK_SCOPE, nullAttr);
xml.write(DocumentHelper.createElement(emptyNamespace ? scope : WebDAV.DAV_NS_PREFIX + scope));
xml.endElement(ns, WebDAV.XML_LOCK_SCOPE, emptyNamespace ? WebDAV.XML_LOCK_SCOPE : WebDAV.XML_NS_LOCK_SCOPE);
// NOTE: We only support one level of lock at the moment
xml.startElement(ns, WebDAV.XML_DEPTH, emptyNamespace ? WebDAV.XML_DEPTH : WebDAV.XML_NS_DEPTH, nullAttr);
xml.write(depth);
xml.endElement(ns, WebDAV.XML_DEPTH, emptyNamespace ? WebDAV.XML_DEPTH : WebDAV.XML_NS_DEPTH);
xml.startElement(ns, WebDAV.XML_OWNER, emptyNamespace ? WebDAV.XML_OWNER : WebDAV.XML_NS_OWNER, nullAttr);
xml.write(owner);
xml.endElement(ns, WebDAV.XML_OWNER, emptyNamespace ? WebDAV.XML_OWNER : WebDAV.XML_NS_OWNER);
xml.startElement(ns, WebDAV.XML_TIMEOUT, emptyNamespace ? WebDAV.XML_TIMEOUT : WebDAV.XML_NS_TIMEOUT, nullAttr);
// Output the expiry time
String strTimeout = WebDAV.INFINITE;
if (expiryDate != null)
{
long timeoutRemaining = (expiryDate.getTime() - System.currentTimeMillis())/1000L;
strTimeout = WebDAV.SECOND + timeoutRemaining;
}
xml.write(strTimeout);
xml.endElement(ns, WebDAV.XML_TIMEOUT, emptyNamespace ? WebDAV.XML_TIMEOUT : WebDAV.XML_NS_TIMEOUT);
xml.startElement(ns, WebDAV.XML_LOCK_TOKEN, emptyNamespace ? WebDAV.XML_LOCK_TOKEN : WebDAV.XML_NS_LOCK_TOKEN, nullAttr);
xml.startElement(ns, WebDAV.XML_HREF, emptyNamespace ? WebDAV.XML_HREF : WebDAV.XML_NS_HREF, nullAttr);
xml.write(lToken);
xml.endElement(ns, WebDAV.XML_HREF, emptyNamespace ? WebDAV.XML_HREF : WebDAV.XML_NS_HREF);
xml.endElement(ns, WebDAV.XML_LOCK_TOKEN, emptyNamespace ? WebDAV.XML_LOCK_TOKEN : WebDAV.XML_NS_LOCK_TOKEN);
xml.endElement(ns, WebDAV.XML_ACTIVE_LOCK, emptyNamespace ? WebDAV.XML_ACTIVE_LOCK : WebDAV.XML_NS_ACTIVE_LOCK);
xml.endElement(ns, WebDAV.XML_LOCK_DISCOVERY, emptyNamespace ? WebDAV.XML_LOCK_DISCOVERY : WebDAV.XML_NS_LOCK_DISCOVERY);
}
}
示例13: executeImpl
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
@Override
protected void executeImpl() throws WebDAVServerException, Exception
{
try
{
super.executeImpl();
m_response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
catch (WebDAVServerException e)
{
if (e.getHttpStatusCode() == WebDAV.WEBDAV_SC_LOCKED)
{
// SharePoint requires a special response for the case of
// trying to delete a locked document
m_response.setStatus(WebDAV.WEBDAV_SC_MULTI_STATUS);
m_response.setContentType(WebDAV.XML_CONTENT_TYPE);
m_response.addHeader(HEADER_X_MSDAVEXT_ERROR, "589838"); // TODO Don't hard code this constant
XMLWriter xml = createXMLWriter();
xml.startDocument();
String nsdec = generateNamespaceDeclarations(namespaceMap);
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_MULTI_STATUS + nsdec, WebDAV.XML_NS_MULTI_STATUS + nsdec, getDAVHelper().getNullAttributes());
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(m_request.getRequestURL().toString());
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_HREF, WebDAV.XML_NS_HREF);
xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, getDAVHelper().getNullAttributes());
xml.write(WebDAV.HTTP1_1 + " " + WebDAV.WEBDAV_SC_LOCKED + " " + SC_LOCKED_DESC);
xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS);
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);
}
else
{
throw e;
}
}
}
示例14: generateFakeLockDiscoveryResponseForWorkingCopy
import org.dom4j.io.XMLWriter; //导入方法依赖的package包/类
/**
* Generates the XML response snippet showing the fake lock information for the given path
*
* @param xml XMLWriter
* @param node NodeRef
* @param isDir boolean
*/
protected void generateFakeLockDiscoveryResponseForWorkingCopy(XMLWriter xml, NodeRef node, boolean isDir) throws Exception
{
Attributes nullAttr= getDAVHelper().getNullAttributes();
String ns = WebDAV.DAV_NS;
if (node != null)
{
String owner = (String) getNodeService().getProperty(node, ContentModel.PROP_WORKING_COPY_OWNER);
String lockTocken = WebDAV.makeLockToken(node, owner);
// Output the XML response
xml.startElement(ns, WebDAV.XML_LOCK_DISCOVERY, WebDAV.XML_NS_LOCK_DISCOVERY, nullAttr);
xml.startElement(ns, WebDAV.XML_ACTIVE_LOCK, WebDAV.XML_NS_ACTIVE_LOCK, nullAttr);
xml.startElement(ns, WebDAV.XML_LOCK_TYPE, WebDAV.XML_NS_LOCK_TYPE, nullAttr);
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_WRITE));
xml.endElement(ns, WebDAV.XML_LOCK_TYPE, WebDAV.XML_NS_LOCK_TYPE);
xml.startElement(ns, WebDAV.XML_LOCK_SCOPE, WebDAV.XML_NS_LOCK_SCOPE, nullAttr);
xml.write(DocumentHelper.createElement(WebDAV.XML_NS_EXCLUSIVE));
xml.endElement(ns, WebDAV.XML_LOCK_SCOPE, WebDAV.XML_NS_LOCK_SCOPE);
// NOTE: We only support one level of lock at the moment
xml.startElement(ns, WebDAV.XML_DEPTH, WebDAV.XML_NS_DEPTH, nullAttr);
xml.write("0");
xml.endElement(ns, WebDAV.XML_DEPTH, WebDAV.XML_NS_DEPTH);
xml.startElement(ns, WebDAV.XML_OWNER, WebDAV.XML_NS_OWNER, nullAttr);
xml.write(owner);
xml.endElement(ns, WebDAV.XML_OWNER, WebDAV.XML_NS_OWNER);
xml.startElement(ns, WebDAV.XML_TIMEOUT, WebDAV.XML_NS_TIMEOUT, nullAttr);
xml.write(WebDAV.SECOND + "604800");
xml.endElement(ns, WebDAV.XML_TIMEOUT, WebDAV.XML_NS_TIMEOUT);
xml.startElement(ns, WebDAV.XML_LOCK_TOKEN, WebDAV.XML_NS_LOCK_TOKEN, nullAttr);
xml.startElement(ns, WebDAV.XML_HREF, WebDAV.XML_NS_HREF, nullAttr);
xml.write(lockTocken);
xml.endElement(ns, WebDAV.XML_HREF, WebDAV.XML_NS_HREF);
xml.endElement(ns, WebDAV.XML_LOCK_TOKEN, WebDAV.XML_NS_LOCK_TOKEN);
xml.endElement(ns, WebDAV.XML_ACTIVE_LOCK, WebDAV.XML_NS_ACTIVE_LOCK);
xml.endElement(ns, WebDAV.XML_LOCK_DISCOVERY, WebDAV.XML_NS_LOCK_DISCOVERY);
}
}