Example usage for org.jdom2.output XMLOutputter XMLOutputter

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

Introduction

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

Prototype

public XMLOutputter(XMLOutputProcessor processor) 

Source Link

Document

This will create an XMLOutputter with the specified XMLOutputProcessor.

Usage

From source file:org.esa.snap.framework.dataop.downloadable.XMLSupport.java

License:Open Source License

public static void SaveXML(final Document doc, final String filePath) {

    try {/*from   ww  w.j a  va 2s  . com*/
        final Format xmlFormat = Format.getPrettyFormat();
        final XMLOutputter outputter = new XMLOutputter(xmlFormat);

        final FileWriter writer = new FileWriter(filePath);
        outputter.output(doc, writer);
        //outputter.output(doc, System.out);
        writer.close();
    } catch (java.io.IOException e) {
        e.printStackTrace();
    }
}

From source file:org.fiware.cybercaptor.server.attackgraph.AttackGraph.java

License:Open Source License

/**
 * Save the attack graph in an xml file/*from   w  w  w. j  a  v a  2s.c  o  m*/
 *
 * @param filePath the path in which the attack graph is saved
 * @throws Exception
 */
public void saveToXmlFile(String filePath) throws Exception {
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
    output.output(toDomElement(), new FileOutputStream(filePath));
}

From source file:org.fiware.cybercaptor.server.informationsystem.InformationSystem.java

License:Open Source License

/**
 * Save the attack graph in an xml file/*w ww.j a  v  a 2  s  .  co  m*/
 *
 * @param filePath the file path where the attack graph will be save
 * @throws Exception
 */
public void saveToXmlFile(String filePath) throws Exception {
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
    output.output(toDomXMLElement(), new FileOutputStream(filePath));
}

From source file:org.fiware.cybercaptor.server.remediation.cost.GlobalParameters.java

License:Open Source License

/**
 * Function used to save the parameters in an xml file
 *
 * @param path the path where the xml file should be created
 * @throws Exception// www  .  j a  va  2  s .  c  o  m
 */
public void saveToXMLFile(String path) throws Exception {
    Document document = new Document(toDomElement());
    //Save the DOM element in file
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
    output.output(document, new FileOutputStream(path));
}

From source file:org.fiware.cybercaptor.server.remediation.cost.OperationalCostParameters.java

License:Open Source License

/**
 * Function used to save the parameters in an xml file
 *
 * @param path the path where the xml file should be created
 * @throws Exception the exception/*from w  ww.  j  a  va  2 s  . c om*/
 */
public void saveToXMLFile(String path) throws Exception {
    Document document = new Document(toDomElement());

    //Save the DOM element in file
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
    output.output(document, new FileOutputStream(path));
}

From source file:org.fiware.cybercaptor.server.rest.RestAPIAttackPaths.java

License:Open Source License

@GET
@Path("list")
@Produces(MediaType.TEXT_XML)/*from w w  w. j a  va 2  s. com*/
public Response getList(@Context HttpServletRequest request) {
    Monitoring monitoring = ((Monitoring) request.getSession(true).getAttribute("monitoring"));

    if (monitoring == null)
        return Response.status(Status.NO_CONTENT).build();

    Element attackPathsXML = org.fiware.cybercaptor.server.api.AttackPathManagement
            .getAttackPathsXML(monitoring);
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
    return Response.ok(output.outputString(attackPathsXML)).build();
}

From source file:org.fiware.cybercaptor.server.rest.RestAPIAttackPaths.java

License:Open Source License

@GET
@Path("{id}")
@Produces(MediaType.TEXT_XML)/*  www  . ja  v a2  s .  c  om*/
public Response getAttackPath(@Context HttpServletRequest request, @PathParam("id") int id) {
    Monitoring monitoring = ((Monitoring) request.getSession(true).getAttribute("monitoring"));

    if (monitoring == null)
        return Response.status(Status.NO_CONTENT).build();

    Element attackPathXML = org.fiware.cybercaptor.server.api.AttackPathManagement.getAttackPathXML(monitoring,
            id);
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());

    return Response.ok(output.outputString(attackPathXML)).build();
}

From source file:org.fiware.cybercaptor.server.rest.RestAPIAttackPaths.java

License:Open Source License

@GET
@Path("{id}/remediations")
@Produces(MediaType.TEXT_XML)//from  w  w  w.  j a v  a2 s  . c  o  m
public Response getAttackPathRemediations(@Context HttpServletRequest request, @PathParam("id") int id) {
    Monitoring monitoring = ((Monitoring) request.getSession(true).getAttribute("monitoring"));
    Database db = ((Database) request.getSession(true).getAttribute("database"));

    if (monitoring == null || db == null)
        return Response.status(Status.NO_CONTENT).build();

    Element remediationXML = org.fiware.cybercaptor.server.api.AttackPathManagement
            .getRemediationXML(monitoring, id, db);
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());

    if (remediationXML == null)
        return Response.status(Status.PRECONDITION_FAILED).build();
    return Response.ok(output.outputString(remediationXML)).build();
}

From source file:org.fiware.cybercaptor.server.rest.RestAPIAttackPaths.java

License:Open Source License

@GET
@Path("attack_graph")
@Produces(MediaType.TEXT_XML)//from ww w .  ja  v  a  2s  . c o  m
public Response getAttackGraph(@Context HttpServletRequest request) {
    Monitoring monitoring = ((Monitoring) request.getSession(true).getAttribute("monitoring"));

    if (monitoring == null)
        return Response.status(Status.NO_CONTENT).build();

    Element attackGraphXML = monitoring.getAttackGraph().toDomElement();
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat());
    return Response.ok(output.outputString(attackGraphXML)).build();
}

From source file:org.fiware.cybercaptor.server.rest.RestJsonAPI.java

License:Open Source License

/**
 * Get the XML topology// w ww .j a v a 2 s.  c  om
 *
 * @param request the HTTP Request
 * @return the HTTP Response
 */
@GET
@Path("/topology")
@Produces(MediaType.APPLICATION_XML)
public Response getTopology(@Context HttpServletRequest request) {
    Monitoring monitoring = ((Monitoring) request.getSession(true).getAttribute("monitoring"));

    if (monitoring == null) {
        return Response.ok("The monitoring object is empty. Did you forget to " + "initialize it ?").build();
    }
    return Response.ok(new XMLOutputter(Format.getPrettyFormat())
            .outputString(monitoring.getInformationSystem().toDomXMLElement())).build();
}