List of usage examples for org.jdom2.input SAXBuilder SAXBuilder
public SAXBuilder()
From source file:de.relaunch64.popelganda.database.CustomScripts.java
License:Open Source License
/** * Loads the scripts from an XML file/*from w ww. j a va 2 s . c om*/ */ public void loadScripts() { // if file exists, go on... if (filepath != null && filepath.exists()) { try { SAXBuilder builder = new SAXBuilder(); scriptFile = builder.build(filepath); } catch (JDOMException | IOException ex) { ConstantsR64.r64logger.log(Level.WARNING, ex.getLocalizedMessage()); } } }
From source file:de.relaunch64.popelganda.database.Settings.java
License:Open Source License
/** * Loads the settings file/*from w w w.j a v a 2s . c om*/ */ public void loadSettings() { // if file exists, go on... if (filepath != null && filepath.exists()) { try { SAXBuilder builder = new SAXBuilder(); settingsFile = builder.build(filepath); } catch (JDOMException | IOException ex) { ConstantsR64.r64logger.log(Level.WARNING, ex.getLocalizedMessage()); } } fillElements(); }
From source file:de.smartics.maven.alias.domain.AliasesProcessor.java
License:Apache License
/** * Default constructor.// ww w .j a v a2 s.c om * * @param source the source to read the alias XML document from. * @throws NullPointerException if {@code source} is <code>null</code>. * @throws IOException if the XML document cannot be read. * @throws JDOMException if the XML document cannot be parsed. */ public AliasesProcessor(final InputSource source) throws NullPointerException, IOException, JDOMException { if (source == null) { throw new NullPointerException("'source' must not be 'null'."); } final SAXBuilder sax = new SAXBuilder();// XMLReaders.XSDVALIDATING); this.doc = sax.build(source); this.nsAlias = doc.getRootElement().getNamespace(); final String uri = nsAlias.getURI(); if (!uri.startsWith(SUPPORTED_NAMESPACE_PREFIX)) { throw new JDOMException( "The namespace '" + nsAlias + "' is not supported. Namespace is required to start with '" + SUPPORTED_NAMESPACE_PREFIX + "'."); } }
From source file:de.smartics.maven.plugin.jboss.modules.parser.ModulesXmlParser.java
License:Apache License
/** * Default constructor. */ public ModulesXmlParser() { this.builder = new SAXBuilder(); }
From source file:de.smartics.maven.plugin.jboss.modules.xml.XmlFragmentParser.java
License:Apache License
/** * Default constructor. */ public XmlFragmentParser() { builder = new SAXBuilder(); }
From source file:de.sub.goobi.config.DigitalCollections.java
License:Open Source License
public static List<String> possibleDigitalCollectionsForProcess(Process process) throws JDOMException, IOException { List<String> result = new ArrayList<String>(); String filename = ConfigurationHelper.getInstance().getConfigurationFolder() + "goobi_digitalCollections.xml"; if (!Files.exists(Paths.get(filename))) { throw new FileNotFoundException("File not found: " + filename); }/*from www . ja va 2 s .c o m*/ /* Datei einlesen und Root ermitteln */ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(filename); Element root = doc.getRootElement(); /* alle Projekte durchlaufen */ List<Element> projekte = root.getChildren(); for (Iterator<Element> iter = projekte.iterator(); iter.hasNext();) { Element projekt = iter.next(); List<Element> projektnamen = projekt.getChildren("name"); for (Iterator<Element> iterator = projektnamen.iterator(); iterator.hasNext();) { Element projektname = iterator.next(); /* * wenn der Projektname aufgefhrt wird, dann alle Digitalen Collectionen in die Liste */ if (projektname.getText().equalsIgnoreCase(process.getProjekt().getTitel())) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); result.add(col.getText()); } } } } return result; }
From source file:de.sub.goobi.config.DigitalCollections.java
License:Open Source License
public static String getDefaultDigitalCollectionForProcess(Process process) throws JDOMException, IOException { String filename = ConfigurationHelper.getInstance().getConfigurationFolder() + "goobi_digitalCollections.xml"; if (!Files.exists(Paths.get(filename))) { throw new FileNotFoundException("File not found: " + filename); }//w w w .j a v a 2s . c o m String firstCollection = ""; /* Datei einlesen und Root ermitteln */ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(filename); Element root = doc.getRootElement(); /* alle Projekte durchlaufen */ List<Element> projekte = root.getChildren(); for (Iterator<Element> iter = projekte.iterator(); iter.hasNext();) { Element projekt = iter.next(); List<Element> projektnamen = projekt.getChildren("name"); for (Iterator<Element> iterator = projektnamen.iterator(); iterator.hasNext();) { Element projektname = iterator.next(); /* * wenn der Projektname aufgefhrt wird, dann alle Digitalen Collectionen in die Liste */ if (projektname.getText().equalsIgnoreCase(process.getProjekt().getTitel())) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); String collectionName = col.getText(); String defaultCollection = col.getAttributeValue("default"); if (defaultCollection.equalsIgnoreCase("true")) { return collectionName; } if (StringUtils.isBlank(firstCollection)) { firstCollection = collectionName; } } } } } return firstCollection; }
From source file:de.sub.goobi.forms.MassImportForm.java
License:Open Source License
/** * generate a list with all possible collections for given project */// w w w. j ava2s. c om private void initializePossibleDigitalCollections() { this.possibleDigitalCollection = new ArrayList<>(); ArrayList<String> defaultCollections = new ArrayList<>(); String filename = this.help.getGoobiConfigDirectory() + "goobi_digitalCollections.xml"; if (!StorageProvider.getInstance().isFileExists(Paths.get(filename))) { Helper.setFehlerMeldung("File not found: ", filename); return; } this.digitalCollections = new ArrayList<>(); try { /* Datei einlesen und Root ermitteln */ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(filename); Element root = doc.getRootElement(); /* alle Projekte durchlaufen */ List<Element> projekte = root.getChildren(); for (Iterator<Element> iter = projekte.iterator(); iter.hasNext();) { Element projekt = iter.next(); // collect default collections if (projekt.getName().equals("default")) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } defaultCollections.add(col.getText()); } } else { // run through the projects List<Element> projektnamen = projekt.getChildren("name"); for (Iterator<Element> iterator = projektnamen.iterator(); iterator.hasNext();) { Element projektname = iterator.next(); // all all collections to list if (projektname.getText().equalsIgnoreCase(this.template.getProjekt().getTitel())) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } this.possibleDigitalCollection.add(col.getText()); } } } } } } catch (JDOMException e1) { log.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } catch (IOException e1) { log.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } if (this.possibleDigitalCollection.size() == 0) { this.possibleDigitalCollection = defaultCollections; } }
From source file:de.sub.goobi.forms.ProzesskopieForm.java
License:Open Source License
private void initializePossibleDigitalCollections() { this.possibleDigitalCollection = new ArrayList<>(); ArrayList<String> defaultCollections = new ArrayList<>(); String filename = this.help.getGoobiConfigDirectory() + "goobi_digitalCollections.xml"; if (!StorageProvider.getInstance().isFileExists(Paths.get(filename))) { Helper.setFehlerMeldung("File not found: ", filename); return;//from ww w. j av a 2 s . co m } this.digitalCollections = new ArrayList<>(); try { /* Datei einlesen und Root ermitteln */ SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(filename); Element root = doc.getRootElement(); /* alle Projekte durchlaufen */ List<Element> projekte = root.getChildren(); for (Iterator<Element> iter = projekte.iterator(); iter.hasNext();) { Element projekt = iter.next(); // collect default collections if (projekt.getName().equals("default")) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } defaultCollections.add(col.getText()); } } else { // run through the projects List<Element> projektnamen = projekt.getChildren("name"); for (Iterator<Element> iterator = projektnamen.iterator(); iterator.hasNext();) { Element projektname = iterator.next(); // all all collections to list if (projektname.getText().equalsIgnoreCase(this.prozessKopie.getProjekt().getTitel())) { List<Element> myCols = projekt.getChildren("DigitalCollection"); for (Iterator<Element> it2 = myCols.iterator(); it2.hasNext();) { Element col = it2.next(); if (col.getAttribute("default") != null && col.getAttributeValue("default").equalsIgnoreCase("true")) { digitalCollections.add(col.getText()); } this.possibleDigitalCollection.add(col.getText()); } } } } } } catch (JDOMException e1) { logger.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } catch (IOException e1) { logger.error("error while parsing digital collections", e1); Helper.setFehlerMeldung("Error while parsing digital collections", e1); } if (this.possibleDigitalCollection.size() == 0) { this.possibleDigitalCollection = defaultCollections; } // if only one collection is possible take it directly if (isSingleChoiceCollection()) { this.digitalCollections.add(getDigitalCollectionIfSingleChoice()); } }
From source file:de.sub.goobi.helper.HelperSchritte.java
License:Open Source License
public static void extractAuthorityMetadata(Path metadataFile, Map<String, List<String>> metadataPairs) { XPathFactory xFactory = XPathFactory.instance(); XPathExpression<Element> authorityMetaXpath = xFactory.compile( "//mets:xmlData/mods:mods/mods:extension/goobi:goobi/goobi:metadata[goobi:authorityValue]", Filters.element(), null, mods, mets, goobiNamespace); SAXBuilder builder = new SAXBuilder(); Document doc;/*from www . jav a2 s . co m*/ try { doc = builder.build(metadataFile.toString()); } catch (JDOMException | IOException e1) { return; } for (Element meta : authorityMetaXpath.evaluate(doc)) { String name = meta.getAttributeValue("name"); if (name == null) { continue; } else { String key = name + "_authority"; List<String> values = metadataPairs.get(key); if (values == null) { values = new ArrayList<>(); metadataPairs.put(key, values); } values.add(meta.getChildText("authorityValue", goobiNamespace)); } } }