List of usage examples for javax.xml.parsers ParserConfigurationException getMessage
public String getMessage()
From source file:org.apache.cayenne.dbimport.DefaultReverseEngineeringLoader.java
@Override public ReverseEngineering load(InputStream inputStream) throws IOException, ReverseEngineeringLoaderException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = null; try {//from w w w .java2s . c o m dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(inputStream); ReverseEngineering engineering = new ReverseEngineering(); Element root = doc.getDocumentElement(); engineering.setSkipRelationshipsLoading(loadBoolean(root, "skipRelationshipsLoading")); engineering.setSkipPrimaryKeyLoading(loadBoolean(root, "skipPrimaryKeyLoading")); engineering.setTableTypes(loadTableTypes(root)); engineering.setCatalogs(loadCatalogs(root)); engineering.setSchemas(loadSchemas(root)); engineering.setIncludeTables(loadIncludeTables(root)); engineering.setExcludeTables(loadExcludeTables(root)); engineering.setIncludeColumns(loadIncludeColumns(root)); engineering.setExcludeColumns(loadExcludeColumns(root)); engineering.setIncludeProcedures(loadIncludeProcedures(root)); engineering.setExcludeProcedures(loadExcludeProcedures(root)); return engineering; } catch (ParserConfigurationException e) { throw new ReverseEngineeringLoaderException(e.getMessage(), e); } catch (SAXException e) { throw new ReverseEngineeringLoaderException(e.getMessage(), e); } }
From source file:org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoader.java
@Override public ReverseEngineering load(Resource configurationResource) throws CayenneRuntimeException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); try {//w w w.j ava 2 s . c om DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(configurationResource.getURL().openStream()); ReverseEngineering engineering = new ReverseEngineering(); Element root = doc.getDocumentElement(); engineering.setSkipRelationshipsLoading(loadBoolean(root, "skipRelationshipsLoading")); engineering.setSkipPrimaryKeyLoading(loadBoolean(root, "skipPrimaryKeyLoading")); engineering.setTableTypes(loadTableTypes(root)); engineering.setCatalogs(loadCatalogs(root)); engineering.setSchemas(loadSchemas(root)); engineering.setIncludeTables(loadIncludeTables(root)); engineering.setExcludeTables(loadExcludeTables(root)); engineering.setIncludeColumns(loadIncludeColumns(root)); engineering.setExcludeColumns(loadExcludeColumns(root)); engineering.setIncludeProcedures(loadIncludeProcedures(root)); engineering.setExcludeProcedures(loadExcludeProcedures(root)); return engineering; } catch (ParserConfigurationException e) { LOG.info(e.getMessage(), e); } catch (SAXException e) { LOG.info(e.getMessage(), e); } catch (IOException e) { LOG.info(e.getMessage(), e); } return null; }
From source file:org.apache.jackrabbit.webdav.client.methods.BaselineControlMethod.java
public BaselineControlMethod(String uri, String baselineHref) throws IOException { super(uri);//from w w w . ja v a2 s . c o m if (baselineHref != null) { // build the request body try { // create the document and attach the root element Document document = DomUtil.createDocument(); Element el = DomUtil.addChildElement(document, "baseline-control", DeltaVConstants.NAMESPACE); el.appendChild(DomUtil.hrefToXml(baselineHref, document)); // set the request body setRequestBody(document); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } } }
From source file:org.apache.jackrabbit.webdav.client.methods.PropFindMethod.java
public PropFindMethod(String uri, int propfindType, DavPropertyNameSet propNameSet, int depth) throws IOException { super(uri);/*from w ww.ja va 2 s . co m*/ DepthHeader dh = new DepthHeader(depth); setRequestHeader(dh.getHeaderName(), dh.getHeaderValue()); // build the request body try { // create the document and attach the root element Document document = DomUtil.createDocument(); Element propfind = DomUtil.createElement(document, XML_PROPFIND, NAMESPACE); document.appendChild(propfind); // fill the propfind element switch (propfindType) { case PROPFIND_ALL_PROP: propfind.appendChild(DomUtil.createElement(document, XML_ALLPROP, NAMESPACE)); break; case PROPFIND_PROPERTY_NAMES: propfind.appendChild(DomUtil.createElement(document, XML_PROPNAME, NAMESPACE)); break; case PROPFIND_BY_PROPERTY: if (propNameSet == null) { // name set missing, ask for a property that is known to exist Element prop = DomUtil.createElement(document, XML_PROP, NAMESPACE); Element resourcetype = DomUtil.createElement(document, PROPERTY_RESOURCETYPE, NAMESPACE); prop.appendChild(resourcetype); propfind.appendChild(prop); } else { propfind.appendChild(propNameSet.toXml(document)); } break; case PROPFIND_ALL_PROP_INCLUDE: propfind.appendChild(DomUtil.createElement(document, XML_ALLPROP, NAMESPACE)); if (propNameSet != null && !propNameSet.isEmpty()) { Element include = DomUtil.createElement(document, XML_INCLUDE, NAMESPACE); Element prop = propNameSet.toXml(document); for (Node c = prop.getFirstChild(); c != null; c = c.getNextSibling()) { // copy over the children of <prop> to <include> element include.appendChild(c.cloneNode(true)); } propfind.appendChild(include); } break; default: throw new IllegalArgumentException("unknown propfind type"); } // set the request body setRequestBody(document); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } }
From source file:org.apache.jackrabbit.webdav.client.methods.PropPatchMethod.java
/** * * @param uri/*from w ww .j av a 2s . c om*/ * @param changeList list of DavProperty (for 'set') and DavPropertyName * (for 'remove') entries. * @throws IOException */ public PropPatchMethod(String uri, List<? extends PropEntry> changeList) throws IOException { super(uri); if (changeList == null || changeList.isEmpty()) { throw new IllegalArgumentException( "PROPPATCH cannot be executed without properties to be set or removed."); } try { Document document = DomUtil.createDocument(); Element propUpdateElement = DomUtil.addChildElement(document, XML_PROPERTYUPDATE, NAMESPACE); Element propElement = null; boolean isSet = false; for (Object entry : changeList) { if (entry instanceof DavPropertyName) { // DAV:remove DavPropertyName removeName = (DavPropertyName) entry; if (propElement == null || isSet) { isSet = false; propElement = getPropElement(propUpdateElement, isSet); } propElement.appendChild(removeName.toXml(document)); propertyNames.add(removeName); } else if (entry instanceof DavProperty) { // DAV:set DavProperty<?> setProperty = (DavProperty<?>) entry; if (propElement == null || !isSet) { isSet = true; propElement = getPropElement(propUpdateElement, isSet); } propElement.appendChild(setProperty.toXml(document)); propertyNames.add(setProperty.getName()); } else { throw new IllegalArgumentException( "ChangeList may only contain DavPropertyName and DavProperty elements."); } } setRequestBody(document); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } }
From source file:org.apache.jackrabbit.webdav.client.methods.PropPatchMethod.java
public PropPatchMethod(String uri, DavPropertySet setProperties, DavPropertyNameSet removeProperties) throws IOException { super(uri);//from w ww. j a v a 2 s . c o m if (setProperties == null || removeProperties == null) { throw new IllegalArgumentException("Neither setProperties nor removeProperties must be null."); } if (setProperties.isEmpty() && removeProperties.isEmpty()) { throw new IllegalArgumentException( "Either setProperties or removeProperties can be empty; not both of them."); } propertyNames.addAll(removeProperties); for (DavPropertyName setName : setProperties.getPropertyNames()) { propertyNames.add(setName); } try { Document document = DomUtil.createDocument(); Element propupdate = DomUtil.addChildElement(document, XML_PROPERTYUPDATE, NAMESPACE); // DAV:set if (!setProperties.isEmpty()) { Element set = DomUtil.addChildElement(propupdate, XML_SET, NAMESPACE); set.appendChild(setProperties.toXml(document)); } // DAV:remove if (!removeProperties.isEmpty()) { Element remove = DomUtil.addChildElement(propupdate, XML_REMOVE, NAMESPACE); remove.appendChild(removeProperties.toXml(document)); } setRequestBody(document); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } }
From source file:org.apache.oodt.product.handlers.ofsn.util.OFSNUtils.java
public static Document getOFSNDoc(List<File> fileList, OFSNHandlerConfig cfg, String productRoot, boolean showDirSize, boolean showFileSize) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true);//from ww w. j av a2 s . c o m Document document; try { DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.newDocument(); Element root = (Element) document.createElement(DIR_RESULT_TAG); XMLUtils.addAttribute(document, root, "xmlns", DIR_LISTING_NS); document.appendChild(root); for (File file : fileList) { Element dirEntryElem = XMLUtils.addNode(document, root, DIR_ENTRY_TAG); String ofsn = toOFSN(file.getAbsolutePath(), productRoot); //This ensures that we get ofsn names with unix style separators. //On a Windows machine, the product server would return '\' //separators. String unixStyleOFSN = FilenameUtils.separatorsToUnix(ofsn); if (cfg.getType().equals(LISTING_CMD)) { if (!Boolean.valueOf(cfg.getHandlerConf().getProperty("isSizeCmd"))) { XMLUtils.addNode(document, dirEntryElem, OFSN_TAG, unixStyleOFSN); } } long size = Long.MIN_VALUE; if (file.isDirectory()) { if (showDirSize) { size = FileUtils.sizeOfDirectory(file); } } else { if (showFileSize) { size = file.length(); } } if (size != Long.MIN_VALUE) { XMLUtils.addNode(document, dirEntryElem, FILE_SIZE_TAG, String.valueOf(size)); } } return document; } catch (ParserConfigurationException e) { LOG.log(Level.SEVERE, e.getMessage()); return null; } }
From source file:org.apache.rave.portal.service.impl.DefaultOmdlService.java
private Document initializeBuilder(String rawXml) { Document xmlRoot = null;/*from w ww. j a va2 s. c om*/ try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); xmlRoot = db.parse(new InputSource(new StringReader(rawXml))); } catch (ParserConfigurationException e) { logger.error(e.getMessage()); throw new RuntimeException(e); } catch (SAXException e) { logger.error(e.getMessage()); throw new RuntimeException(e); } catch (IOException e) { logger.error(e.getMessage()); throw new RuntimeException(e); } return xmlRoot; }
From source file:org.apache.webdav.lib.methods.XMLResponseMethodBase.java
protected void parseXMLResponse(InputStream input) throws IOException, HttpException { if (builder == null) { try {/*from w w w . jav a 2 s . c o m*/ // TODO: avoid the newInstance call for each method instance for performance reasons. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); builder = factory.newDocumentBuilder(); } catch (ParserConfigurationException e) { throw new HttpException("XML Parser Configuration error: " + e.getMessage()); } } try { // avoid ugly printlns from the default error handler. builder.setErrorHandler(new DummyErrorHandler()); responseDocument = builder.parse(new InputSource(input)); if (debug > 0) { System.out.println("\n<<<<<<< from server ---------------------------------------------------"); System.out.println(getStatusLine()); Header[] headers = getResponseHeaders(); for (int i = 0; i < headers.length; i++) { Header header = headers[i]; System.out.print(header.toString()); } System.out.println(); xo.print(responseDocument); System.out.println("------------------------------------------------------------------------"); } } catch (Exception e) { throw new IOException("XML parsing error; response stream is not valid XML: " + e.getMessage()); } // init the response table to display the responses during debugging /*if (debug > 10) { //if (log.isDebugEnabled()) { initResponseHashtable(); }*/ }
From source file:org.apache.wiki.auth.user.XMLUserDatabase.java
private void buildDOM() { // Read DOM/*from ww w . j a va 2 s . c o m*/ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setExpandEntityReferences(false); factory.setIgnoringComments(true); factory.setNamespaceAware(false); try { c_dom = factory.newDocumentBuilder().parse(c_file); log.debug("Database successfully initialized"); c_lastModified = c_file.lastModified(); c_lastCheck = System.currentTimeMillis(); } catch (ParserConfigurationException e) { log.error("Configuration error: " + e.getMessage()); } catch (SAXException e) { log.error("SAX error: " + e.getMessage()); } catch (FileNotFoundException e) { log.info("User database not found; creating from scratch..."); } catch (IOException e) { log.error("IO error: " + e.getMessage()); } if (c_dom == null) { try { // // Create the DOM from scratch // c_dom = factory.newDocumentBuilder().newDocument(); c_dom.appendChild(c_dom.createElement("users")); } catch (ParserConfigurationException e) { log.fatal("Could not create in-memory DOM"); } } }