Example usage for javax.xml.bind JAXBException getLocalizedMessage

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

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.apache.openaz.xacml.util.XACMLPolicyWriter.java

/**
 * Helper static class that does the work to write a policy set to an output stream.
 *///  w  ww .  ja va 2s  .  com
public static void writePolicyFile(OutputStream os, PolicyType policy) {
    JAXBElement<PolicyType> policySetElement = new ObjectFactory().createPolicy(policy);
    try {
        JAXBContext context = JAXBContext.newInstance(PolicyType.class);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        m.marshal(policySetElement, os);
    } catch (JAXBException e) {
        logger.error("writePolicyFile failed: " + e.getLocalizedMessage());
    }
}

From source file:org.kuali.mobility.academics.dao.AcademicsDaoImplDemo.java

private void initCatalogNumbers() {
    if (getCatalogNumbers().isEmpty()) {
        for (int i = 0; i < 10; i++) {
            LOG.debug("Attempting to load file named: CatalogNumber" + i + ".xml");
            CatalogNumber catalogNumber = null;
            try {
                JAXBContext jc = JAXBContext.newInstance(CatalogNumber.class);
                Unmarshaller um = jc.createUnmarshaller();
                InputStream in = this.getClass().getResourceAsStream("/CatalogNumber" + i + ".xml");
                catalogNumber = (CatalogNumber) um.unmarshal(in);
                getCatalogNumbers().add(catalogNumber);
            } catch (JAXBException jbe) {
                LOG.error(jbe.getLocalizedMessage(), jbe);
            }/*from  w w w .  j ava  2 s .  c om*/
        }
    }
}

From source file:org.openestate.is24.restapi.utils.ExportHandler.java

/**
 * Archivate a real estate object at the Webservice.
 *
 * @param externalObjectId//w ww. ja  va  2  s  .c  o  m
 * external real estate ID
 *
 * @throws IOException
 * if the operation failed
 */
protected final void doArchiveObject(String externalObjectId) throws IOException {
    // Immobilie ermitteln
    final RealEstate is24Object;
    try {
        is24Object = ImportExport.RealEstateService.getByExternalId(this.client, externalObjectId);
        if (is24Object == null) {
            this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_FOUND_FOR_ARCHIVING,
                    "Property '" + externalObjectId + "' is not available anymore at the Webservice!");
            return;
        }
    } catch (JAXBException ex) {
        throw new IOExceptionWithCause("Can't read / write XML while communicating with the Webservice!", ex);
    } catch (OAuthException ex) {
        throw new IOExceptionWithCause("Authorization failed!", ex);
    } catch (RequestFailedException ex) {
        LOGGER.error("Can't get property '" + externalObjectId + "' from the Webservice!");
        if (ex.requestRefNumber != null)
            LOGGER.error("> referring request: " + ex.requestRefNumber);
        logMessagesAsError(ex.responseMessages);
        LOGGER.error("> " + ex.getLocalizedMessage(), ex);
        this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_FOUND_FOR_ARCHIVING, ex);
        return;
    }
    this.doArchiveObject(is24Object);
}

From source file:org.openestate.is24.restapi.utils.ExportHandler.java

/**
 * Archivate a real estate object at the Webservice.
 *
 * @param is24ObjectId// ww w  .j a va2 s  .  c om
 * real estate ID by IS24
 *
 * @param externalObjectId
 * external real estate ID
 *
 * @throws IOException
 * if the operation failed
 */
protected final void doArchiveObject(long is24ObjectId, String externalObjectId) throws IOException {
    // Immobilie ermitteln
    final RealEstate is24Object;
    try {
        is24Object = ImportExport.RealEstateService.getByIs24Id(this.client, is24ObjectId);
        if (is24Object == null) {
            if (!StringUtils.isBlank(externalObjectId)) {
                this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_FOUND_FOR_ARCHIVING,
                        "Property '" + externalObjectId + "' is not available anymore at the Webservice!");
            } else {
                this.putGeneralMessage(ExportMessage.Code.OBJECT_NOT_FOUND_FOR_ARCHIVING,
                        "Property (" + is24ObjectId + ") is not available anymore at the Webservice!");
            }
            return;
        }
    } catch (JAXBException ex) {
        throw new IOExceptionWithCause("Can't read / write XML while communicating with the Webservice!", ex);
    } catch (OAuthException ex) {
        throw new IOExceptionWithCause("Authorization failed!", ex);
    } catch (RequestFailedException ex) {
        if (!StringUtils.isBlank(externalObjectId)) {
            LOGGER.error("Can't get property '" + externalObjectId + "' (" + is24ObjectId
                    + ") from the Webservice!");
            if (ex.requestRefNumber != null)
                LOGGER.error("> referring request: " + ex.requestRefNumber);
            logMessagesAsError(ex.responseMessages);
            LOGGER.error("> " + ex.getLocalizedMessage(), ex);
            this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_FOUND_FOR_ARCHIVING, ex);
        } else {
            LOGGER.error("Can't get property (" + is24ObjectId + ") from the Webservice!");
            if (ex.requestRefNumber != null)
                LOGGER.error("> referring request: " + ex.requestRefNumber);
            logMessagesAsError(ex.responseMessages);
            LOGGER.error("> " + ex.getLocalizedMessage(), ex);
            this.putGeneralMessage(ExportMessage.Code.OBJECT_NOT_FOUND_FOR_ARCHIVING, ex);
        }
        return;
    }
    this.doArchiveObject(is24Object);
}

From source file:org.silverpeas.core.importexport.control.ImportExport.java

/**
 * Mthode retournant l'arbre des objets mapps sur le fichier xml pass en paramtre.
 * @param xmlFileName le fichier xml interprt par JAXB
 * @return Un objet SilverPeasExchangeType contenant le mapping d'un fichier XML
 * @throws ImportExportException/*from   w w  w. j  a va  2s . c om*/
 */
private SilverPeasExchangeType loadSilverpeasExchange(String xmlFileName) throws ImportExportException {
    try {
        File xmlInputSource = new File(xmlFileName);
        String xsdSystemId = settings.getString("xsdDefaultSystemId");

        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = sf.newSchema(new URL(xsdSystemId));

        // Unmarshall the import model
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        unmarshaller.setSchema(schema);
        unmarshaller.setEventHandler(new ImportExportErrorHandler());
        SilverPeasExchangeType silverpeasExchange = (SilverPeasExchangeType) unmarshaller
                .unmarshal(xmlInputSource);

        return silverpeasExchange;

    } catch (JAXBException me) {
        throw new ImportExportException("ImportExport.loadSilverpeasExchange",
                "importExport.EX_UNMARSHALLING_FAILED",
                "XML Filename " + xmlFileName + ": " + me.getLocalizedMessage(), me);
    } catch (MalformedURLException ue) {
        throw new ImportExportException("ImportExport.loadSilverpeasExchange",
                "importExport.EX_UNMARSHALLING_FAILED",
                "XML Filename " + xmlFileName + ": " + ue.getLocalizedMessage(), ue);
    } catch (SAXException ve) {
        throw new ImportExportException("ImportExport.loadSilverpeasExchange", "importExport.EX_PARSING_FAILED",
                "XML Filename " + xmlFileName + ": " + ve.getLocalizedMessage(), ve);
    }
}