Example usage for javax.xml.bind JAXBException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:edu.purdue.cybercenter.dm.service.VocabularyService.java

public VocabularyService() {
    try {/*from www . j  ava  2  s .  c o  m*/
        context = JAXBContext.newInstance(Vocabulary.class);
    } catch (JAXBException ex) {
        throw new RuntimeException("failed to instantiate unmarshaller for Vocabulary: " + ex.getMessage());
    }
}

From source file:com.xerox.amazonws.sqs2.MessageQueue.java

/**
 * Sets a queue attribute. This is provided to expose the underlying functionality, although
 * the only attribute at this time is visibility timeout.
 *
 * @param attribute name of the attribute being set
 * @param value the value being set for this attribute
 *///from w  ww. j  a v a  2 s .  com
public void setQueueAttribute(String attribute, String value) throws SQSException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("Attribute.Name", attribute);
    params.put("Attribute.Value", value);
    GetMethod method = new GetMethod();
    try {
        //SetQueueAttributesResponse response =
        makeRequest(method, "SetQueueAttributes", params, SetQueueAttributesResponse.class);
    } catch (JAXBException ex) {
        throw new SQSException("Problem setting the visibility timeout.", ex);
    } catch (HttpException ex) {
        throw new SQSException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new SQSException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:gov.nih.nci.integration.caaers.CaAERSParticipantServiceWSClient.java

/**
 * Constructor used for Mocking purpose/*from  w w w  .j  av  a  2s .c om*/
 * 
 * @param client - ParticipantServiceInterface
 * @throws IntegrationException - IntegrationException
 */
public CaAERSParticipantServiceWSClient(ParticipantServiceInterface client) throws IntegrationException {
    try {
        getUnmarshaller();
        this.client = client;
    } catch (JAXBException e) {
        LOG.error("CaAERSParticipantServiceWSClient()..JAXBException while initialising unmarshaller", e);
        throw new IntegrationException(IntegrationError._1054, e.getMessage());// NOPMD
    }
}

From source file:com.xerox.amazonws.sqs2.MessageQueue.java

/**
 * Gets queue attributes. This is provided to expose the underlying functionality.
 * Currently supported attributes are ApproximateNumberOfMessages and VisibilityTimeout.
 *
 * @return a map of attributes and their values
 *//*from www .  j a v a2s  .co m*/
public Map<String, String> getQueueAttributes(QueueAttribute qAttr) throws SQSException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("AttributeName", qAttr.queryAttribute());
    GetMethod method = new GetMethod();
    try {
        GetQueueAttributesResponse response = makeRequest(method, "GetQueueAttributes", params,
                GetQueueAttributesResponse.class);
        Map<String, String> ret = new HashMap<String, String>();
        List<Attribute> attrs = response.getGetQueueAttributesResult().getAttributes();
        for (Attribute attr : attrs) {
            ret.put(attr.getName(), attr.getValue());
        }
        return ret;
    } catch (JAXBException ex) {
        throw new SQSException("Problem getting the visilibity timeout.", ex);
    } catch (HttpException ex) {
        throw new SQSException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new SQSException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

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();/* ww  w  .ja  va  2 s. 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:com.xerox.amazonws.sqs2.MessageQueue.java

/**
 * Internal implementation of receiveMessages.
 *
 * @param numMessages the maximum number of messages to return
 * @param visibilityTimeout the duration (in seconds) the retrieved message is hidden from
 *                          subsequent calls to retrieve.
 * @return an array of message objects/*from w ww. jav  a  2s  . c om*/
 */
protected Message[] receiveMessages(BigInteger numMessages, BigInteger visibilityTimeout) throws SQSException {
    Map<String, String> params = new HashMap<String, String>();
    if (numMessages != null) {
        params.put("MaxNumberOfMessages", numMessages.toString());
    }
    if (visibilityTimeout != null) {
        params.put("VisibilityTimeout", visibilityTimeout.toString());
    }
    GetMethod method = new GetMethod();
    try {
        ReceiveMessageResponse response = makeRequest(method, "ReceiveMessage", params,
                ReceiveMessageResponse.class);
        if (response.getReceiveMessageResult().getMessages() == null) {
            return new Message[0];
        } else {
            ArrayList<Message> msgs = new ArrayList();
            for (com.xerox.amazonws.typica.sqs2.jaxb.Message msg : response.getReceiveMessageResult()
                    .getMessages()) {
                String decodedMsg = enableEncoding ? new String(Base64.decodeBase64(msg.getBody().getBytes()))
                        : msg.getBody();
                msgs.add(new Message(msg.getMessageId(), msg.getReceiptHandle(), decodedMsg,
                        msg.getMD5OfBody()));
            }
            return msgs.toArray(new Message[msgs.size()]);
        }
    } catch (JAXBException ex) {
        throw new SQSException("Problem parsing returned message.", ex);
    } catch (HttpException ex) {
        throw new SQSException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new SQSException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:be.fedict.eid.applet.service.signer.facets.XAdESSignatureFacet.java

private Node marshallQualifyingProperties(Document document, ObjectFactory xadesObjectFactory,
        QualifyingPropertiesType qualifyingProperties) {
    Node marshallNode = document.createElement("marshall-node");
    try {/*w w  w  . j  a v  a 2s .c  om*/
        this.marshaller.marshal(xadesObjectFactory.createQualifyingProperties(qualifyingProperties),
                marshallNode);
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }
    Element qualifyingPropertiesElement = (Element) marshallNode.getFirstChild();
    Element signedPropertiesElement = (Element) qualifyingPropertiesElement
            .getElementsByTagNameNS("http://uri.etsi.org/01903/v1.3.2#", "SignedProperties").item(0);
    signedPropertiesElement.setIdAttribute("Id", true);
    return qualifyingPropertiesElement;
}

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  w  w w. j av a2 s  .  c om

    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:com.intuit.tank.tools.script.ScriptFilterRunner.java

private String toXml(ScriptTO turboScriptTO) {
    String ret = null;/*from  w ww  .ja v  a 2  s . c o m*/
    try {
        JAXBContext ctx = JAXBContext.newInstance(ScriptTO.class.getPackage().getName());
        Marshaller marshaller = ctx.createMarshaller();
        marshaller.setProperty("jaxb.formatted.output", true);
        StringWriter sw = new StringWriter();
        marshaller.marshal(turboScriptTO, sw);
        ret = sw.toString();
    } catch (JAXBException e) {
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error reading file", JOptionPane.ERROR_MESSAGE);
    }
    return ret;
}

From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java

private void loadTSXml(File selectedFile) {
    try {//  w ww  . j  a v  a  2 s .co m
        JAXBContext ctx = JAXBContext.newInstance(ScriptTO.class.getPackage().getName());
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        tankScript = (ScriptTO) unmarshaller.unmarshal(selectedFile);
        currentFileLabel.setText(selectedFile.getName());
        xmlFile = selectedFile;
        showXmlBT.setEnabled(true);
        runBT.setEnabled(true);
        saveBT.setEnabled(true);
    } catch (JAXBException e) {
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error reading file", JOptionPane.ERROR_MESSAGE);
    }

}