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);
}
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);
}
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);
}
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);
}
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;
}
Aggregations