List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace
public void printStackTrace()
From source file:com.library.essay.tinymce.spellchecker.GoogleSpellChekerServlet.java
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); try {//from w ww. ja va2 s .co m JSONObject requestJSONdata = requestDataToJSON(request.getInputStream()); String method = requestJSONdata.getString("method"); String language = requestJSONdata.getJSONArray("params").getString(0); this.connect(language); this.setHeaders(); String textToCheck; if (method.equalsIgnoreCase("checkWords")) { JSONArray words = requestJSONdata.getJSONArray("params").getJSONArray(1); textToCheck = words.join(" ").replaceAll("\"", ""); } else if (method.equalsIgnoreCase("getSuggestions")) { textToCheck = requestJSONdata.getJSONArray("params").getString(1); } else { out.println( "{\"id\":null,\"results\":null,\"error\":\"Invalid request, method not yet implemented\"}"); out.flush(); return; } this.sendData(getXML(textToCheck)); JSONObject responseJSON = this.receiveData(method, textToCheck); if (responseJSON == null) { out.println("{\"id\":null,\"results\":null,\"error\":\"No suggestions were received\"}"); out.flush(); return; } responseJSON.write(out); out.flush(); } catch (JSONException e1) { //Send error to client, exit out.println("{\"id\":null,\"results\":null,\"error\":\"Invalid request, cannot parse json data\"}"); out.flush(); return; } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } }
From source file:de.uni_potsdam.hpi.bpt.promnicat.importer.sap_rm.SapReferenceModelImporter.java
@Override public void importModelsFrom(String modelDirectory) throws IOException, JSONException { persistenceApi.openDb();/*from w w w .jav a 2 s. c o m*/ File rootDir = super.checkModelPath(modelDirectory, true); Collection<File> files = super.getFilesRecursivelyFromDir(rootDir); for (File file : files) { try { splitEPML(file); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } } persistenceApi.closeDb(); }
From source file:de.ingrid.iplug.opensearch.query.OSDescriptorBuilder.java
/** * Request the descriptorAddress and return an OSDescriptor object. * /* w w w. j av a 2 s . co m*/ * @param descriptorAddress * @return * @throws Exception */ public OSDescriptor receiveDescriptor(String descriptorAddress) throws Exception { OSCommunication comm = new OSCommunication(); OSDescriptor osDesciptor = new OSDescriptor(); try { InputStream response = comm.sendRequest(descriptorAddress); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document descriptorDoc = builder.parse(response); XPath xpath = XPathFactory.newInstance().newXPath(); NodeList typeList = (NodeList) xpath.evaluate("/OpenSearchDescription/Url/@type", descriptorDoc, XPathConstants.NODESET); NodeList templateList = (NodeList) xpath.evaluate("/OpenSearchDescription/Url/@template", descriptorDoc, XPathConstants.NODESET); for (int i = 0; i < typeList.getLength(); i++) { osDesciptor.setTypeAndUrl(typeList.item(i).getTextContent(), templateList.item(i).getTextContent()); } } catch (ParserConfigurationException e) { log.error("Error while parsing DescriptorFile from: " + descriptorAddress); e.printStackTrace(); } catch (SAXException e) { log.error("Error while parsing DescriptorFile from: " + descriptorAddress); e.printStackTrace(); } catch (XPathExpressionException e) { log.error("Error while parsing DescriptorFile from: " + descriptorAddress); e.printStackTrace(); } finally { comm.releaseConnection(); } return osDesciptor; }
From source file:com.oprisnik.semdroid.SemdroidServlet.java
public String getResults(SemdroidReport results, InputStream transformationStyle) { try {//ww w.j a va2 s . c o m Document doc = XmlUtils.createDocument(); Element rootElement = doc.createElement("AnalysisResults"); doc.appendChild(rootElement); XmlUtils.addResults(results, doc, rootElement); StringWriter writer = new StringWriter(); TransformerFactory transformerFactory = TransformerFactory.newInstance(); StreamSource stylesource = new StreamSource(transformationStyle); Transformer transformer = transformerFactory.newTransformer(stylesource); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(writer); transformer.transform(source, result); return writer.toString(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); log.warning("Exception: " + pce.getMessage()); log.throwing(this.getClass().getName(), "getResults", pce); } catch (TransformerConfigurationException e) { e.printStackTrace(); log.warning("Exception: " + e.getMessage()); log.throwing(this.getClass().getName(), "getResults", e); } catch (TransformerException e) { e.printStackTrace(); log.warning("Exception: " + e.getMessage()); log.throwing(this.getClass().getName(), "getResults", e); } return null; }
From source file:eu.impact_project.wsclient.HtmlServiceProvider.java
private Document convertToDoc(InputStream htmlFile) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true);// www .java 2 s.c om DocumentBuilder builder; Document doc = null; try { builder = factory.newDocumentBuilder(); doc = builder.parse(htmlFile); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return doc; }
From source file:de.ingrid.iplug.dscmapclient.index.producer.PlugDescriptionConfiguredWmsRecordSetProducer.java
/** * this private method does all the dirty work, read the file, parse it into * a document and find the desired ids, through the xpath expression * //from w ww . j ava 2s . com * @param filePath * @param expression * @return NodeList */ private NodeList readXmlFile(String filePath, String expression) { XPath xPath = XPathFactory.newInstance().newXPath(); File fXmlFile = new File(filePath); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder; try { dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(fXmlFile); return (NodeList) xPath.evaluate(expression, doc, XPathConstants.NODESET); } catch (ParserConfigurationException e) { log.error("Error creating record ids.", e); e.printStackTrace(); } catch (SAXException e) { log.error("Error creating record ids.", e); e.printStackTrace(); } catch (IOException e) { log.error("Error creating record ids.", e); e.printStackTrace(); } catch (XPathExpressionException e) { log.error("Error creating record ids.", e); e.printStackTrace(); } return null; }
From source file:matteroverdrive.gui.pages.PageGuideDescription.java
public PageGuideDescription(MOGuiBase gui, int posX, int posY, int width, int height, String name) { super(gui, posX, posY, width, height); this.setName(name); pages = new ArrayList<>(); bt_scroll_right = new MOElementButton(gui, this, sizeX - 20, sizeY - 16, SCROLL_RIGHT_ELEMENT_NAME, 0, 0, 10, 0, 10, 10, ""); bt_scroll_right.setTexture(Reference.PATH_ELEMENTS + "scroll_right.png", 20, 10); bt_scroll_left = new MOElementButton(gui, this, 10, sizeY - 16, SCROLL_LEFT_ELEMENT_NAME, 0, 0, 10, 0, 10, 10, ""); bt_scroll_left.setTexture(Reference.PATH_ELEMENTS + "scroll_left.png", 20, 10); bt_return = new MOElementButton(gui, this, sizeX / 2 - 5, sizeY - 16, RETURN_ELEMENT_NAME, 0, 0, 11, 0, 11, 11, ""); bt_return.setTexture(Reference.PATH_ELEMENTS + "return_arrow.png", 22, 11); builderFactory = DocumentBuilderFactory.newInstance(); builderFactory.setIgnoringElementContentWhitespace(true); try {/*w w w.ja va 2 s .c o m*/ builder = builderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { e.printStackTrace(); } }
From source file:de.xplib.xdbm.util.I18N.java
/** * @param localeIn .../* www . j a va2s. com*/ */ public void setLocale(final Locale localeIn) { InputStream is = this.getClass().getClassLoader() .getResourceAsStream("de/xplib/xdbm/ui/res/i18n/" + localeIn.getLanguage() + ".xml"); try { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = db.parse(is); this.entries.clear(); NodeList nl = doc.getDocumentElement().getElementsByTagName("entry"); for (int i = 0, l = nl.getLength(); i < l; i++) { NamedNodeMap nnm = nl.item(i).getAttributes(); if (nnm == null) { continue; } Node n = nnm.getNamedItem("key"); if (n == null) { continue; } this.entries.put(n.getNodeValue(), nnm); } this.notifyObservers(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:eu.serco.dhus.plugin.synergy1eo.Synergy1EoPlugin.java
public Synergy1EoPlugin() { executor = Executors.newFixedThreadPool(MAX_THREADS_NUMBER); map = new HashMap<String, String>(); map.put("SY_1_MISR__", "SY_1_2"); map.put("SY_2_SYN___", "SY_1_2"); map.put("SY_2_VGP___", "SY_1_2"); map.put("SY_2_VGK___", "SY_1_2"); map.put("SY_2_VG1___", "SY_2_VG"); map.put("SY_2_V10___", "SY_2_VG"); try {//from w w w .java 2s.com loadTaskTables(); loadSelectionRulesProperties(); externalDHuSUrl = ConfigurationManager.getExternalDHuSHost(); hashedString = ConfigurationManager.getHashedConnectionString(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (SAXException saxe) { saxe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.serco.dhus.plugin.olcil1eo.OlciL1EoPlugin.java
public OlciL1EoPlugin() { executor = Executors.newFixedThreadPool(MAX_THREADS_NUMBER); map = new HashMap<String, String>(); map.put("OL_1_EFR___", "OL_1_EO"); map.put("OL_1_ERR___", "OL_1_EO"); map.put("OL_1_RAC___", "OL_1_RAC"); map.put("OL_1_SPC___", "OL_1_SPC"); map.put("OL_2_WFR___", "OL_2"); map.put("OL_2_WRR___", "OL_2"); map.put("OL_2_LFR___", "OL_2"); map.put("OL_2_LRR___", "OL_2"); try {//from w w w . jav a 2 s . co m loadTaskTables(); loadSelectionRulesProperties(); externalDHuSUrl = ConfigurationManager.getExternalDHuSHost(); hashedString = ConfigurationManager.getHashedConnectionString(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (SAXException saxe) { saxe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }