Example usage for org.jdom2.output XMLOutputter outputString

List of usage examples for org.jdom2.output XMLOutputter outputString

Introduction

In this page you can find the example usage for org.jdom2.output XMLOutputter outputString.

Prototype

public final String outputString(EntityRef entity) 

Source Link

Document

Return a string representing an EntityRef .

Usage

From source file:org.kisst.cordys.caas.util.XmlNode.java

License:Open Source License

@Override
public String toString() {
    XMLOutputter out = new XMLOutputter();
    return out.outputString(element);
}

From source file:org.kisst.cordys.caas.util.XmlNode.java

License:Open Source License

public String getPretty() {
    XMLOutputter out = new XMLOutputter();
    out.setFormat(Format.getPrettyFormat());
    String xml = out.outputString(element);
    return xml;/*from   w ww.ja v  a  2 s  . c  o  m*/
}

From source file:org.lendingclub.mercator.ucs.UCSClient.java

License:Apache License

public void logDebug(String message, Element element) {

    if (logger.isDebugEnabled()) {
        XMLOutputter out = new XMLOutputter();

        out.setFormat(Format.getPrettyFormat());

        element = element.clone();/*  w  w  w  . ja v a 2s . c  o m*/
        if (!Strings.isNullOrEmpty(element.getAttributeValue("outCookie"))) {
            element.setAttribute("outCookie", "**********");
        }
        if (!Strings.isNullOrEmpty(element.getAttributeValue("cookie"))) {
            element.setAttribute("cookie", "**********");
        }
        logger.debug(message + "\n{}", out.outputString(element));
    }
}

From source file:org.lendingclub.mercator.ucs.UCSClient.java

License:Apache License

public Element exec(String command, Map<String, String> args) {
    try {/*from   w  w  w . j a  v  a  2  s . co m*/
        Element el = new Element(command);

        if (!command.equals("aaaLogout")) {
            String cookie = getToken().getTokenValue();
            if (Strings.isNullOrEmpty(cookie)) {
                throw new MercatorException("client does not have valid session");
            }
            el.setAttribute("cookie", getToken().getTokenValue());
        }

        args.forEach((k, v) -> {
            el.setAttribute(k, v);
        });
        XMLOutputter out = new XMLOutputter();
        String val = target.post(out.outputString(el)).header("Content-type", "application/xml")
                .execute(String.class);

        SAXBuilder saxBuilder = new SAXBuilder();

        Document document = saxBuilder.build(new StringReader(val));

        Element element = document.getRootElement();
        logDebug(command, element);
        String errorCode = element.getAttributeValue("errorCode");
        if (!Strings.isNullOrEmpty(errorCode)) {
            if (errorCode.equals("552")) {
                logout();
                throw UCSRemoteException.fromResponse(element);
            } else if (errorCode.equals("555") && command.equals("aaaLogout")) {
                logger.info("aaaLogout session not found");
            } else {
                throw UCSRemoteException.fromResponse(element);
            }
        }
        return element;
    } catch (IOException | JDOMException e) {
        throw new UCSException(e);
    }
}

From source file:org.mule.tools.apikit.Helper.java

License:Open Source License

public static String nonSpaceOutput(Element element) {
    XMLOutputter xout = new XMLOutputter(Format.getCompactFormat());
    return xout.outputString(element);
}

From source file:org.mule.tools.apikit.Helper.java

License:Open Source License

public static String nonSpaceOutput(Document doc) {
    XMLOutputter xout = new XMLOutputter(Format.getCompactFormat());
    return xout.outputString(doc.getRootElement().getChildren());
}

From source file:org.mycore.common.MCRMailer.java

License:Open Source License

/** Outputs xml to the LOGGER for debugging */
private static void debug(Element xml) {
    XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
    LOGGER.debug(delimiter + xout.outputString(xml) + delimiter);
}

From source file:org.mycore.datamodel.metadata.validator.MCREditorOutValidator.java

License:Open Source License

/**
 * tries to generate a valid MCRObject as JDOM Document.
 * /*  w  ww.  j  a v a2  s .c  o  m*/
 * @return MCRObject
 */
public Document generateValidMyCoReObject() throws JDOMException, SAXParseException, IOException {
    MCRObject obj;
    // load the JDOM object
    XPathFactory.instance().compile("/mycoreobject/*/*/*/@editor.output", Filters.attribute()).evaluate(input)
            .forEach(Attribute::detach);
    try {
        byte[] xml = new MCRJDOMContent(input).asByteArray();
        obj = new MCRObject(xml, true);
    } catch (SAXParseException e) {
        XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
        LOGGER.warn("Failure while parsing document:\n" + xout.outputString(input));
        throw e;
    }
    Date curTime = new Date();
    obj.getService().setDate("modifydate", curTime);

    // return the XML tree
    input = obj.createXML();
    return input;
}

From source file:org.mycore.frontend.cli.MCRAccessCommands.java

License:Open Source License

/**
 * This method invokes MCRUserMgr.getAllPrivileges() and retrieves a
 * ArrayList of all privileges stored in the persistent datastore.
 *///from  w  ww  .  j  a v a  2  s. co m
@MCRCommand(syntax = "list all permissions", help = "List all permission entries.", order = 20)
public static void listAllPermissions() throws MCRException {
    MCRAccessInterface AI = MCRAccessManager.getAccessImpl();
    Collection<String> permissions = AI.getPermissions();
    boolean noPermissionsDefined = true;
    for (String permission : permissions) {
        noPermissionsDefined = false;
        String description = AI.getRuleDescription(permission);
        if (description.equals("")) {
            description = "No description";
        }
        org.jdom2.Element rule = AI.getRule(permission);
        LOGGER.info("       " + permission);
        LOGGER.info("           " + description);
        if (rule != null) {
            org.jdom2.output.XMLOutputter o = new org.jdom2.output.XMLOutputter();
            LOGGER.info("           " + o.outputString(rule));
        }
    }
    if (noPermissionsDefined) {
        LOGGER.warn("No permissions defined");
    }
    LOGGER.info("");
}

From source file:org.mycore.frontend.editor.MCREditorServlet.java

License:Open Source License

private void sendToDebug(HttpServletResponse res, Document unprocessed, MCREditorSubmission sub)
        throws IOException, UnsupportedEncodingException {
    res.setContentType("text/html; charset=UTF-8");

    PrintWriter pw = res.getWriter();

    pw.println("<html><body><p><pre>");

    for (int i = 0; i < sub.getVariables().size(); i++) {
        MCREditorVariable var = (MCREditorVariable) sub.getVariables().get(i);
        pw.println(var.getPath() + " = " + var.getValue());

        FileItem file = var.getFile();

        if (file != null) {
            pw.println("      is uploaded file " + file.getContentType() + ", " + file.getSize() + " bytes");
        }//  w  w  w .j  a  v  a2 s  . com
    }

    pw.println("</pre></p><p>");

    XMLOutputter outputter = new XMLOutputter();
    Format fmt = Format.getPrettyFormat();
    fmt.setLineSeparator("\n");
    fmt.setOmitDeclaration(true);
    outputter.setFormat(fmt);

    Element pre = new Element("pre");
    pre.addContent(outputter.outputString(unprocessed));
    outputter.output(pre, pw);

    pre = new Element("pre");
    pre.addContent(outputter.outputString(sub.getXML()));
    outputter.output(pre, pw);

    pw.println("</p></body></html>");
    pw.close();
}