當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLWriter.startElement方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:25,代碼來源:PropFindMethod.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:25,代碼來源:PropPatchMethod.java

示例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);
        }
    }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:32,代碼來源:PropfindMethod.java

示例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);
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:42,代碼來源:PropFindMethod.java

示例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); 
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:22,代碼來源:PropFindMethod.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:44,代碼來源:PropPatchMethod.java

示例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");
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:40,代碼來源:PropfindMethod.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:33,代碼來源:PropfindMethod.java

示例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);
   
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:45,代碼來源:LockMethod.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:58,代碼來源:PropFindMethod.java

示例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);
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:54,代碼來源:PropPatchMethod.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:70,代碼來源:WebDAVMethod.java

示例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;
        }
    }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:50,代碼來源:DeleteMethod.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:community-edition-old,代碼行數:58,代碼來源:PropfindMethod.java


注:本文中的org.dom4j.io.XMLWriter.startElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。