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 shouldParseEncodedUrl.
@Test
public void shouldParseEncodedUrl() {
String output = "<?xml version=\"1.0\"?>\n" + "<info>\n" + "<entry\n" + " kind=\"dir\"\n" + " path=\"trunk\"\n" + " revision=\"8650\">\n" + "<url>https://217.45.214.17:8443/svn/Entropy%20System/Envoy%20Enterprise/trunk</url>\n" + "<repository>\n" + "<root>https://217.45.214.17:8443/svn</root>\n" + "<uuid>3ed677eb-f12f-3343-ac77-786e4d01a301</uuid>\n" + "</repository>\n" + "<commit\n" + " revision=\"8650\">\n" + "<author>BuildServer</author>\n" + "<date>2009-04-03 15:52:16 +0800 (Fri, 03 Apr 2009)</date>\n" + "</commit>\n" + "</entry>\n" + "</info>";
SvnCommand.SvnInfo svnInfo = new SvnCommand.SvnInfo();
svnInfo.parse(output, new SAXBuilder());
assertThat(svnInfo.getUrl(), is("https://217.45.214.17:8443/svn/Entropy%20System/Envoy%20Enterprise/trunk"));
assertThat(svnInfo.getPath(), is("/Entropy System/Envoy Enterprise/trunk"));
}
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 opentheso by miledrousset.
the class importxml method ouvreFichier2.
/**
* cette funtion permet de ouvrir un fichier pour comencée a faire une
* injection de données.
* Cette funtion c'est la generique
* @param ds
* @param archive
* @throws ClassNotFoundException
* @throws SQLException
*/
public void ouvreFichier2(HikariDataSource ds, File archive) throws ClassNotFoundException, SQLException {
LanguageBean langueBean = new LanguageBean();
SAXBuilder builder = new SAXBuilder();
ArrayList<Table> toutTables = new ArrayList<>();
ArrayList<LineOfData> lineOfDatas = new ArrayList<>();
try {
// on crée le document a partir du fichier que on a selectioné
Document document = (Document) builder.build(archive);
// Se obtiene la raiz 'tables'
Element rootNode = document.getRootElement();
// ici on a toutes les tables (les enfants de la racine)
List list = rootNode.getChildren("table");
// ici on fait le tour pour les enfants de 'tables'
for (int i = 0; i < list.size(); i++) {
// ici on a la première table
Element tabla = (Element) list.get(i);
// ici on a le nom de la table
String nombreTabla = tabla.getAttributeValue("nom");
// ici c'est la liste des lignes de la table
List lista_campos = tabla.getChildren();
// ici on découpe la liste des lignes
for (int j = 0; j < lista_campos.size(); j++) {
// ici on a une ligne de la table
Element campo = (Element) lista_campos.get(j);
for (Element colonne : campo.getChildren()) {
LineOfData lineOfData = new LineOfData();
lineOfData.setColomne(colonne.getName());
lineOfData.setValue(colonne.getText());
lineOfDatas.add(lineOfData);
}
insertLine2(ds, lineOfDatas, nombreTabla);
lineOfDatas.clear();
}
// / mettre à jour la table dans la BDD
}
} catch (IOException | JDOMException io) {
System.out.println(io.toString());
}
// FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(langueBean.getMsg("info") + " :", langueBean.getMsg("impBDD.info1")));
}
Aggregations