Search in sources :

Example 6 with Element

use of org.jdom2.Element in project gocd by gocd.

the class GoControlLog method writeLogFile.

/**
     * Writes the current build log to the appropriate directory and filename.
     */
public void writeLogFile(Date now) throws IOException {
    String logFilename = decideLogfileName(now);
    // Add the logDir as an info element
    Element logDirElement = new Element("property");
    logDirElement.setAttribute("name", "logdir");
    logDirElement.setAttribute("value", new File(logDir).getAbsolutePath());
    buildLog.getChild("info").addContent(logDirElement);
    // Add the logFile as an info element
    Element logFileElement = new Element("property");
    logFileElement.setAttribute("name", "logfile");
    logFileElement.setAttribute("value", logFilename);
    buildLog.getChild("info").addContent(logFileElement);
    File logfile = new File(logDir, logFilename);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Writing log file [" + logfile.getAbsolutePath() + "]");
    }
    writeLogFile(logfile, buildLog);
}
Also used : Element(org.jdom2.Element) File(java.io.File)

Example 7 with Element

use of org.jdom2.Element in project gocd by gocd.

the class BuildLogElement method setBuildLogHeader.

public Element setBuildLogHeader(String execCommand) {
    Element target = new Element("target");
    target.setAttribute("name", "exec");
    build.addContent(target);
    buildTask = new Element("task");
    buildTask.setAttribute("name", execCommand);
    target.addContent(buildTask);
    return buildTask;
}
Also used : Element(org.jdom2.Element)

Example 8 with Element

use of org.jdom2.Element in project gocd by gocd.

the class StageCctrayPresentationModelTest method shouldContainBuilds.

private void shouldContainBuilds(Element root) {
    Element buildProject = findChildByName(root, "cruise :: ft :: firefox");
    assertThat(buildProject, hasAttribute("activity", "Sleeping"));
    assertThat(buildProject, hasAttribute("lastBuildStatus", "Success"));
    assertThat(buildProject, hasAttribute("lastBuildLabel", String.valueOf(LABEL)));
    assertThat(buildProject, hasAttribute("lastBuildTime", DATE_STR));
    assertThat(buildProject, hasAttribute("webUrl", buildDetailUrl()));
}
Also used : Element(org.jdom2.Element)

Example 9 with Element

use of org.jdom2.Element in project gocd by gocd.

the class StageCctrayPresentationModelTest method shouldGetGoodCctrayXml.

@Test
public void shouldGetGoodCctrayXml() throws Exception {
    Element root = new Element("Projects");
    cctrayXmlPresenter.toCctrayXml(root, CONTEXT_PATH);
    assertThat(root.getChildren().size(), is(2));
    shouldContainStage(root);
    shouldContainBuilds(root);
}
Also used : Element(org.jdom2.Element) Test(org.junit.Test)

Example 10 with Element

use of org.jdom2.Element in project gocd by gocd.

the class GoConfigMigration method getCurrentSchemaVersion.

private int getCurrentSchemaVersion(String content) {
    try {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(new ByteArrayInputStream(content.getBytes()));
        Element root = document.getRootElement();
        String currentVersion = root.getAttributeValue(schemaVersion) == null ? "0" : root.getAttributeValue(schemaVersion);
        return Integer.parseInt(currentVersion);
    } catch (Exception e) {
        throw bomb(e);
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) Document(org.jdom2.Document) XmlUtils.buildXmlDocument(com.thoughtworks.go.util.XmlUtils.buildXmlDocument) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException)

Aggregations

Element (org.jdom2.Element)673 Attribute (org.jdom2.Attribute)103 Document (org.jdom2.Document)64 File (java.io.File)49 ArrayList (java.util.ArrayList)36 NamedIcon (jmri.jmrit.catalog.NamedIcon)28 IOException (java.io.IOException)27 DataConversionException (org.jdom2.DataConversionException)26 JDOMException (org.jdom2.JDOMException)26 XmlFile (jmri.jmrit.XmlFile)24 Test (org.junit.Test)24 Editor (jmri.jmrit.display.Editor)22 DocType (org.jdom2.DocType)21 Turnout (jmri.Turnout)20 ProcessingInstruction (org.jdom2.ProcessingInstruction)16 Point (java.awt.Point)15 HashMap (java.util.HashMap)15 SignalHead (jmri.SignalHead)15 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)15 Dimension (java.awt.Dimension)14