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:it.okkam.rdf2okkam.ens.client.EnsClient.java

License:asdf

private Entity getTypeTemplateImp(String type) throws OkkamClientException, OkkamCoreException {
    try {/*from  w  w w  . j  av a 2 s  . c  om*/
        String xml = proxy.getTypeTemplate(type);
        XMLEntityConverter converter = new XMLEntityConverter();
        Entity e = converter.xmlToEntity(xml);
        return e;
    } catch (JAXBException exc) {
        log.error("Impossible to get type template, convertion xml -> Entity exception, " + exc.getMessage());
        throw new OkkamClientException(
                "Impossible to get type template, convertion xml -> Entity exception, " + exc.getMessage());
    } catch (Exception exc) {
        log.error("Impossible to get type template, client exception, " + exc.getMessage());
        throw new OkkamClientException(exc.getMessage());
    } catch (Throwable t) {
        log.error("Impossible to get type template, client exception, " + t.getMessage());
        throw new OkkamClientException(t.getMessage());
    }
}

From source file:eu.eco2clouds.scheduler.accounting.client.AccountingClientHC.java

@Override
public Experiment createExperiment(Experiment experiment) {
    Boolean exception = false;/*  w w w .jav a  2s.c  o  m*/
    String experimentUrl = url + "/experiments/";
    logger.debug("URL build: " + experimentUrl);

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Experiment.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        marshaller.marshal(experiment, out);
        String payload = out.toString();

        String response = postMethod(experimentUrl, payload, experiment.getBonfireUserId(),
                experiment.getBonfireGroupId(), exception);
        logger.debug("PAYLOAD: " + response);

        try {
            jaxbContext = JAXBContext.newInstance(Experiment.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            experiment = (Experiment) jaxbUnmarshaller.unmarshal(new StringReader(response));
        } catch (JAXBException e) {
            logger.warn("Error trying incoming experiment to object. Exception: " + e.getMessage());
            exception = true;
        }
    } catch (JAXBException e) {
        logger.warn("Error trying to parse returned experiment from database: " + url + "/experiments"
                + " Exception: " + e.getMessage());
        exception = true;
    }

    if (exception)
        return new Experiment();
    return experiment;
}

From source file:eu.eco2clouds.scheduler.accounting.client.AccountingClientHC.java

@Override
public Experiment updateExperiment(Experiment experiment) {
    Boolean exception = false;/*from  ww  w . ja v a  2s  .c  o  m*/
    String experimentUrl = url + "/experiments/" + experiment.getId().intValue();
    logger.debug("URL build: " + experimentUrl);

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Experiment.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        marshaller.marshal(experiment, out);
        String payload = out.toString();

        String response = putMethod(experimentUrl, payload, experiment.getBonfireUserId(),
                experiment.getBonfireGroupId(), exception);
        logger.debug("PAYLOAD: " + response);

        try {
            jaxbContext = JAXBContext.newInstance(Experiment.class);
            Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            experiment = (Experiment) jaxbUnmarshaller.unmarshal(new StringReader(response));
        } catch (JAXBException e) {
            logger.warn("Error trying incoming experiment to object. Exception: " + e.getMessage());
            exception = true;
        }
    } catch (JAXBException e) {
        logger.warn("Error trying to parse returned experiment from database: " + url + "/experiments"
                + " Exception: " + e.getMessage());
        exception = true;
    }

    if (exception)
        return new Experiment();
    return experiment;
}

From source file:it.okkam.rdf2okkam.ens.client.EnsClient.java

License:asdf

private Vector<Entity> getEntitiesImp(List<String> oids, String authKey)
        throws OkkamClientException, OkkamCoreException {
    try {//from  ww w .  j  a v  a  2  s. c  o m
        // load the proxy

        XMLEntityConverter converter = new XMLEntityConverter();
        // convert the list -> array

        String[] clientIds = oids.toArray(new String[0]);

        String[] clientResult = proxy.getEntities(clientIds);
        // convert the results
        Vector<Entity> vector = new Vector<Entity>(clientResult.length);
        for (int i = 0; i < clientResult.length; i++) {
            String xml = clientResult[i];
            Entity e = converter.xmlToEntity(xml);
            vector.add(e);
        }
        return vector;
    } catch (JAXBException exc) {
        log.error("Impossible to get the entities, convertion xml -> Entity exception, " + exc.getMessage());
        throw new OkkamClientException(
                "Impossible to get the entities, convertion xml -> Entity exception, " + exc.getMessage());
    }

    catch (Exception exc) {
        log.error("Impossible to get the entities, core exception, " + exc.getMessage());
        throw new OkkamClientException(exc.getMessage());
    } catch (Throwable t) {
        log.error("Impossible to get the entities, client exception, " + t.getMessage());
        throw new OkkamClientException(t.getMessage());
    }
}

From source file:eu.trentorise.smartcampus.permissionprovider.manager.ResourceManager.java

/**
 * Read the resources from the XML descriptor
 * @return//from   ww  w .j a v  a 2s  . co m
 */
private List<Service> loadResourceTemplates() {
    try {
        JAXBContext jaxb = JAXBContext.newInstance(ServiceDescriptor.class, Services.class,
                ResourceMapping.class, ResourceDeclaration.class);
        Unmarshaller unm = jaxb.createUnmarshaller();
        JAXBElement<Services> element = (JAXBElement<Services>) unm.unmarshal(
                new StreamSource(getClass().getResourceAsStream("resourceTemplates.xml")), Services.class);
        return element.getValue().getService();
    } catch (JAXBException e) {
        logger.error("Failed to load resource templates: " + e.getMessage(), e);
        return Collections.emptyList();
    }
}

From source file:eu.eco2clouds.scheduler.accounting.client.AccountingClientHC.java

@Override
public HostPool getHostStatusForATestbed(Testbed testbed) {
    Boolean exception = false;/*from  w  w w.  j  a  v  a  2 s  .  c o  m*/
    String testbedsUrl = url + "/testbeds/" + testbed.getName() + "/status";

    String response = getMethod(testbedsUrl, null, null, exception);

    HostPool hostPool = new HostPool();

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

    if (exception)
        return new HostPool();
    return hostPool;
}

From source file:eu.eco2clouds.scheduler.accounting.client.AccountingClientHC.java

@Override
public List<Testbed> getListOfTestbeds() {
    Boolean exception = false;//  w  ww  .j a  v a2 s . co m
    String testbedsUrl = url + "/testbeds";

    logger.debug("CONNECTING TO: " + url);

    String response = getMethod(testbedsUrl, null, null, exception);
    logger.debug("PAYLOAD: " + 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 list of testbed: " + url + "/testbeds" + " Exception: "
                + e.getMessage());
        exception = true;
    }

    if (exception)
        return new ArrayList<Testbed>();

    return collection.getItems().getTestbeds();
}

From source file:eu.eco2clouds.scheduler.accounting.client.AccountingClientHC.java

private Experiment getExperiment(String experimentUrl, String bonfireUser, String bonfireGroup) {
    Boolean exception = false;/*from  www.j ava 2s. c  o m*/

    String response = getMethod(experimentUrl, bonfireUser, bonfireGroup, exception);
    logger.debug("PAYLOAD: " + response);

    Experiment experiment = new Experiment();

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Experiment.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        experiment = (Experiment) jaxbUnmarshaller.unmarshal(new StringReader(response));
    } catch (JAXBException e) {
        logger.warn("Error trying to parse returned list of testbed: " + url + "/experiments" + " Exception: "
                + e.getMessage());
        exception = true;
    }

    if (exception)
        return new Experiment();
    setStatusExperiment(experiment);

    return experiment;
}

From source file:eu.eco2clouds.scheduler.accounting.client.AccountingClientHC.java

@Override
public Testbed getTestbed(String location) {
    Boolean exception = false;// w  w w.j  a v  a2  s.  c  o m
    String testbedUrl = url + "/testbeds/" + location;

    String response = getMethod(testbedUrl, null, null, exception);
    logger.debug("PAYLOAD: " + response);

    Testbed testbed = new Testbed();

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Testbed.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        testbed = (Testbed) jaxbUnmarshaller.unmarshal(new StringReader(response));
    } catch (JAXBException e) {
        logger.warn("Error trying to parse returned list of testbed: " + url + "/testbeds/" + location
                + " Exception: " + e.getMessage());
        exception = true;
    }

    return testbed;
}

From source file:eu.eco2clouds.scheduler.accounting.client.AccountingClientHC.java

@Override
public List<Experiment> getListOfExperiments(String bonfireUser, String bonfireGroup) {
    Boolean exception = false;//  w  ww  .  ja va2 s.  co  m
    String experimentsUrl = url + "/experiments";

    String response = getMethod(experimentsUrl, bonfireUser, bonfireGroup, exception);
    logger.debug("PAYLOAD: " + 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 list of testbed: " + url + "/experiments" + " Exception: "
                + e.getMessage());
        exception = true;
    }

    if (exception)
        return new ArrayList<Experiment>();

    List<Experiment> experiments = collection.getItems().getExperiments();

    if (experiments != null) {
        for (Experiment experiment : collection.getItems().getExperiments()) {
            setStatusExperiment(experiment);
        }
    }

    return collection.getItems().getExperiments();
}