Example usage for javax.xml.bind JAXBException printStackTrace

List of usage examples for javax.xml.bind JAXBException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:edu.harvard.i2b2.fhir.FhirUtil.java

public static Resource getResourceFromContainer(ResourceContainer rc) {
    Resource r = null;//from   w w  w  . jav a2s .c o m
    if (rc.getPatient() != null)
        return rc.getPatient();
    if (rc.getMedication() != null)
        return rc.getMedication();
    if (rc.getMedicationStatement() != null)
        return rc.getMedicationStatement();
    if (rc.getMedicationDispense() != null)
        return rc.getMedicationDispense();
    if (rc.getMedicationOrder() != null)
        return rc.getMedicationOrder();
    if (rc.getCondition() != null)
        return rc.getCondition();
    if (rc.getObservation() != null)
        return rc.getObservation();
    if (rc.getBundle() != null)
        return rc.getBundle();
    if (rc.getSearchParameter() != null)
        return rc.getSearchParameter();
    if (rc.getDiagnosticReport() != null)
        return rc.getDiagnosticReport();
    if (rc.getDiagnosticOrder() != null)
        return rc.getDiagnosticOrder();
    if (rc.getOrder() != null)
        return rc.getOrder();
    String xml = null;
    try {
        xml = JAXBUtil.toXml(rc);
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    throw new RuntimeException("Not implemented all resource types:" + xml);
}

From source file:cool.pandora.modeller.ui.handlers.iiif.CreateXmlFilesHandler.java

@Override
public void execute() {
    final String message = ApplicationContextUtil.getMessage("bag.message.xmlfilecreated");
    final DefaultBag bag = bagView.getBag();
    final Map<String, BagInfoField> map = bag.getInfo().getFieldMap();
    final ResourceIdentifierList idList = new ResourceIdentifierList(bagView);
    final ArrayList<String> resourceIDList = idList.getResourceIdentifierList();
    final String collectionId = URIResolver.ContainerURIResolverNormal.getMapValue(map,
            ProfileOptions.COLLECTION_ID_KEY);
    final String objektId = URIResolver.ContainerURIResolverNormal.getMapValue(map,
            ProfileOptions.OBJEKT_ID_KEY);
    for (final String resourceId : resourceIDList) {
        ByteArrayOutputStream resourceFile = null;
        try {// w  w  w .  j a  v  a 2s . com
            resourceFile = getXmlOutputStream(collectionId, objektId, resourceId);
        } catch (final JAXBException e) {
            e.printStackTrace();
        }
        assert resourceFile != null;
        final ByteArrayInputStream in = new ByteArrayInputStream(resourceFile.toByteArray());
        final String filename = resourceId + ".xml";
        final String contentType = "application/xml";
        final URI destinationURI = IIIFObjectURI.getDestinationURI(map, filename);
        try {
            ModellerClient.doStreamPut(destinationURI, in, contentType);
            ApplicationContextUtil.addConsoleMessage(message + " " + destinationURI);
        } catch (final ModellerClientFailedException e) {
            ApplicationContextUtil.addConsoleMessage(getMessage(e));
        }
    }
}

From source file:fr.fastconnect.factory.tibco.bw.codereview.ConvertRulesToSonarMojo.java

public void save(File f, Rules rules) {
    try {//w w  w.jav a 2  s  .  co m
        JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
        Marshaller m = jaxbContext.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        m.marshal(rules, f);
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:com.provenance.cloudprovenance.sconverter.PolicyResponseConverter.java

public String marhsallObject(PolicyResponse pResponse) {

    JAXBContext jaxbContext;//  w ww  .  j ava  2s . c  om
    StringWriter sw = new StringWriter();

    try {
        jaxbContext = JAXBContext.newInstance(instanceDir);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", cProvPrefixMapper);

        JAXBElement<PolicyResponse> el = pFactory.createPolicyResponse(pResponse);

        marshaller.marshal(el, sw);

        logger.info("Sucessfully marshalled the policy objects: " + el.getName());

    } catch (JAXBException e) {
        e.printStackTrace();
    }

    return sw.toString();
}

From source file:eu.openminted.toolkit.elsevier.retriever.JaxbMarshalingTest.java

@Test
public void shoudDeserialise() {
    try {/*from   w w  w .  j  a v a  2 s .  c  om*/
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        File testXml = new File("src/test/resources/S0140673616313228");
        FullTextRetrievalResponse deserialisedObject = (FullTextRetrievalResponse) unmarshaller
                .unmarshal(testXml);

        Assert.assertNotNull(deserialisedObject);
        Assert.assertEquals(deserialisedObject.getCoredata().getDc_identifier(),
                testObject.getCoredata().getDc_identifier());
        Assert.assertEquals(deserialisedObject.getCoredata().getLink(), testObject.getCoredata().getLink());
        Assert.assertEquals(deserialisedObject.getCoredata().getOpenaccess(),
                testObject.getCoredata().getOpenaccess());
        Assert.assertEquals(deserialisedObject.getCoredata().isOpenaccessArticle(),
                testObject.getCoredata().isOpenaccessArticle());

        //            Assert.assertEquals(deserialisedObject, testObject);

        System.out.println("Deserialized object :\n" + deserialisedObject.toString());
        System.out.println("\nTestObject :\n" + testObject.toString());
    } catch (JAXBException jAXBException) {
        jAXBException.printStackTrace();
    }
}

From source file:net.itransformers.idiscover.v2.core.listeners.node.GraphmlFileLogDiscoveryListener.java

@Override
public void nodeDiscovered(NodeDiscoveryResult discoveryResult) {
    File baseDir = new File(projectPath, labelDirName);
    File xsltFile = new File(projectPath, xsltFileName);
    File graphmlDir = new File(baseDir, graphmlDirName);
    if (!graphmlDir.exists())
        graphmlDir.mkdir();//from  ww  w .  ja  v  a2s .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 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);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }

    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(graphMLOutputStream.toByteArray()));
        String graphml = new XmlFormatter().format(new String(graphMLOutputStream.toByteArray()));
        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) {
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    }

}

From source file:eu.impress.impressplatform.IntegrationLayer.ResourcesMgmt.BedAvailabilityServiceBean.java

@Override
public String getBedAvailablityHAVE(String hospitalname) {

    String hospitalstatushave;/*from w  w  w  .j a va  2 s. c om*/
    BedStats bedStats = bedService.getHospitalAvailableBeds(hospitalname);
    HospitalStatus hospitalStatus = beansTransformation.BedStatstoHAVE(bedStats);

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(HospitalStatus.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        //jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        StringWriter sw = new StringWriter();
        //marshal the envelope 
        jaxbMarshaller.marshal(hospitalStatus, sw);
        hospitalstatushave = sw.toString();

    } catch (JAXBException e) {
        e.printStackTrace();
        return "Error Marshalling XML Object" + HttpStatus.INTERNAL_SERVER_ERROR;
    }

    return hospitalstatushave;

}

From source file:com.spend.spendService.MainPage.java

private SearchEngines getSearchEnginesFromXml() {
    try {//from ww  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 e) {
        e.printStackTrace();
    }
    return null;
}

From source file:eu.impress.impressplatform.IntegrationLayer.ResourcesMgmt.BedAvailabilityServiceBean.java

@Override
public String createBedAvailabilityDE() throws DatatypeConfigurationException {

    String DEmessageenvelope = "";
    String DEmessage = "";

    EDXLDistribution ed = EDXLlib.createEDXLEnvelope();

    try {//from w  w  w. jav a2  s.  c  om
        JAXBContext jaxbContext = JAXBContext.newInstance(EDXLDistribution.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        //jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        StringWriter sw = new StringWriter();
        //marshal the envelope 
        jaxbMarshaller.marshal(ed, sw);
        DEmessageenvelope = sw.toString();

        //could not unescape characters no matter what!
        //encapsulate the edxl have message into DE by avoiding jaxb 
        //DEmessage = EDXLlib.DEEncapsulation(DEmessageenvelope, edxlhave);
        DEmessage = DEmessageenvelope;

    } catch (JAXBException e) {
        e.printStackTrace();
        return "Error Marshalling XML Object" + HttpStatus.INTERNAL_SERVER_ERROR;
    }

    return DEmessage;

}

From source file:eu.impress.repository.service.BedAvailabilityServiceImpl.java

@Override
public String getBedTypeAllAvailablityHAVE() {
    String hospitalstatushave;// w w w .j ava  2  s. c  o m
    List<eu.impress.repository.model.BedStats> bedStatsList = bedService.getHospitalAllAvailableBedTypes();
    HospitalStatus hospitalStatus = beansTransformation.BedTypesStatstoHAVE(bedStatsList);

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(HospitalStatus.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        StringWriter sw = new StringWriter();
        jaxbMarshaller.marshal(hospitalStatus, sw);
        hospitalstatushave = sw.toString();

    } catch (JAXBException e) {
        e.printStackTrace();
        return "Error Marshalling XML Object";
    }

    return hospitalstatushave;

}