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.mgmtp.perfload.loadprofiles.ui.ctrl.ConfigController.java

public void saveActiveSettings() {
    checkState(activeSettingsFile != null, "No active settings file set.");

    Writer wr = null;//from  w  ww .j  a v a  2s.  c om
    File file = new File(settingsDir, activeSettingsFile);
    file.getParentFile().mkdir();

    try {
        wr = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
        JAXBContext context = JAXBContext.newInstance(Settings.class);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        m.marshal(getActiveSettings(), wr);
    } catch (JAXBException ex) {
        String msg = "Error marshalling contents to file: " + file;
        throw new LoadProfileException(msg, ex);
    } catch (IOException ex) {
        throw new LoadProfileException(ex.getMessage(), ex);
    } finally {
        Closeables.closeQuietly(wr);
    }
}

From source file:com.xerox.amazonws.devpay.DevPayLS.java

/**
 * Verifies that a specified product is subscribed to by a customer.
 *
 * @param productToken the product token
 * @param userToken the user token//  w  w  w  . j a  v  a  2 s. c  o m
 * @return the list of product codes 
 * @throws DevPayException wraps checked exceptions
 */
public boolean isProductSubscribedByTokens(String productToken, String userToken) throws DevPayException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("ProductToken", productToken);
    params.put("UserToken", userToken);
    GetMethod method = new GetMethod();
    try {
        VerifyProductSubscriptionByTokensResponse response = makeRequest(method,
                "VerifyProductSubscriptionByTokens", params, VerifyProductSubscriptionByTokensResponse.class);

        VerifyProductSubscriptionByTokensResult result = response.getVerifyProductSubscriptionByTokensResult();
        return result.isSubscribed();
    } catch (JAXBException ex) {
        throw new DevPayException("Problem parsing returned message.", ex);
    } catch (HttpException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:com.mgmtp.perfload.loadprofiles.ui.ctrl.ConfigController.java

public void loadActiveSettings() {
    checkState(activeSettingsFile != null, "No active settings file set.");

    Reader r = null;//from  w ww . j a  v a 2 s  .  c om
    File file = new File(settingsDir, activeSettingsFile);
    try {
        r = new InputStreamReader(new FileInputStream(file), "UTF-8");
        JAXBContext context = JAXBContext.newInstance(Settings.class);
        Unmarshaller m = context.createUnmarshaller();
        activeSettings = (Settings) m.unmarshal(r);
    } catch (JAXBException ex) {
        String msg = "Error unmarshalling contents from file: " + file;
        throw new LoadProfileException(msg, ex);
    } catch (IOException ex) {
        throw new LoadProfileException(ex.getMessage(), ex);
    } finally {
        Closeables.closeQuietly(r);
    }
}

From source file:com.xerox.amazonws.devpay.DevPayLS.java

/**
 * Activates a hosted product.//ww w. j  a v  a 2 s  . co  m
 *
 * @param activationKey key obtained from the customer
 * @param productToken token for your product
 * @return the product info
 * @throws DevPayException wraps checked exceptions
 */
public HostedProductInfo activateHostedProduct(String activationKey, String productToken)
        throws DevPayException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("ActivationKey", activationKey);
    params.put("ProductToken", productToken);
    GetMethod method = new GetMethod();
    try {
        ActivateHostedProductResponse response = makeRequest(method, "ActivateHostedProduct", params,
                ActivateHostedProductResponse.class);

        ActivateHostedProductResult result = response.getActivateHostedProductResult();
        return new HostedProductInfo(result.getPersistentIdentifier(), result.getUserToken());
    } catch (JAXBException ex) {
        throw new DevPayException("Problem parsing returned message.", ex);
    } catch (HttpException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:com.xerox.amazonws.devpay.DevPayLS.java

/**
 * Verifies that a specified product is subscribed to by a customer.
 *
 * @param persistentIdentifier customers's PID
 * @param productCode the product code/* w w  w.  j a  va2 s.co m*/
 * @return true if product is subscribed
 * @throws DevPayException wraps checked exceptions
 */
public boolean isProductSubscribedByPid(String persistentIdentifier, String productCode)
        throws DevPayException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("PersistentIdentifier", persistentIdentifier);
    params.put("ProductCode", productCode);
    GetMethod method = new GetMethod();
    try {
        VerifyProductSubscriptionByPidResponse response = makeRequest(method, "VerifyProductSubscriptionByPid",
                params, VerifyProductSubscriptionByPidResponse.class);

        VerifyProductSubscriptionByPidResult result = response.getVerifyProductSubscriptionByPidResult();
        return result.isSubscribed();
    } catch (JAXBException ex) {
        throw new DevPayException("Problem parsing returned message.", ex);
    } catch (HttpException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:com.xerox.amazonws.devpay.DevPayLS.java

/**
 * Activates a desktop product.//from   www.ja va2  s. c o m
 *
 * @param activationKey key obtained from the customer
 * @param productToken token for your product
 * @return the product info
 * @throws DevPayException wraps checked exceptions
 */
public DesktopProductInfo activateDesktopProduct(String activationKey, String productToken)
        throws DevPayException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("ActivationKey", activationKey);
    params.put("ProductToken", productToken);
    GetMethod method = new GetMethod();
    try {
        ActivateDesktopProductResponse response = makeRequest(method, "ActivateDesktopProduct", params,
                ActivateDesktopProductResponse.class);

        ActivateDesktopProductResult result = response.getActivateDesktopProductResult();
        return new DesktopProductInfo(result.getAWSAccessKeyId(), result.getSecretAccessKey(),
                result.getUserToken());
    } catch (JAXBException ex) {
        throw new DevPayException("Problem parsing returned message.", ex);
    } catch (HttpException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:com.xerox.amazonws.devpay.DevPayLS.java

/**
 * Gets the most up-to-date version of the user token.
 *
 * @param userToken the user token//  w w  w  . ja v a  2 s .co  m
 * @param additionalTokens optional token (see dev guide), null if not used
 * @return the list of product codes 
 * @throws DevPayException wraps checked exceptions
 */
public String refreshUserToken(String userToken, String additionalTokens) throws DevPayException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("UserToken", userToken);
    if (additionalTokens != null) {
        params.put("AdditionalTokens", additionalTokens);
    }
    GetMethod method = new GetMethod();
    try {
        RefreshUserTokenResponse response = makeRequest(method, "RefreshUserToken", params,
                RefreshUserTokenResponse.class);

        RefreshUserTokenResult result = response.getRefreshUserTokenResult();
        return result.getUserToken();
    } catch (JAXBException ex) {
        throw new DevPayException("Problem parsing returned message.", ex);
    } catch (HttpException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new DevPayException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}

From source file:eu.eco2clouds.scheduler.bonfire.BFClientSchedulerImpl.java

@Override
public Compute getVM(String userId, String href) {
    this.userId = userId;
    Boolean exception = false;//from   w w  w. j  ava 2  s.c  o  m
    String computeURL = url + href;

    String response = getMethod(computeURL, exception);
    logger.debug(response);

    Compute compute = new Compute();
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Compute.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        compute = (Compute) jaxbUnmarshaller.unmarshal(new StringReader(response));
    } catch (JAXBException e) {
        logger.warn("Error trying to parse returned status of hosts: " + computeURL + " Exception: "
                + e.getMessage());
        exception = true;
    }

    if (exception)
        return new Compute();
    return compute;
}

From source file:eu.eco2clouds.scheduler.bonfire.BFClientSchedulerImpl.java

@Override
public List<Compute> getVMsOfExperiment(String userId, long experimentId) {
    this.userId = userId;
    Boolean exception = false;//from w ww.  j  a va  2 s . c  o m
    String experimentUrl = url + "/experiments/" + experimentId + "/computes";

    String response = getMethod(experimentUrl, exception);
    logger.debug(response);

    Collection collection = new Collection();

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Collection.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        collection = (Collection) jaxbUnmarshaller.unmarshal(new StringReader(response));
    } catch (JAXBException e) {
        logger.warn("Error trying to parse returned status of hosts: " + experimentUrl + " Exception: "
                + e.getMessage());
        exception = true;
    }

    if (exception)
        return new ArrayList<Compute>();
    return collection.getItems().getComputes();
}

From source file:com.xerox.amazonws.sdb.Domain.java

/**
 * Gets a list of items in this domain filtered by the query string.
 *
 * @param queryString the filter statement
 * @param nextToken the token used to return more items in the query result set
 * @param maxResults a limit to the number of results to return now
  * @return the object containing the items, a more token, etc.
 * @throws SDBException wraps checked exceptions
 *//*from  w  w w  .j a  va 2s.c o  m*/
public QueryResult listItems(String queryString, String nextToken, int maxResults) throws SDBException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("DomainName", domainName);
    params.put("QueryExpression", (queryString == null) ? "" : queryString);
    if (nextToken != null) {
        params.put("NextToken", nextToken);
    }
    if (maxResults > 0) {
        params.put("MaxNumberOfItems", "" + maxResults);
    }
    GetMethod method = new GetMethod();
    try {
        QueryResponse response = makeRequest(method, "Query", params, QueryResponse.class);
        return new QueryResult(response.getQueryResult().getNextToken(),
                Item.createList(response.getQueryResult().getItemNames().toArray(new String[] {}), domainName,
                        getAwsAccessKeyId(), getSecretAccessKey(), isSecure(), getServer(),
                        getSignatureVersion(), getHttpClient()));
    } catch (JAXBException ex) {
        throw new SDBException("Problem parsing returned message.", ex);
    } catch (HttpException ex) {
        throw new SDBException(ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new SDBException(ex.getMessage(), ex);
    } finally {
        method.releaseConnection();
    }
}