use of org.jdom2.input.SAXBuilder 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);
}
}
use of org.jdom2.input.SAXBuilder in project gocd by gocd.
the class SvnCommandTest method shouldParseSvnInfoWithParthDifferentFromUrl.
@Test
public void shouldParseSvnInfoWithParthDifferentFromUrl() throws Exception {
String output = "<?xml version=\"1.0\"?>\n" + "<info>\n" + "<entry\n" + " kind=\"dir\"\n" + " path=\"PurchaseDeliverables\"\n" + " revision=\"36788\">\n" + "<url>http://svn.somewhere.com/someotherline/bloresvn/TISSIP/branch/DEV/PurchaseDeliverables</url>\n" + "<repository>\n" + "<root>http://svn.somewhere.com/someotherline</root>\n" + "<uuid>f6689194-972b-e749-89bf-11ebdadc4dc5</uuid>\n" + "</repository>\n" + "<commit\n" + " revision=\"26449\">\n" + "<author>nigelfer</author>\n" + "<date>2009-02-03T15:43:08.059944Z</date>\n" + "</commit>\n" + "</entry>\n" + "</info>";
SvnCommand.SvnInfo svnInfo = new SvnCommand.SvnInfo();
svnInfo.parse(output, new SAXBuilder());
assertThat(svnInfo.getPath(), is("/bloresvn/TISSIP/branch/DEV/PurchaseDeliverables"));
assertThat(svnInfo.getUrl(), is("http://svn.somewhere.com/someotherline/bloresvn/TISSIP/branch/DEV/PurchaseDeliverables"));
}
use of org.jdom2.input.SAXBuilder in project gocd by gocd.
the class SvnCommandTest method shouldParseSvnInfo.
@Test
public void shouldParseSvnInfo() throws Exception {
String output = "<?xml version=\"1.0\"?>\n" + "<info>\n" + "<entry\n" + " kind=\"dir\"\n" + " path=\"someotherline\"\n" + " revision=\"36788\">\n" + "<url>http://svn.somewhere.com/svn/someotherline</url>\n" + "<repository>\n" + "<root>http://svn.somewhere.com/svn</root>\n" + "<uuid>f6689194-972b-e749-89bf-11ebdadc4dc5</uuid>\n" + "</repository>\n" + "<commit\n" + " revision=\"36788\">\n" + "<author>csebasti</author>\n" + "<date>2009-05-30T17:47:27.435599Z</date>\n" + "</commit>\n" + "</entry>\n" + "</info>";
SvnCommand.SvnInfo svnInfo = new SvnCommand.SvnInfo();
svnInfo.parse(output, new SAXBuilder());
assertThat(svnInfo.getPath(), is("/someotherline"));
assertThat(svnInfo.getUrl(), is("http://svn.somewhere.com/svn/someotherline"));
assertThat(svnInfo.getRoot(), is("http://svn.somewhere.com/svn"));
}
use of org.jdom2.input.SAXBuilder in project gocd by gocd.
the class SvnCommand method getAllExternalURLs.
public List<SvnExternal> getAllExternalURLs() {
CommandLine svnExternalCommand = svn(true).withArgs("propget", "--non-interactive", "svn:externals", "-R").withArg(repositoryUrl);
ConsoleResult result = executeCommand(svnExternalCommand);
String svnExternalConsoleOut = result.outputAsString();
SvnInfo remoteInfo = remoteInfo(new SAXBuilder());
String repoUrl = remoteInfo.getUrl();
String repoRoot = remoteInfo.getRoot();
List<SvnExternal> svnExternalList = null;
try {
svnExternalList = new SvnExternalParser().parse(svnExternalConsoleOut, repoUrl, repoRoot);
} catch (RuntimeException e) {
throw (RuntimeException) result.smudgedException(e);
}
return svnExternalList;
}
use of org.jdom2.input.SAXBuilder in project gocd by gocd.
the class SvnCommand method getBuilder.
private SAXBuilder getBuilder() {
SAXBuilder saxBuilder = saxBuilderThreadLocal.get();
if (saxBuilder == null) {
saxBuilder = new SAXBuilder();
saxBuilderThreadLocal.set(saxBuilder);
}
return saxBuilder;
}
Aggregations