List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace
public void printStackTrace()
From source file:com.pontecultural.flashcards.ReadSpreadsheet.java
public void run() { try {//w ww . ja v a 2s . co m // This class is used to upload a zip file via // the web (ie,fileData). To test it, the file is // give to it directly via odsFile. One of // which must be defined. assertFalse(odsFile == null && fileData == null); XMLReader reader = null; final String ZIP_CONTENT = "content.xml"; // Open office files are zipped. // Walk through it and find "content.xml" ZipInputStream zin = null; try { if (fileData != null) { zin = new ZipInputStream(new BufferedInputStream(fileData.getInputStream())); } else { zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(odsFile))); } ZipEntry entry; while ((entry = zin.getNextEntry()) != null) { if (entry.getName().equals(ZIP_CONTENT)) { break; } } SAXParserFactory spf = SAXParserFactory.newInstance(); //spf.setValidating(validate); SAXParser parser = spf.newSAXParser(); reader = parser.getXMLReader(); // reader.setErrorHandler(new MyErrorHandler()); reader.setContentHandler(this); // reader.parse(new InputSource(zf.getInputStream(entry))); reader.parse(new InputSource(zin)); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (SAXParseException spe) { spe.printStackTrace(); } catch (SAXException se) { se.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { if (zin != null) zin.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } }
From source file:org.opencastproject.loadtest.impl.IngestJob.java
/** * Parse the episode.xml file and change the mediapackage id. * /* w w w.j a v a 2 s. co m*/ * @param filepath * The location of the episode.xml. */ private void changeEpisodeID(String filepath) { try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(filepath); // Get the identifier element by tag name directly Node identifier = doc.getElementsByTagName("dcterms:identifier").item(0); identifier.setTextContent(id); // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new File(filepath)); transformer.transform(source, result); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (TransformerException tfe) { tfe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (SAXException sae) { sae.printStackTrace(); } }
From source file:org.opencastproject.loadtest.impl.IngestJob.java
/** * Parse and change the manifest.xml's id to match the mediapackage id we will be ingesting. * /*from ww w . j a v a 2 s.c o m*/ * @param filepath * The path to the manifest.xml file. */ private void changeManifestID(String filepath) { try { logger.info("Filepath for changing the manifest id is " + filepath); DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(filepath); // Get the mediapackage XPath xPath = XPathFactory.newInstance().newXPath(); Node mediapackage = ((NodeList) xPath.evaluate("//*[local-name() = 'mediapackage']", doc, XPathConstants.NODESET)).item(0); // update mediapackage attribute NamedNodeMap attr = mediapackage.getAttributes(); Node nodeAttr = attr.getNamedItem("id"); nodeAttr.setTextContent(id); // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new File(filepath)); transformer.transform(source, result); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (TransformerException tfe) { tfe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (SAXException sae) { sae.printStackTrace(); } catch (XPathExpressionException xpe) { xpe.printStackTrace(); } }
From source file:dreamboxdataservice.DreamboxDataService.java
private void getEPGData(TvDataUpdateManager updateManager, Channel ch) { try {//from ww w . j a va2s . c o m URL url = new URL("http://" + mProperties.getProperty("ip", "") + "/web/epgservice?sRef=" + StringUtils.replace(StringUtils.replace(ch.getId().substring(5), "_", ":"), " ", "%20")); URLConnection connection = url.openConnection(); String userpassword = mProperties.getProperty("username", "") + ":" + IOUtilities .xorEncode(mProperties.getProperty("password", ""), DreamboxSettingsPanel.PASSWORDSEED); String encoded = new String(Base64.encodeBase64(userpassword.getBytes())); connection.setRequestProperty("Authorization", "Basic " + encoded); connection.setConnectTimeout(60); InputStream stream = connection.getInputStream(); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); DreamboxChannelHandler handler = new DreamboxChannelHandler(updateManager, ch); saxParser.parse(stream, handler); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.collabnet.ccf.core.recovery.HospitalArtifactReplayer.java
public HospitalArtifactReplayer(HospitalEntry entry) { this.entry = entry; DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); try {//from w ww .java 2s . co m builder = docBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } replayWorkDir = new File(REPLAY_WORK_DIR); if (!replayWorkDir.exists()) { boolean isDirectoryCreated = replayWorkDir.mkdirs(); if (!isDirectoryCreated) { String message = "Could not create working directory for the replay script"; log.error(message); throw new CCFRuntimeException(message); } } }
From source file:dreamboxdataservice.DreamboxDataService.java
/** * @param service Service-ID/* www . j a v a2 s . c o m*/ * @return Data of specific service */ public TreeMap<String, String> getServiceData(String service) { try { URL url = new URL("http://" + mProperties.getProperty("ip", "") + "/web/getservices?sRef=" + service); URLConnection connection = url.openConnection(); String userpassword = mProperties.getProperty("username", "") + ":" + IOUtilities .xorEncode(mProperties.getProperty("password", ""), DreamboxSettingsPanel.PASSWORDSEED); String encoded = new String(Base64.encodeBase64(userpassword.getBytes())); connection.setRequestProperty("Authorization", "Basic " + encoded); connection.setConnectTimeout(10); InputStream stream = connection.getInputStream(); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); DreamboxHandler handler = new DreamboxHandler(); saxParser.parse(stream, handler); return handler.getData(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:dreamboxdataservice.DreamboxDataService.java
/** * @param service Service-ID/* w w w. j a va 2 s. c o m*/ * @return Data of specific service */ public TreeMap<String, String> getServiceDataBonquets(String service) { try { URL url = new URL("http://" + mProperties.getProperty("ip", "") + "/web/getservices?bRef=" + service); URLConnection connection = url.openConnection(); String userpassword = mProperties.getProperty("username", "") + ":" + IOUtilities .xorEncode(mProperties.getProperty("password", ""), DreamboxSettingsPanel.PASSWORDSEED); String encoded = new String(Base64.encodeBase64(userpassword.getBytes())); connection.setRequestProperty("Authorization", "Basic " + encoded); connection.setConnectTimeout(10); InputStream stream = connection.getInputStream(); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); DreamboxHandler handler = new DreamboxHandler(); saxParser.parse(stream, handler); return handler.getData(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:eu.serco.dhus.plugin.slstr.SlstrPlugin.java
public SlstrPlugin() { executor = Executors.newFixedThreadPool(MAX_THREADS_NUMBER); map = new HashMap<String, String>(); map.put("SL_1_RBT___", "SL_1"); map.put("SL_2_WCT___", "SL_2"); map.put("SL_2_WST___", "SL_2"); map.put("SL_2_LST___", "SL_2"); try {//from w w w . j ava 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(); } }
From source file:eu.serco.dhus.plugin.sral.SralPlugin.java
public SralPlugin() { executor = Executors.newFixedThreadPool(MAX_THREADS_NUMBER); map = new HashMap<String, String>(); map.put("SR_1_CAL___", "SR_1_CAL"); map.put("SR_1_SRA___", "SR_1_MEAS"); map.put("SR_2_WAT___", "SR_2"); map.put("SR_2_LAN___", "SR_2"); try {/*from w w w . j av a2 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(); } }
From source file:gr.forth.ics.isl.webservice.XPathsWebservice.java
/** * Uploads the file and returns status OK and the XML Paths in JSON * * @param input/*from w ww . j av a 2 s . c o m*/ * @return * @throws IOException */ @POST @Path("/fileService") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.MULTIPART_FORM_DATA) public Response fileParse(MultipartFormDataInput input) throws IOException { String filePath = uploadFile(input); XPaths xPaths; try { xPaths = handleParsing(filePath); } catch (ParserConfigurationException e) { e.printStackTrace(); return Response.status(400).entity(handleException(e)).build(); //status ERROR } catch (SAXException e) { e.printStackTrace(); return Response.status(400).entity(handleException(e)).build(); //status ERROR } return Response.status(200).entity(xPaths).build(); //status OK }