List of usage examples for javax.xml.bind JAXBException printStackTrace
public void printStackTrace()
From source file:edu.harvard.i2b2.PdoEGtoFhirBundle.java
@Test public void Test23() throws XQueryUtilException { String medsBundle = null;// getMeds(); // logger.trace("getMEds:"+medsBundle); try {/*w w w . j ava2s . c o m*/ Bundle b = JAXBUtil.fromXml(medsBundle, Bundle.class); MedicationStatement ms = b.getEntry().get(1).getResource().getMedicationStatement(); logger.trace(JAXBUtil.toXml(ms)); logger.trace(ms.getPatient().getReference().getValue().toString()); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:net.itransformers.idiscover.v2.core.listeners.Neo4JGraphmlLoggerLogDiscoveryListener.java
@Override public void nodeDiscovered(NodeDiscoveryResult discoveryResult) { File baseDir = new File(projectPath, labelDirName); File xsltFile = new File(xsltFileName); File graphmlDir = new File(baseDir, graphmDirName); GraphDatabaseService graphdb = new org.neo4j.rest.graphdb.RestGraphDatabase(graphDbUrl); if (!graphmlDir.exists()) graphmlDir.mkdir();/*from www . j a v a 2 s . c o m*/ String deviceName = discoveryResult.getNodeId(); DiscoveredDeviceData discoveredDeviceData = (DiscoveredDeviceData) discoveryResult .getDiscoveredData(dataType); ByteArrayOutputStream graphMLOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { JaxbMarshalar.marshal(discoveredDeviceData, out, "DiscoveredDevice"); } catch (JAXBException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } XsltTransformer transformer = new XsltTransformer(); try { transformer.transformXML(new ByteArrayInputStream(out.toByteArray()), xsltFile, graphMLOutputStream, null, null); } catch (Exception e) { logger.error(e.getMessage(), e); } final String fileName = "node-" + deviceName + ".graphml"; final File nodeFile = new File(graphmlDir, fileName); String unformatedGraphml = new String(graphMLOutputStream.toByteArray()); try { String graphml = new XmlFormatter().format(unformatedGraphml); FileUtils.writeStringToFile(nodeFile, graphml); FileWriter writer = new FileWriter(new File(labelDirName, "undirected" + ".graphmls"), true); writer.append(String.valueOf(fileName)).append("\n"); writer.close(); } catch (IOException e) { logger.debug("Unformated xml is not in correct format: \n" + unformatedGraphml); e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } Neo4jGraphmlMerger neo4jMerger = new Neo4jGraphmlMerger(graphdb, "v1"); Transaction tx = graphdb.beginTx(); try { tx = graphdb.beginTx(); neo4jMerger.merge(nodeFile); tx.success(); } catch (Exception e) { if (tx != null) tx.failure(); } finally { if (tx != null) tx.finish(); } }
From source file:net.itransformers.idiscover.v2.core.listeners.node.GraphmlFileLogGroovyDiscoveryListener.java
@Override public void nodeDiscovered(NodeDiscoveryResult discoveryResult) { File baseDir = new File(projectPath, labelDirName); File graphmlDir = new File(baseDir, graphmlDirName); if (!graphmlDir.exists()) graphmlDir.mkdir();//from w w w . j a va 2s .c o m String deviceName = discoveryResult.getNodeId(); if (deviceName == null) return; //This is a case of a subnetKind of a node or other nodes without nodeId. DiscoveredDeviceData discoveredDeviceData = (DiscoveredDeviceData) discoveryResult .getDiscoveredData("deviceData"); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { JaxbMarshalar.marshal(discoveredDeviceData, out, "DiscoveredDevice"); } catch (JAXBException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } StringReader reader = new StringReader(out.toString()); StringWriter graphmlWriter = new StringWriter(); transformRawDataToGraphml(reader, graphmlWriter); try { final String fileName = "node-" + deviceName + ".graphml"; // String fullFileName = path + File.separator + fileName; final File nodeFile = new File(graphmlDir, fileName); //System.out.println(new String(graphmlWriter.toString())); String graphml; graphml = new XmlFormatter().format(graphmlWriter.toString()); FileUtils.writeStringToFile(nodeFile, graphml); File undirectedGraphmls = new File(graphmlDir.getParent(), "undirected" + ".graphmls"); if (!undirectedGraphmls.exists()) { undirectedGraphmls.createNewFile(); } FileWriter writer = new FileWriter(undirectedGraphmls, true); writer.append(String.valueOf(fileName)).append("\n"); writer.close(); } catch (IOException e) { logger.debug("Unformated xml is not in correct format: \n" + graphmlWriter.toString()); e.printStackTrace(); } catch (ParserConfigurationException e) { logger.debug("Unformated xml is not in correct format: \n" + graphmlWriter.toString()); e.printStackTrace(); } catch (SAXException e) { logger.debug("Unformated xml is not in correct format: \n" + graphmlWriter.toString()); e.printStackTrace(); } }
From source file:net.itransformers.idiscover.v2.core.listeners.node.Neo4JGraphmlLoggerLogDiscoveryListener.java
@Override public void nodeDiscovered(NodeDiscoveryResult discoveryResult) { File baseDir = new File(projectPath, labelDirName); File xsltFile = new File(xsltFileName); File graphmlDir = new File(baseDir, graphmlDirName); GraphDatabaseService graphdb = new org.neo4j.rest.graphdb.RestGraphDatabase(graphDbUrl); if (!graphmlDir.exists()) graphmlDir.mkdir();//from www. j a va2s . c o m String deviceName = discoveryResult.getNodeId(); DiscoveredDeviceData discoveredDeviceData = (DiscoveredDeviceData) discoveryResult .getDiscoveredData(dataType); ByteArrayOutputStream graphMLOutputStream = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { JaxbMarshalar.marshal(discoveredDeviceData, out, "DiscoveredDevice"); } catch (JAXBException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } XsltTransformer transformer = new XsltTransformer(); try { transformer.transformXML(new ByteArrayInputStream(out.toByteArray()), xsltFile, graphMLOutputStream); } catch (Exception e) { logger.error(e.getMessage(), e); } final String fileName = "node-" + deviceName + ".graphml"; final File nodeFile = new File(graphmlDir, fileName); String unformatedGraphml = new String(graphMLOutputStream.toByteArray()); try { String graphml = new XmlFormatter().format(unformatedGraphml); FileUtils.writeStringToFile(nodeFile, graphml); FileWriter writer = new FileWriter(new File(labelDirName, "undirected" + ".graphmls"), true); writer.append(String.valueOf(fileName)).append("\n"); writer.close(); } catch (IOException e) { logger.debug("Unformated xml is not in correct format: \n" + unformatedGraphml); e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } Neo4jGraphmlMerger neo4jMerger = new Neo4jGraphmlMerger(graphdb, "v1"); Transaction tx = graphdb.beginTx(); try { tx = graphdb.beginTx(); neo4jMerger.merge(nodeFile); tx.success(); } catch (Exception e) { if (tx != null) tx.failure(); } finally { if (tx != null) tx.finish(); } }
From source file:eu.modaclouds.sla.service.rest.AbstractSLARest.java
protected String printError(int code, String text) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try {//ww w .j a v a 2 s. c om ErrorResponse errorResponse = new ErrorResponse(); errorResponse.setCode(code); errorResponse.setMessage(text); JAXBContext jaxbContext; jaxbContext = JAXBContext.newInstance(eu.atos.sla.parser.data.ErrorResponse.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(errorResponse, out); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } return out.toString(); }
From source file:eu.modaclouds.sla.service.rest.AbstractSLARest.java
protected String printMessage(int code, String text) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try {// w w w . j a v a2 s .c om MessageResponse messageResponse = new MessageResponse(); messageResponse.setCode(code); messageResponse.setMessage(text); JAXBContext jaxbContext = JAXBContext.newInstance(eu.atos.sla.parser.data.MessageResponse.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(messageResponse, out); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } return out.toString(); }
From source file:de.uni_potsdam.hpi.bpt.promnicat.importer.ibm.IBMModelImporter.java
private Model parseModel(File file, String id) { Model model = new Model(file.getName(), Constants.ORIGIN_IBM, id); Revision revision = new Revision(0); revision.connectRepresentation(new Representation(Constants.FORMAT_XML, Constants.NOTATION_BPMN2_0, file)); try {/*from w w w . ja v a2 s .com*/ revision.connectRepresentation(new Representation(Constants.FORMAT_BPMAI_JSON, Constants.NOTATION_BPMN2_0, parseIBMBPMN2Diagram(file).getBytes())); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } model.connectLatestRevision(revision); return model; }
From source file:com.spend.spendService.DomainLearning.java
private SearchEngines getSearchEnginesFromXml() { try {/*from w w w . jav a 2 s.c o m*/ File file = new File("SearchEngines.xml"); JAXBContext jaxbContext = JAXBContext.newInstance(SearchEngines.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); SearchEngines searchEngineList = (SearchEngines) jaxbUnmarshaller.unmarshal(file); return searchEngineList; } catch (JAXBException ex) { System.out.println("DomainLearning.java getSearchEnginesFromXml function ERROR " + ex.getMessage()); ex.printStackTrace(); } return null; }
From source file:eu.learnpad.core.impl.cw.XwikiBridgeInterfaceRestResource.java
@Override public void notifyScoreUpdate(ScoreRecord record) throws LpRestException { String contentType = "application/xml"; HttpClient httpClient = this.getClient(); String uri = String.format("%s/learnpad/cw/bridge/scores", DefaultRestResource.REST_URI); PostMethod postMethod = new PostMethod(uri); postMethod.addRequestHeader(HttpHeaders.CONTENT_TYPE, contentType); try {//from w w w . j av a2 s .com JAXBContext jc = JAXBContext.newInstance(ScoreRecord.class); Writer marshalledRecord = new StringWriter(); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(record, marshalledRecord); postMethod.setRequestEntity(new StringRequestEntity(marshalledRecord.toString(), contentType, "UTF-8")); httpClient.executeMethod(postMethod); } catch (JAXBException e1) { e1.printStackTrace(); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.sarm.lonelyplanet.process.DestinationProcessorTest.java
/** * This method tests the JAXB provider. The validates if the JAXB provider * is eclipse provider MOXy. In essence it tests that the jaxb.properties * file is present and it has the correct JAXBContextFactory configured. *//*from w w w . j a v a 2s . co m*/ @Test public void testJAXBContext() { logger.info("Testing testJAXBContext "); JAXBContext jc = null; try { jc = JAXBContext.newInstance(Destinations.class); } catch (JAXBException ex) { logger.error(ex); ex.printStackTrace(); } String context = "class org.eclipse.persistence.jaxb.JAXBContext"; assertEquals(context, jc.getClass().toString()); }