Java 类org.apache.catalina.util.XMLWriter 实例源码

项目:concourseconnect-community    文件:WebdavServlet.java   
/**
 * If a directory does not have files or folders under it then this
 * method generates the necessary xml
 *
 * @param context          Description of the Parameter
 * @param resources        Description of the Parameter
 * @param generatedXML     Description of the Parameter
 * @param propertiesVector Description of the Parameter
 * @throws java.io.IOException Description of the Exception
 */
private void parseProperties(ActionContext context, ModuleContext resources,
                             XMLWriter generatedXML, Vector propertiesVector) throws IOException {

  generatedXML.writeElement(null, "response", XMLWriter.OPENING);
  String status = new String(
      "HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND
          + " " + WebdavStatus.getStatusText
          (WebdavStatus.SC_NOT_FOUND));

  generatedXML.writeElement(null, "propstat", XMLWriter.OPENING);
  generatedXML.writeElement(null, "prop", XMLWriter.OPENING);
  generatedXML.writeElement(null, "prop", XMLWriter.CLOSING);
  generatedXML.writeElement(null, "status", XMLWriter.OPENING);
  generatedXML.writeText(status);
  generatedXML.writeElement(null, "status", XMLWriter.CLOSING);
  generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING);
  generatedXML.writeElement(null, "response", XMLWriter.CLOSING);
}
项目:tomcat7    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery",
                        XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:lams    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement(null, "lockdiscovery",
                                  XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement(null, "lockdiscovery",
                                          XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement(null, "lockdiscovery",
                                  XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:jerrydog    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = (LockInfo) resourceLocks.get(path);
    Enumeration collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement(null, "lockdiscovery",
                                  XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock =
            (LockInfo) collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement(null, "lockdiscovery",
                                          XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement(null, "lockdiscovery",
                                  XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:apache-tomcat-7.0.73-with-comment    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery",
                        XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:lazycat    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path
 *            Path
 * @param generatedXML
 *            XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery(String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:sakai    文件:DavServlet.java   
/**
 * Get an XML representation of this lock token. This method will append an XML fragment to the given XML writer.
 */
// originally this called toXML( ... false). That causes
// the system to show a dummy lock name. That breaks
// Contribute. It also violates the RFC. Contribute uses
// PROPFIND to find the lock name. Furthermore, the RFC
// specifically prohibits hiding the lock name this way.
// Rather than treating the lock name as secret, it's
// better to check permissions, as I now do.
public void toXML(XMLWriter generatedXML)
{
    toXML(generatedXML, true);
}
项目:class-guard    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery",
                        XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:apache-tomcat-7.0.57    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery",
                        XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:apache-tomcat-7.0.57    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery",
                        XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:sakai    文件:DavServlet.java   
/**
 * Get an XML representation of this lock token. This method will append an XML fragment to the given XML writer.
 */
// originally this called toXML( ... false). That causes
// the system to show a dummy lock name. That breaks
// Contribute. It also violates the RFC. Contribute uses
// PROPFIND to find the lock name. Furthermore, the RFC
// specifically prohibits hiding the lock name this way.
// Rather than treating the lock name as secret, it's
// better to check permissions, as I now do.
public void toXML(XMLWriter generatedXML)
{
    toXML(generatedXML, true);
}
项目:HowTomcatWorks    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = (LockInfo) resourceLocks.get(path);
    Enumeration collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement(null, "lockdiscovery",
                                  XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock =
            (LockInfo) collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement(null, "lockdiscovery",
                                          XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement(null, "lockdiscovery",
                                  XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:WBSAirback    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

    LockInfo resourceLock = resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null) {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements()) {
        LockInfo currentLock = collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path)) {
            if (!wroteStart) {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery",
                        XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart) {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    } else {
        return false;
    }

    return true;

}
项目:tomcat7    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable<String,Integer> errorList)
        throws IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus",
            XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = pathList.nextElement();
        int errorCode = errorList.get(errorPath).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " "
                + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:tomcat7    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML) {

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == maxDepth) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    Enumeration<String> tokensList = tokens.elements();
    while (tokensList.hasMoreElements()) {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:"
                               + tokensList.nextElement());
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:lams    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable<String,Integer> errorList)
    throws ServletException, IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement(null, "multistatus"
                              + generateNamespaceDeclarations(),
                              XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = pathList.nextElement();
        int errorCode = errorList.get(errorPath).intValue();

        generatedXML.writeElement(null, "response", XMLWriter.OPENING);

        generatedXML.writeElement(null, "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
        generatedXML.writeElement(null, "status", XMLWriter.OPENING);
        generatedXML
            .writeText("HTTP/1.1 " + errorCode + " "
                       + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement(null, "status", XMLWriter.CLOSING);

        generatedXML.writeElement(null, "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:lams    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML) {

    generatedXML.writeElement(null, "activelock", XMLWriter.OPENING);

    generatedXML.writeElement(null, "locktype", XMLWriter.OPENING);
    generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "depth", XMLWriter.OPENING);
    if (depth == maxDepth) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement(null, "depth", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement(null, "owner", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING);
    Enumeration<String> tokensList = tokens.elements();
    while (tokensList.hasMoreElements()) {
        generatedXML.writeElement(null, "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:"
                               + tokensList.nextElement());
        generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING);

}
项目:jerrydog    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable errorList)
    throws ServletException, IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement(null, "multistatus"
                              + generateNamespaceDeclarations(),
                              XMLWriter.OPENING);

    Enumeration pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = (String) pathList.nextElement();
        int errorCode = ((Integer) errorList.get(errorPath)).intValue();

        generatedXML.writeElement(null, "response", XMLWriter.OPENING);

        generatedXML.writeElement(null, "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
        generatedXML.writeElement(null, "status", XMLWriter.OPENING);
        generatedXML
            .writeText("HTTP/1.1 " + errorCode + " "
                       + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement(null, "status", XMLWriter.CLOSING);

        generatedXML.writeElement(null, "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:jerrydog    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML, boolean showToken) {

    generatedXML.writeElement(null, "activelock", XMLWriter.OPENING);

    generatedXML.writeElement(null, "locktype", XMLWriter.OPENING);
    generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "depth", XMLWriter.OPENING);
    if (depth == INFINITY) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement(null, "depth", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement(null, "owner", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING);
    if (showToken) {
        Enumeration tokensList = tokens.elements();
        while (tokensList.hasMoreElements()) {
            generatedXML.writeElement(null, "href", XMLWriter.OPENING);
            generatedXML.writeText("opaquelocktoken:"
                                   + tokensList.nextElement());
            generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
        }
    } else {
        generatedXML.writeElement(null, "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:dummytoken");
        generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING);

}
项目:apache-tomcat-7.0.73-with-comment    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable<String,Integer> errorList)
        throws IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus",
            XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = pathList.nextElement();
        int errorCode = errorList.get(errorPath).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " "
                + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:apache-tomcat-7.0.73-with-comment    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML) {

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == maxDepth) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    Enumeration<String> tokensList = tokens.elements();
    while (tokensList.hasMoreElements()) {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:"
                               + tokensList.nextElement());
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:lazycat    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req
 *            Servlet request
 * @param resp
 *            Servlet response
 * @param errorList
 *            List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp, Hashtable<String, Integer> errorList)
        throws IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = pathList.nextElement();
        int errorCode = errorList.get(errorPath).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " " + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:lazycat    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will append
 * an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML) {

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == maxDepth) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    Enumeration<String> tokensList = tokens.elements();
    while (tokensList.hasMoreElements()) {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:" + tokensList.nextElement());
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:sakai    文件:DavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the client.
 * 
 * @param req
 *        Servlet request
 * @param resp
 *        Servlet response
 * @param errorList
 *        List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp, Hashtable<String,Integer> errorList) throws ServletException,
        IOException
{

    resp.setStatus(SakaidavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements())
    {

        String errorPath = pathList.nextElement();
        int errorCode = ((Integer) errorList.get(errorPath)).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/")) toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " " + SakaidavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:sakai    文件:DavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 * 
 * @param path
 *        Path
 * @param generatedXML
 *        XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery(String path, XMLWriter generatedXML)
{

    LockInfo resourceLock = (LockInfo) resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null)
    {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements())
    {
        LockInfo currentLock = (LockInfo) collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path))
        {
            if (!wroteStart)
            {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart)
    {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    }
    else
    {
        return false;
    }

    return true;

}
项目:sakai    文件:DavServlet.java   
/**
 * Get an XML representation of this lock token. This method will append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML, boolean showToken)
{

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == INFINITY)
    {
        generatedXML.writeText("Infinity");
    }
    else
    {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    if (showToken)
    {
        Enumeration<String> tokensList = tokens.elements();
        while (tokensList.hasMoreElements())
        {
            generatedXML.writeElement("D", "href", XMLWriter.OPENING);
            generatedXML.writeText("opaquelocktoken:" + tokensList.nextElement());
            generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        }
    }
    else
    {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:dummytoken");
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:concourseconnect-community    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req       Servlet request
 * @param resp      Servlet response
 * @param errorList List of error to be displayed
 * @throws javax.servlet.ServletException Description of the Exception
 * @throws java.io.IOException            Description of the Exception
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable errorList)
    throws ServletException, IOException {

  resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

  String absoluteUri = req.getRequestURI();
  String relativePath = getRelativePath(req);

  XMLWriter generatedXML = new XMLWriter();
  generatedXML.writeXMLHeader();

  generatedXML.writeElement(
      null, "multistatus"
          + generateNamespaceDeclarations(),
      XMLWriter.OPENING);

  Enumeration pathList = errorList.keys();
  while (pathList.hasMoreElements()) {

    String errorPath = (String) pathList.nextElement();
    int errorCode = ((Integer) errorList.get(errorPath)).intValue();

    generatedXML.writeElement(null, "response", XMLWriter.OPENING);

    generatedXML.writeElement(null, "href", XMLWriter.OPENING);
    String toAppend = errorPath.substring(relativePath.length());
    if (!toAppend.startsWith("/")) {
      toAppend = "/" + toAppend;
    }
    generatedXML.writeText(absoluteUri + toAppend);
    generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
    generatedXML.writeElement(null, "status", XMLWriter.OPENING);
    generatedXML.writeText(
        "HTTP/1.1 " + errorCode + " "
            + WebdavStatus.getStatusText(errorCode));
    generatedXML.writeElement(null, "status", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "response", XMLWriter.CLOSING);

  }

  generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);

  Writer writer = resp.getWriter();
  writer.write(generatedXML.toString());
  writer.close();

}
项目:concourseconnect-community    文件:WebdavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 *
 * @param path         Path
 * @param generatedXML XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery
    (String path, XMLWriter generatedXML) {

  WebdavServlet.LockInfo resourceLock = (WebdavServlet.LockInfo) resourceLocks.get(path);
  Enumeration collectionLocksList = collectionLocks.elements();

  boolean wroteStart = false;

  if (resourceLock != null) {
    wroteStart = true;
    generatedXML.writeElement(
        null, "lockdiscovery",
        XMLWriter.OPENING);
    resourceLock.toXML(generatedXML);
  }

  while (collectionLocksList.hasMoreElements()) {
    WebdavServlet.LockInfo currentLock =
        (WebdavServlet.LockInfo) collectionLocksList.nextElement();
    if (path.startsWith(currentLock.path)) {
      if (!wroteStart) {
        wroteStart = true;
        generatedXML.writeElement(
            null, "lockdiscovery",
            XMLWriter.OPENING);
      }
      currentLock.toXML(generatedXML);
    }
  }

  if (wroteStart) {
    generatedXML.writeElement(
        null, "lockdiscovery",
        XMLWriter.CLOSING);
  } else {
    return false;
  }

  return true;
}
项目:concourseconnect-community    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will append an
 * XML fragment to the given XML writer.
 *
 * @param generatedXML Description of the Parameter
 */
public void toXML(XMLWriter generatedXML) {

  generatedXML.writeElement(null, "activelock", XMLWriter.OPENING);

  generatedXML.writeElement(null, "locktype", XMLWriter.OPENING);
  generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT);
  generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING);

  generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING);
  generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT);
  generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING);

  generatedXML.writeElement(null, "depth", XMLWriter.OPENING);
  if (depth == INFINITY) {
    generatedXML.writeText("Infinity");
  } else {
    generatedXML.writeText("0");
  }
  generatedXML.writeElement(null, "depth", XMLWriter.CLOSING);

  generatedXML.writeElement(null, "owner", XMLWriter.OPENING);
  generatedXML.writeText(owner);
  generatedXML.writeElement(null, "owner", XMLWriter.CLOSING);

  generatedXML.writeElement(null, "timeout", XMLWriter.OPENING);
  long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
  generatedXML.writeText("Second-" + timeout);
  generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING);

  generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING);
  Enumeration tokensList = tokens.elements();
  while (tokensList.hasMoreElements()) {
    generatedXML.writeElement(null, "href", XMLWriter.OPENING);
    generatedXML.writeText(
        "opaquelocktoken:"
            + tokensList.nextElement());
    generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
  }
  generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING);

  generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING);

}
项目:class-guard    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable<String,Integer> errorList)
        throws IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus",
            XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = pathList.nextElement();
        int errorCode = errorList.get(errorPath).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " "
                + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:class-guard    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML) {

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == maxDepth) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    Enumeration<String> tokensList = tokens.elements();
    while (tokensList.hasMoreElements()) {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:"
                               + tokensList.nextElement());
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:apache-tomcat-7.0.57    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable<String,Integer> errorList)
        throws IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus",
            XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = pathList.nextElement();
        int errorCode = errorList.get(errorPath).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " "
                + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:apache-tomcat-7.0.57    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML) {

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == maxDepth) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    Enumeration<String> tokensList = tokens.elements();
    while (tokensList.hasMoreElements()) {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:"
                               + tokensList.nextElement());
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:apache-tomcat-7.0.57    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable<String,Integer> errorList)
        throws IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus",
            XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = pathList.nextElement();
        int errorCode = errorList.get(errorPath).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " "
                + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:apache-tomcat-7.0.57    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML) {

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == maxDepth) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    Enumeration<String> tokensList = tokens.elements();
    while (tokensList.hasMoreElements()) {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:"
                               + tokensList.nextElement());
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:sakai    文件:DavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the client.
 * 
 * @param req
 *        Servlet request
 * @param resp
 *        Servlet response
 * @param errorList
 *        List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp, Hashtable<String,Integer> errorList) throws ServletException,
        IOException
{

    resp.setStatus(SakaidavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement("D", "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING);

    Enumeration<String> pathList = errorList.keys();
    while (pathList.hasMoreElements())
    {

        String errorPath = pathList.nextElement();
        int errorCode = ((Integer) errorList.get(errorPath)).intValue();

        generatedXML.writeElement("D", "response", XMLWriter.OPENING);

        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/")) toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        generatedXML.writeElement("D", "status", XMLWriter.OPENING);
        generatedXML.writeText("HTTP/1.1 " + errorCode + " " + SakaidavStatus.getStatusText(errorCode));
        generatedXML.writeElement("D", "status", XMLWriter.CLOSING);

        generatedXML.writeElement("D", "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:sakai    文件:DavServlet.java   
/**
 * Print the lock discovery information associated with a path.
 * 
 * @param path
 *        Path
 * @param generatedXML
 *        XML data to which the locks info will be appended
 * @return true if at least one lock was displayed
 */
private boolean generateLockDiscovery(String path, XMLWriter generatedXML)
{

    LockInfo resourceLock = (LockInfo) resourceLocks.get(path);
    Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();

    boolean wroteStart = false;

    if (resourceLock != null)
    {
        wroteStart = true;
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
        resourceLock.toXML(generatedXML);
    }

    while (collectionLocksList.hasMoreElements())
    {
        LockInfo currentLock = (LockInfo) collectionLocksList.nextElement();
        if (path.startsWith(currentLock.path))
        {
            if (!wroteStart)
            {
                wroteStart = true;
                generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
            }
            currentLock.toXML(generatedXML);
        }
    }

    if (wroteStart)
    {
        generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
    }
    else
    {
        return false;
    }

    return true;

}
项目:sakai    文件:DavServlet.java   
/**
 * Get an XML representation of this lock token. This method will append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML, boolean showToken)
{

    generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);

    generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
    generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
    if (depth == INFINITY)
    {
        generatedXML.writeText("Infinity");
    }
    else
    {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
    if (showToken)
    {
        Enumeration<String> tokensList = tokens.elements();
        while (tokensList.hasMoreElements())
        {
            generatedXML.writeElement("D", "href", XMLWriter.OPENING);
            generatedXML.writeText("opaquelocktoken:" + tokensList.nextElement());
            generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
        }
    }
    else
    {
        generatedXML.writeElement("D", "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:dummytoken");
        generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);

}
项目:HowTomcatWorks    文件:WebdavServlet.java   
/**
 * Send a multistatus element containing a complete error report to the
 * client.
 *
 * @param req Servlet request
 * @param resp Servlet response
 * @param errorList List of error to be displayed
 */
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
                        Hashtable errorList)
    throws ServletException, IOException {

    resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

    String absoluteUri = req.getRequestURI();
    String relativePath = getRelativePath(req);

    XMLWriter generatedXML = new XMLWriter();
    generatedXML.writeXMLHeader();

    generatedXML.writeElement(null, "multistatus"
                              + generateNamespaceDeclarations(),
                              XMLWriter.OPENING);

    Enumeration pathList = errorList.keys();
    while (pathList.hasMoreElements()) {

        String errorPath = (String) pathList.nextElement();
        int errorCode = ((Integer) errorList.get(errorPath)).intValue();

        generatedXML.writeElement(null, "response", XMLWriter.OPENING);

        generatedXML.writeElement(null, "href", XMLWriter.OPENING);
        String toAppend = errorPath.substring(relativePath.length());
        if (!toAppend.startsWith("/"))
            toAppend = "/" + toAppend;
        generatedXML.writeText(absoluteUri + toAppend);
        generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
        generatedXML.writeElement(null, "status", XMLWriter.OPENING);
        generatedXML
            .writeText("HTTP/1.1 " + errorCode + " "
                       + WebdavStatus.getStatusText(errorCode));
        generatedXML.writeElement(null, "status", XMLWriter.CLOSING);

        generatedXML.writeElement(null, "response", XMLWriter.CLOSING);

    }

    generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);

    Writer writer = resp.getWriter();
    writer.write(generatedXML.toString());
    writer.close();

}
项目:HowTomcatWorks    文件:WebdavServlet.java   
/**
 * Get an XML representation of this lock token. This method will
 * append an XML fragment to the given XML writer.
 */
public void toXML(XMLWriter generatedXML, boolean showToken) {

    generatedXML.writeElement(null, "activelock", XMLWriter.OPENING);

    generatedXML.writeElement(null, "locktype", XMLWriter.OPENING);
    generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT);
    generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING);
    generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT);
    generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "depth", XMLWriter.OPENING);
    if (depth == INFINITY) {
        generatedXML.writeText("Infinity");
    } else {
        generatedXML.writeText("0");
    }
    generatedXML.writeElement(null, "depth", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "owner", XMLWriter.OPENING);
    generatedXML.writeText(owner);
    generatedXML.writeElement(null, "owner", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "timeout", XMLWriter.OPENING);
    long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
    generatedXML.writeText("Second-" + timeout);
    generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING);
    if (showToken) {
        Enumeration tokensList = tokens.elements();
        while (tokensList.hasMoreElements()) {
            generatedXML.writeElement(null, "href", XMLWriter.OPENING);
            generatedXML.writeText("opaquelocktoken:"
                                   + tokensList.nextElement());
            generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
        }
    } else {
        generatedXML.writeElement(null, "href", XMLWriter.OPENING);
        generatedXML.writeText("opaquelocktoken:dummytoken");
        generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
    }
    generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING);

    generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING);

}