Search in sources :

Example 36 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class SystemParamsUtils method getXMLDocument.

public static String getXMLDocument(Document doc) {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(doc);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format)

Example 37 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class ApsPropertiesDOM method getXMLDocument.

/**
 * Restituisce il formato xml delle Properties.
 * @return String Formato xml delle Properties.
 */
public String getXMLDocument() {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("");
    out.setFormat(format);
    return out.outputString(_doc);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format)

Example 38 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class SystemInstallationReport method toXml.

public String toXml() {
    Document doc = new Document();
    Element rootElement = new Element(ROOT_ELEMENT);
    Status status = Status.OK;
    for (ComponentInstallationReport componentReport : this.getReports()) {
        if (!componentReport.getStatus().equals(Status.OK) && !componentReport.getStatus().equals(Status.UNINSTALLED)) {
            status = componentReport.getStatus();
            break;
        }
    }
    rootElement.setAttribute(STATUS_ATTRIBUTE, status.toString());
    Element creationElement = new Element(CREATION_ELEMENT);
    creationElement.setText(DateConverter.getFormattedDate(this.getCreation(), DATE_FORMAT));
    rootElement.addContent(creationElement);
    Element lastUpdateElement = new Element(LAST_UPDATE_ELEMENT);
    lastUpdateElement.setText(DateConverter.getFormattedDate(this.getLastUpdate(), DATE_FORMAT));
    rootElement.addContent(lastUpdateElement);
    Element componentsElement = new Element(COMPONENTS_ELEMENT);
    rootElement.addContent(componentsElement);
    for (int i = 0; i < this.getReports().size(); i++) {
        ComponentInstallationReport singleReport = this.getReports().get(i);
        Element componentElement = singleReport.toJdomElement();
        componentsElement.addContent(componentElement);
    }
    doc.setRootElement(rootElement);
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("\t");
    out.setFormat(format);
    return out.outputString(doc);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format) Element(org.jdom.Element) Document(org.jdom.Document)

Example 39 with Format

use of org.jdom.output.Format in project entando-core by entando.

the class ServiceExtraConfigDOM method getXMLDocument.

protected String getXMLDocument() {
    XMLOutputter out = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    out.setFormat(format);
    return out.outputString(this._doc);
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) Format(org.jdom.output.Format)

Example 40 with Format

use of org.jdom.output.Format in project build-info by JFrogDev.

the class PomTransformer method transform.

/**
 * Performs the transformation.
 *
 * @return True if the file was modified.
 */
public Boolean transform(File pomFile) throws IOException {
    this.pomFile = pomFile;
    if (!pomFile.exists()) {
        throw new IllegalArgumentException("Couldn't find pom file: " + pomFile);
    }
    SAXBuilder saxBuilder = createSaxBuilder();
    Document document;
    EolDetectingInputStream eolDetectingStream = null;
    InputStreamReader inputStreamReader = null;
    try {
        eolDetectingStream = new EolDetectingInputStream(new FileInputStream(pomFile));
        inputStreamReader = new InputStreamReader(eolDetectingStream, "UTF-8");
        document = saxBuilder.build(inputStreamReader);
    } catch (JDOMException e) {
        throw new IOException("Failed to parse pom: " + pomFile.getAbsolutePath(), e);
    } finally {
        IOUtils.closeQuietly(inputStreamReader);
        IOUtils.closeQuietly(eolDetectingStream);
    }
    Element rootElement = document.getRootElement();
    Namespace ns = rootElement.getNamespace();
    getProperties(rootElement, ns);
    changeParentVersion(rootElement, ns);
    changeCurrentModuleVersion(rootElement, ns);
    // changePropertiesVersion(rootElement, ns);
    changeDependencyManagementVersions(rootElement, ns);
    changeDependencyVersions(rootElement, ns);
    if (scmUrl != null) {
        changeScm(rootElement, ns);
    }
    if (modified && !dryRun) {
        FileOutputStream fileOutputStream = new FileOutputStream(pomFile);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF-8");
        try {
            XMLOutputter outputter = new XMLOutputter();
            String eol = eolDetectingStream.getEol();
            if (!"".equals(eol)) {
                Format format = outputter.getFormat();
                format.setLineSeparator(eol);
                format.setTextMode(Format.TextMode.PRESERVE);
                outputter.setFormat(format);
            }
            outputter.output(document, outputStreamWriter);
        } finally {
            IOUtils.closeQuietly(outputStreamWriter);
            IOUtils.closeQuietly(fileOutputStream);
        }
    }
    return modified;
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) Namespace(org.jdom.Namespace) Format(org.jdom.output.Format) EolDetectingInputStream(org.jfrog.build.extractor.EolDetectingInputStream)

Aggregations

Format (org.jdom.output.Format)45 XMLOutputter (org.jdom.output.XMLOutputter)40 Document (org.jdom.Document)20 Element (org.jdom.Element)20 StringWriter (java.io.StringWriter)11 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)6 Namespace (org.jdom.Namespace)6 Writer (java.io.Writer)5 SAXBuilder (org.jdom.input.SAXBuilder)5 DateFormat (java.text.DateFormat)4 SimpleDateFormat (java.text.SimpleDateFormat)4 JDOMException (org.jdom.JDOMException)4 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 File (java.io.File)3 FileWriter (java.io.FileWriter)3 StringReader (java.io.StringReader)3 List (java.util.List)3 TreeMap (java.util.TreeMap)3 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3