Package org.apache.webdav.lib.util

Examples of org.apache.webdav.lib.util.XMLPrinter


     *
     * <p>The default behavior simply returns an empty body.</p>
     */
    protected String generateRequestBody() {

        XMLPrinter printer = new XMLPrinter();

        printer.writeXMLHeader();
        printer.writeElement("D", "DAV:", "acl",
                             XMLPrinter.OPENING);

        Enumeration aceList = aces.elements();

        while (aceList.hasMoreElements()) {
            Ace ace = (Ace) aceList.nextElement();

            if (ace.isInherited() || ace.isProtected()) {
                // draft-ietf-webdav-acl-06
                // do not submit inherited and protected aces
                // continue with next ace
                continue;
            }

            printer.writeElement("D", null, "ace",
                                 XMLPrinter.OPENING);

            if (ace.isInheritable() != true) {
                printer.writeElement("S", "http://jakarta.apache.org/slide/", "non-inheritable",
                        XMLPrinter.NO_CONTENT);
            }

            printer.writeElement("D", null, "principal",
                                 XMLPrinter.OPENING);

            boolean found = false;
            String principal = ace.getPrincipal();
            String[] types = {"all", "authenticated", "unauthenticated",
                              "property", "self"};
            for (int i = 0; i < types.length && !found; i++) {
                if (types[i].equals(principal)) {
                    found = true;
                    if ("property".equals(principal)) {
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.OPENING);
                        PropertyName property = ace.getProperty();
                        String nsURI = property.getNamespaceURI();
                        if ("DAV:".equals(nsURI)) {
                            printer.writeElement("D", null,
                                                 property.getLocalName(),
                                                 XMLPrinter.NO_CONTENT);
                        } else {
                            printer.writeElement("Z", nsURI,
                                                 property.getLocalName(),
                                                 XMLPrinter.NO_CONTENT);
                        }
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.CLOSING);
                    } else {
                        printer.writeElement("D", null, principal,
                                             XMLPrinter.NO_CONTENT);
                    }
                }
            }
            if (!found) {
                printer.writeElement("D", null, "href", XMLPrinter.OPENING);
                printer.writeText(principal);
                printer.writeElement("D", null, "href", XMLPrinter.CLOSING);
            }

            printer.writeElement("D", null, "principal",
                                 XMLPrinter.CLOSING);

            String positive = (ace.isNegative()) ? "deny" : "grant";

            printer.writeElement("D", null, positive,
                                 XMLPrinter.OPENING);

            Enumeration privilegeList = ace.enumeratePrivileges();
            while (privilegeList.hasMoreElements()) {
                Privilege privilege = (Privilege) privilegeList.nextElement();
                printer.writeElement("D", null, "privilege",
                                     XMLPrinter.OPENING);
                String nsURI = privilege.getNamespace();
                if ("DAV:".equals(nsURI)) {
                    printer.writeElement("D", null, privilege.getName(),
                                         XMLPrinter.NO_CONTENT);
                } else {
                    printer.writeElement("Z", nsURI, privilege.getName(),
                                         XMLPrinter.NO_CONTENT);
                }
                printer.writeElement("D", null, "privilege",
                                     XMLPrinter.CLOSING);
            }

            printer.writeElement("D", null, positive,
                                 XMLPrinter.CLOSING);

            printer.writeElement("D", null, "ace",
                                 XMLPrinter.CLOSING);

        }

        printer.writeElement("D", "acl", XMLPrinter.CLOSING);

        return printer.toString();
    }
View Full Code Here


        if (segment == null || href == null)
            throw new IllegalStateException
                ("Segment and Href must be set before " +
                 "calling this function.");

        XMLPrinter printer = new XMLPrinter();

        printer.writeXMLHeader();
        printer.writeElement("D", "DAV:", "rebind", XMLPrinter.OPENING);
        printer.writeElement("D", "segment", XMLPrinter.OPENING);
        printer.writeText(segment);
        printer.writeElement("D", "segment", XMLPrinter.CLOSING);
        printer.writeElement("D", "href", XMLPrinter.OPENING);
        printer.writeText(href);
        printer.writeElement("D", "href", XMLPrinter.CLOSING);
        printer.writeElement("D", "rebind", XMLPrinter.CLOSING);

        return printer.toString();
    }
View Full Code Here

     * <p>The default behavior simply returns an empty body.</p>
     */
    protected String generateRequestBody() {

        if (sTarget != null){
            XMLPrinter printer = new XMLPrinter();


            printer.writeXMLHeader();

            printer.writeElement("D", "DAV:", "version-control", XMLPrinter.OPENING);
            printer.writeElement("D", "version", XMLPrinter.OPENING);

            printer.writeElement("D", "href", XMLPrinter.OPENING);
            printer.writeText(sTarget);
            printer.writeElement("D", "href", XMLPrinter.CLOSING);
            printer.writeElement("D", "version", XMLPrinter.CLOSING);
            printer.writeElement("D", "version-control", XMLPrinter.CLOSING);

            return printer.toString();
        }
        else
            return "";

    }
View Full Code Here

     * generate that body.
     *
     * <p>The default behavior simply returns an empty body.</p>
     */
    protected String generateRequestBody() {
        XMLPrinter printer = new XMLPrinter();


        printer.writeXMLHeader();
        printer.writeElement("D", "DAV:", "propertyupdate",
                             XMLPrinter.OPENING);

        if (toSet.size() > 0) {

            printer.writeElement("D", null, "set", XMLPrinter.OPENING);

            Enumeration toSetList = toSet.elements();
            printer.writeElement("D", null, "prop", XMLPrinter.OPENING);
            while (toSetList.hasMoreElements()) {
                Property current = (Property) toSetList.nextElement();
                if ("DAV:".equals(current.namespaceInfo)) {
                    printer.writeProperty("D", null, current.name, current.value);
                }
                else {
                    printer.writeProperty(current.namespace, current.namespaceInfo,
                                      current.name, current.value);
                }
            }
            printer.writeElement("D", null, "prop", XMLPrinter.CLOSING);

            printer.writeElement("D", null, "set", XMLPrinter.CLOSING);

        }

        if (toRemove.size() > 0) {

            printer.writeElement("D", null, "remove", XMLPrinter.OPENING);

            Enumeration toRemoveList = toRemove.elements();
            printer.writeElement("D", null, "prop", XMLPrinter.OPENING);
            while (toRemoveList.hasMoreElements()) {
                Property current = (Property) toRemoveList.nextElement();
                printer.writeElement(current.namespace, current.namespaceInfo,
                                     current.name, XMLPrinter.NO_CONTENT);
            }
            printer.writeElement("D", null, "prop", XMLPrinter.CLOSING);

            printer.writeElement("D", null, "remove", XMLPrinter.CLOSING);

        }

        printer.writeElement("D", "propertyupdate", XMLPrinter.CLOSING);

        return printer.toString();
    }
View Full Code Here

        if (segment == null || href == null)
            throw new IllegalStateException
                ("Segment and Href must be set before " +
                 "calling this function.");

        XMLPrinter printer = new XMLPrinter();

        printer.writeXMLHeader();
        printer.writeElement("D", "DAV:", "bind", XMLPrinter.OPENING);
        printer.writeElement("D", "segment", XMLPrinter.OPENING);
        printer.writeText(segment);
        printer.writeElement("D", "segment", XMLPrinter.CLOSING);
        printer.writeElement("D", "href", XMLPrinter.OPENING);
        printer.writeText(href);
        printer.writeElement("D", "href", XMLPrinter.CLOSING);
        printer.writeElement("D", "bind", XMLPrinter.CLOSING);

        return printer.toString();
    }
View Full Code Here

     * <p>The default behavior simply returns an empty body.</p>
     */
    protected String generateRequestBody() {

        if (type != 0){
            XMLPrinter printer = new XMLPrinter();

            printer.writeXMLHeader();
            //System.out.println(printer.toString());
            printer.writeElement("D", "DAV:", "options",
                                 XMLPrinter.OPENING);

            if (type == OPTIONS_VERSION_HISTORY)
                printer.writeElement("D", "version-history-collection-set", XMLPrinter.NO_CONTENT);
            if (type == OPTIONS_WORKSPACE)
                printer.writeElement("D", "workspace-collection-set", XMLPrinter.NO_CONTENT);

            printer.writeElement("D", "options", XMLPrinter.CLOSING);

            return printer.toString();
        }

        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.webdav.lib.util.XMLPrinter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.