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:com.xerox.amazonws.sqs.MessageQueue.java

/**
 * Sets the message visibility timeout. 
 *
 * @param msgId the id of the message/*from w  ww .j a va2s .c om*/
 * @param timeout the duration (in seconds) the retrieved message is hidden from
 *                          subsequent calls to retrieve.
 */
public void setVisibilityTimeout(String msgId, int timeout) throws SQSException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("MessageId", "" + msgId);
    params.put("VisibilityTimeout", "" + timeout);
    GetMethod method = new GetMethod();
    try {
        //ChangeMessageVisibilityResponse response =
        makeRequest(method, "ChangeMessageVisibility", params, ChangeMessageVisibilityResponse.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:com.xerox.amazonws.sqs.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   www . jav  a 2  s.  co m
public void setQueueAttribute(String attribute, String value) throws SQSException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("Attribute", attribute);
    params.put("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:com.xerox.amazonws.sqs.MessageQueue.java

/**
 * Returns a specified message. This does not affect and is not affected by the visibility
 * timeout of either the queue or the message.
 *
 * @param msgId the id of the message to be read
 * @return the message object/*from   ww  w.j  a  v a 2 s. c  om*/
 */
public Message peekMessage(String msgId) throws SQSException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("MessageId", msgId);
    GetMethod method = new GetMethod();
    try {
        PeekMessageResponse response = makeRequest(method, "PeekMessage", params, PeekMessageResponse.class);
        com.xerox.amazonws.typica.jaxb.Message msg = response.getMessage();
        if (msg == null) {
            return null;
        } else {
            String decodedMsg = enableEncoding
                    ? new String(Base64.decodeBase64(msg.getMessageBody().getBytes()))
                    : msg.getMessageBody();
            return new Message(msg.getMessageId(), decodedMsg);
        }
    } 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.ooxml.OOXMLSignatureVerifier.java

public OOXMLSignatureVerifier() {
    try {/*from w  w  w  . j  ava2  s  . co  m*/
        JAXBContext relationshipsJAXBContext = JAXBContext.newInstance(ObjectFactory.class);
        this.relationshipsUnmarshaller = relationshipsJAXBContext.createUnmarshaller();
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }
}

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

public Element getReturnStoredDocumentElement(ReturnStoredDocument returnStoredDocument) {

    Document newDocument = this.documentBuilder.newDocument();
    Element newElement = newDocument.createElement("newNode");
    try {//from w w  w  . j  av  a 2s  .co  m
        this.artifactMarshaller.marshal(
                this.artifactObjectFactory.createReturnStoredDocument(returnStoredDocument), newElement);
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }
    return (Element) newElement.getFirstChild();
}

From source file:com.xerox.amazonws.sqs.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   w w  w  . ja  v  a2s  . co m*/
public Map<String, String> getQueueAttributes(QueueAttribute qAttr) throws SQSException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("Attribute", qAttr.queryAttribute());
    GetMethod method = new GetMethod();
    try {
        GetQueueAttributesResponse response = makeRequest(method, "GetQueueAttributes", params,
                GetQueueAttributesResponse.class);
        Map<String, String> ret = new HashMap<String, String>();
        List<AttributedValue> attrs = response.getAttributedValues();
        for (AttributedValue attr : attrs) {
            ret.put(attr.getAttribute(), 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:com.xerox.amazonws.sqs.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. j a v 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("NumberOfMessages", 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.getMessages() == null) {
            return new Message[0];
        } else {
            ArrayList<Message> msgs = new ArrayList();
            for (com.xerox.amazonws.typica.jaxb.Message msg : response.getMessages()) {
                String decodedMsg = enableEncoding
                        ? new String(Base64.decodeBase64(msg.getMessageBody().getBytes()))
                        : msg.getMessageBody();
                msgs.add(new Message(msg.getMessageId(), decodedMsg));
            }
            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:com.xerox.amazonws.sqs.MessageQueue.java

/**
 * Retrieves a list of grants for this queue. The results can be filtered by specifying
 * a grantee or a particular permission.
 *
 * @param grantee the optional user or group
 * @param permission the optional permission
 * @return a list of objects representing the grants
 *//* w w w  .j av a 2s  .c  o  m*/
public Grant[] listGrants(Grantee grantee, String permission) throws Exception {
    Map<String, String> params = new HashMap<String, String>();
    if (permission != null && !permission.trim().equals("")) {
        params.put("Permission", permission);
    }
    if (grantee instanceof CanonicalUser) {
        params.put("Grantee.ID", ((CanonicalUser) grantee).getID());
    }
    GetMethod method = new GetMethod();
    try {
        ListGrantsResponse response = makeRequest(method, "ListGrants", params, ListGrantsResponse.class);
        Grant[] grants = new Grant[response.getGrantLists().size()];
        int i = 0;
        for (com.xerox.amazonws.typica.jaxb.Grant g : response.getGrantLists()) {
            Grantee g2 = null;
            if (g.getGrantee() instanceof com.xerox.amazonws.typica.jaxb.Group) {
                com.xerox.amazonws.typica.jaxb.Group grp = (com.xerox.amazonws.typica.jaxb.Group) g
                        .getGrantee();
                g2 = new Group(new URI(grp.getURI()));
            } else if (g.getGrantee() instanceof com.xerox.amazonws.typica.jaxb.CanonicalUser) {
                com.xerox.amazonws.typica.jaxb.CanonicalUser u = (com.xerox.amazonws.typica.jaxb.CanonicalUser) g
                        .getGrantee();
                g2 = new CanonicalUser(u.getID(), u.getDisplayName());
            }
            grants[i] = new Grant(g2, g.getPermission());
            i++;
        }
        return grants;
    } 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.dss.client.DigitalSignatureServiceClient.java

/**
 * Main constructor./*from   w  ww .j a  v  a2 s  . com*/
 * 
 * @param endpointAddress
 *            the DSS web service endpoint address. For example
 *            http://localhost:8080/eid-dss-ws/dss
 */
public DigitalSignatureServiceClient(String endpointAddress) {
    this.endpointAddress = endpointAddress;
    this.dssObjectFactory = new ObjectFactory();
    this.vrObjectFactory = new be.fedict.eid.dss.ws.profile.vr.jaxb.ObjectFactory();
    try {
        JAXBContext vrJAXBContext = JAXBContext
                .newInstance(be.fedict.eid.dss.ws.profile.vr.jaxb.ObjectFactory.class);
        this.vrMarshaller = vrJAXBContext.createMarshaller();
        this.vrUnmarshaller = vrJAXBContext.createUnmarshaller();

        JAXBContext artifactJAXBContext = JAXBContext
                .newInstance(be.fedict.eid.dss.ws.profile.artifact.jaxb.ObjectFactory.class);
        this.artifactMarshaller = artifactJAXBContext.createMarshaller();
        this.artifactUnmarshaller = artifactJAXBContext.createUnmarshaller();

        JAXBContext originalDocumentJAXBContext = JAXBContext
                .newInstance(be.fedict.eid.dss.ws.profile.originaldocument.jaxb.ObjectFactory.class);
        this.originalDocumentMarshaller = originalDocumentJAXBContext.createMarshaller();
    } catch (JAXBException e) {
        throw new RuntimeException("JAXB error: " + e.getMessage(), e);
    }

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    try {
        this.documentBuilder = documentBuilderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        throw new RuntimeException("document builder error: " + e.getMessage(), e);
    }

    try {
        this.certificateFactory = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new RuntimeException("X509 factory error: " + e.getMessage(), e);
    }

    this.port = getPort();
}

From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java

public <T> T unmarshalObject(Object domOrJaxbElement, Class<T> type) throws SchemaException {
    JAXBElement<T> element;
    if (domOrJaxbElement instanceof JAXBElement<?>) {
        element = (JAXBElement<T>) domOrJaxbElement;
    } else if (domOrJaxbElement instanceof Node) {
        try {// w ww  .  j  a  v a 2  s  .  c om
            element = unmarshalElement((Node) domOrJaxbElement, type);
        } catch (JAXBException e) {
            throw new SchemaException(e.getMessage(), e);
        }
    } else {
        throw new IllegalArgumentException("Unknown element type " + domOrJaxbElement);
    }
    if (element == null) {
        return null;
    }
    T value = element.getValue();
    adopt(value, type);
    return value;
}