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.sdb.Item.java

/**
 * Gets attributes of a given name. The parameter limits the results to those of
 * the name given./* ww w .  j  av a  2s  .co m*/
 *
 * @param attributeName a name that limits the results
  * @return the list of attributes
 * @throws SDBException wraps checked exceptions
 */
public List<ItemAttribute> getAttributes(String attributeName) throws SDBException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("DomainName", domainName);
    params.put("ItemName", identifier);
    if (attributeName != null) {
        params.put("AttributeName", attributeName);
    }
    GetMethod method = new GetMethod();
    try {
        GetAttributesResponse response = makeRequest(method, "GetAttributes", params,
                GetAttributesResponse.class);
        List<ItemAttribute> ret = new ArrayList<ItemAttribute>();
        List<Attribute> attrs = response.getGetAttributesResult().getAttributes();
        for (Attribute attr : attrs) {
            ret.add(new ItemAttribute(attr.getName(), attr.getValue(), false));
        }
        return ret;
    } 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();
    }
}

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

/**
 * Deletes one or more attributes./* w w  w . j ava 2 s . c  om*/
 *
 * @param attributes the names of the attributes to be deleted
 * @throws SDBException wraps checked exceptions
 */
public void deleteAttributes(List<ItemAttribute> attributes) throws SDBException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("DomainName", domainName);
    params.put("ItemName", identifier);
    if (attributes != null) {
        int i = 1;
        for (ItemAttribute attr : attributes) {
            params.put("Attribute." + i + ".Name", attr.getName());
            String value = attr.getValue();
            if (value != null) {
                params.put("Attribute." + i + ".Value", value);
            }
            i++;
        }
    }
    GetMethod method = new GetMethod();
    try {
        //DeleteAttributesResponse response =
        makeRequest(method, "DeleteAttributes", params, DeleteAttributesResponse.class);
    } 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();
    }
}

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

/**
 * Creates attributes for this item. Each item can have "replace" specified which
 * indicates to replace the Attribute/Value or ad a new Attribute/Value.
 * NOTE: if an attribute value is null, that attribute will be ignored.
 *
 * @param attributes list of attributes to add
 * @throws SDBException wraps checked exceptions
 *//*from  ww w .ja  va 2  s  .  c om*/
public void putAttributes(List<ItemAttribute> attributes) throws SDBException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("DomainName", domainName);
    params.put("ItemName", identifier);
    int i = 1;
    for (ItemAttribute attr : attributes) {
        String val = attr.getValue();
        if (val != null) {
            params.put("Attribute." + i + ".Name", attr.getName());
            params.put("Attribute." + i + ".Value", val);
            if (attr.isReplace()) {
                params.put("Attribute." + i + ".Replace", "true");
            }
            i++;
        }
    }
    GetMethod method = new GetMethod();
    try {
        //PutAttributesResponse response =
        makeRequest(method, "PutAttributes", params, PutAttributesResponse.class);
    } 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();
    }
}

From source file:net.ageto.gyrex.impex.persistence.cassandra.storage.CassandraRepositoryImpl.java

/**
 * Find all processes./*from  ww  w. j a v a2s. co m*/
 * 
 * @return
 */
public List<IProcessConfig> findAllProcesses() {

    RangeSlicesQuery<String, String, String> rangeSlicesQuery = HFactory.createRangeSlicesQuery(
            getImpexKeyspace(), StringSerializer.get(), StringSerializer.get(), StringSerializer.get());
    rangeSlicesQuery.setColumnFamily(columnFamilyProcesses);
    rangeSlicesQuery.setKeys("", "");
    rangeSlicesQuery.setRange("", "", false, 999);

    // rangeSlicesQuery.setRowCount(999);
    QueryResult<OrderedRows<String, String, String>> result = rangeSlicesQuery.execute();
    OrderedRows<String, String, String> orderedRows = result.get();

    List<IProcessConfig> processes = new ArrayList<IProcessConfig>();

    if (orderedRows != null) {
        try {
            for (Row<String, String, String> row : orderedRows) {
                JAXBContext context = JAXBContext.newInstance(ProcessConfig.class);
                Unmarshaller u = context.createUnmarshaller();

                ColumnSlice<String, String> columnSlice = row.getColumnSlice();
                HColumn<String, String> column = columnSlice.getColumnByName(columnNameProcess);
                StringReader reader = new StringReader(column.getValue());

                // create process from xml
                IProcessConfig process = (ProcessConfig) u.unmarshal(reader);
                if (process != null) {
                    processes.add(process);
                }
            }
        } catch (JAXBException e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    }

    return processes;
}

From source file:io.onedecision.engine.decisions.converter.DecisionModelConverter.java

private void writeAsXml(Object o, Writer writer) throws IOException {
    JAXBContext context;//from   w ww  . jav a 2  s  .  c o  m
    try {
        context = JAXBContext.newInstance(o.getClass());
        Marshaller m = context.createMarshaller();
        m.marshal(o, writer);
    } catch (JAXBException e) {
        throw new IOException(e.getMessage(), e);
    }
}

From source file:com.vns.pdf.impl.PdfDocument.java

private void loadTextAreaFile() {
    try {/*  w ww  . ja  v a 2 s.  c  om*/
        JAXBContext context = JAXBContext.newInstance(Doc.class);
        Unmarshaller un = context.createUnmarshaller();
        doc = (Doc) un.unmarshal(textAreaFilePath.toFile());
    } catch (JAXBException ex) {
        LOGGER.error(ex.getMessage(), ex);
    }
}

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

/**
 * Deletes a domain.//from   w w w .  j  av  a2 s  .c om
 *
 * @param name the name of the domain to be deleted
 * @throws SDBException wraps checked exceptions
 */
public void deleteDomain(String name) throws SDBException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("DomainName", name);
    GetMethod method = new GetMethod();
    try {
        //DeleteDomainResponse response =
        makeRequest(method, "DeleteDomain", params, DeleteDomainResponse.class);
    } 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();
    }
}

From source file:com.vns.pdf.impl.PdfDocument.java

private void createTextAreaFile() {
    String pageXmlFileName = textAreaFilePath.toAbsolutePath().toString();
    try {//from   w w w.ja v  a 2 s . co m
        JAXBContext context = JAXBContext.newInstance(Doc.class);
        Marshaller ms = context.createMarshaller();
        ms.setProperty(JAXB_FORMATTED_OUTPUT, true);
        ms.setProperty(CharacterEscapeHandler.class.getName(),
                (CharacterEscapeHandler) (ch, start, length, isAttVal, out) -> {
                    String escape = StringEscapeUtils.escapeXml11(new String(ch));
                    if (!escape.contains("&#"))
                        out.write(escape.toCharArray(), 0, escape.toCharArray().length);
                });
        ms.marshal(doc, new File(pageXmlFileName));
    } catch (JAXBException ex) {
        LOGGER.error(ex.getMessage(), ex);
    }
}

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

/**
 * Creates a domain. If domain already exists, no error is thrown.
 *
 * @param name name of the new domain// w  ww.  j a  va 2s  . c o  m
 * @throws SDBException wraps checked exceptions
 */
public Domain createDomain(String name) throws SDBException {
    Map<String, String> params = new HashMap<String, String>();
    params.put("DomainName", name);
    GetMethod method = new GetMethod();
    try {
        CreateDomainResponse response = makeRequest(method, "CreateDomain", params, CreateDomainResponse.class);
        Domain ret = new Domain(name, getAwsAccessKeyId(), getSecretAccessKey(), isSecure(), getServer());
        ret.setSignatureVersion(getSignatureVersion());
        ret.setHttpClient(getHttpClient());
        return ret;
    } 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();
    }
}

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

/**
 * Gets a list of domains/*from  w  w w  .  j av a2s.co  m*/
 * 
 * @param nextToken token to use when retrieving next results
 * @param maxResults the max number of results to return (0 means no max defined)
 * @throws SDBException wraps checked exceptions
 */
public ListDomainsResult listDomains(String nextToken, int maxResults) throws SDBException {
    Map<String, String> params = new HashMap<String, String>();
    if (nextToken != null) {
        params.put("NextToken", nextToken);
    }
    if (maxResults > 0) {
        params.put("MaxNumberOfDomains", "" + maxResults);
    }
    GetMethod method = new GetMethod();
    try {
        ListDomainsResponse response = makeRequest(method, "ListDomains", params, ListDomainsResponse.class);
        return new ListDomainsResult(response.getListDomainsResult().getNextToken(),
                Domain.createList(response.getListDomainsResult().getDomainNames().toArray(new String[] {}),
                        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();
    }
}