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:org.plasma.sdo.helper.PlasmaXSDHelper.java

private Schema unmarshalSchema(String xml) {
    try {// w  w w .  j av a 2 s. c  om
        SchemaDataBinding binding = new SchemaDataBinding(new DefaultValidationEventHandler());
        return (Schema) binding.unmarshal(xml);

    } catch (JAXBException e) {
        log.error(e.getMessage(), e);
        throw new PlasmaRuntimeException(e);
    } catch (SAXException e) {
        log.error(e.getMessage(), e);
        throw new PlasmaRuntimeException(e);
    }
}

From source file:org.plasma.sdo.helper.PlasmaXSDHelper.java

private Schema unmarshalSchema(Reader reader) {
    try {/*  w  w w  .j a v a2s  .c om*/
        SchemaDataBinding binding = new SchemaDataBinding(new DefaultValidationEventHandler());
        return (Schema) binding.unmarshal(reader);

    } catch (JAXBException e) {
        log.error(e.getMessage(), e);
        throw new PlasmaRuntimeException(e);
    } catch (SAXException e) {
        log.error(e.getMessage(), e);
        throw new PlasmaRuntimeException(e);
    }
}

From source file:org.plasma.sdo.helper.PlasmaXSDHelper.java

private Schema unmarshalSchema(Source source) {
    try {/* w w  w . j a  v  a 2 s .  c o m*/
        SchemaDataBinding binding = new SchemaDataBinding(new DefaultValidationEventHandler());
        return (Schema) binding.unmarshal(source);

    } catch (JAXBException e) {
        log.error(e.getMessage(), e);
        throw new PlasmaRuntimeException(e);
    } catch (SAXException e) {
        log.error(e.getMessage(), e);
        throw new PlasmaRuntimeException(e);
    }
}

From source file:org.plasma.sdo.helper.PlasmaXSDHelper.java

private void writeSchemaStagingModel(Model stagingModel, String location, String fileName) {
    try {//from  w ww.  java2s .c o m
        BindingValidationEventHandler debugHandler = new BindingValidationEventHandler() {
            public int getErrorCount() {
                return 0;
            }

            public boolean handleEvent(ValidationEvent ve) {
                ValidationEventLocator vel = ve.getLocator();

                String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber() + ":"
                        + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();

                switch (ve.getSeverity()) {
                default:
                    log.debug(message);
                }
                return true;
            }
        };
        ProvisioningModelDataBinding binding = new ProvisioningModelDataBinding(debugHandler);
        String xml = binding.marshal(stagingModel);
        binding.validate(xml);

        File provDebugFile = null;
        if (location != null)
            provDebugFile = new File(location, fileName);
        else
            provDebugFile = File.createTempFile(fileName, "");
        FileOutputStream provDebugos = new FileOutputStream(provDebugFile);
        log.debug("Writing provisioning model to: " + provDebugFile.getAbsolutePath());
        binding.marshal(stagingModel, provDebugos);
    } catch (JAXBException e) {
        log.debug(e.getMessage(), e);
    } catch (SAXException e) {
        log.debug(e.getMessage(), e);
    } catch (IOException e) {
        log.debug(e.getMessage(), e);
    }

}

From source file:org.plasma.xml.uml.DefaultUMLModelAssembler.java

private Document buildDocumentModel(Query query, String destNamespaceURI, String destNamespacePrefix) {
    ProvisioningModelAssembler stagingAssembler = new ProvisioningModelAssembler(query, destNamespaceURI,
            destNamespacePrefix);/*  w  w w . ja  v a2  s  .  co m*/
    Model model = stagingAssembler.getModel();

    if (log.isDebugEnabled()) {
        try {
            BindingValidationEventHandler debugHandler = new BindingValidationEventHandler() {
                public int getErrorCount() {
                    return 0;
                }

                public boolean handleEvent(ValidationEvent ve) {
                    ValidationEventLocator vel = ve.getLocator();

                    String message = "Line:Col:Offset[" + vel.getLineNumber() + ":" + vel.getColumnNumber()
                            + ":" + String.valueOf(vel.getOffset()) + "] - " + ve.getMessage();
                    String sev = "";
                    switch (ve.getSeverity()) {
                    case ValidationEvent.WARNING:
                        sev = "WARNING";
                        break;
                    case ValidationEvent.ERROR:
                        sev = "ERROR";
                        break;
                    case ValidationEvent.FATAL_ERROR:
                        sev = "FATAL_ERROR";
                        break;
                    default:
                    }
                    log.debug(sev + " - " + message);

                    return true;
                }
            };
            ProvisioningModelDataBinding binding = new ProvisioningModelDataBinding(debugHandler);
            String xml = binding.marshal(model);
            binding.validate(xml);
            log.debug(xml);
        } catch (JAXBException e) {
            log.debug(e.getMessage(), e);
        } catch (SAXException e) {
            log.debug(e.getMessage(), e);
        }
    }

    return buildDocumentModel(model, destNamespaceURI, destNamespacePrefix);
}

From source file:org.silverpeas.core.admin.component.WAComponentRegistry.java

/**
 * Registers the specified workflow as a WAComponent so that it will be available among
 * the instantiable applications in Silverpeas. (A workflow that is instantiated as an
 * application instance is then taken in charge by the Silverpeas Workflow Engine.)
 * </p>//ww  w  . ja  v a 2  s.co  m
 * If a such workflow application already exists, then nothing is done.
 * @param waComponent the WAComponent instance representing a workflow application.
 * @throws SilverpeasRuntimeException if the registration failed.
 */
public void putWorkflow(WAComponent waComponent) {
    if (!componentsByName.containsKey(waComponent.getName())) {
        try {
            Path descriptor = Paths.get(getWAComponentDescriptorHome().toString(), "workflows",
                    waComponent.getName() + ".xml");
            storeComponent(waComponent, descriptor.toFile());
            componentsByName.put(waComponent.getName(), waComponent);
        } catch (JAXBException e) {
            throw new SilverpeasRuntimeException(e.getMessage(), e);
        }
    }
}

From source file:org.silverpeas.core.contribution.template.publication.PublicationTemplateImpl.java

/**
 * load a recordTemplate definition from xml file to java objects
 *
 * @param xmlFileName the xml file name that contains process model definition
 * @return a RecordTemplate object/*from ww w . j  a va  2s  .c  o m*/
 */
public RecordTemplate loadRecordTemplate(String xmlFileName) throws PublicationTemplateException {
    if (!StringUtil.isDefined(xmlFileName)) {
        return null;
    }
    final PublicationTemplateManager templateManager = PublicationTemplateManager.getInstance();
    String filePath = templateManager.makePath(xmlFileName);

    try {
        Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller();
        GenericRecordTemplate recordTemplate = (GenericRecordTemplate) unmarshaller
                .unmarshal(new File(filePath));
        recordTemplate.setTemplateName(fileName.substring(0, fileName.lastIndexOf('.')));
        return recordTemplate;
    } catch (JAXBException e) {
        System.out.println("JAXB : " + e.getMessage());
        throw new PublicationTemplateException("PublicationTemplateImpl.loadRecordTemplate",
                "form.EX_ERR_LOAD_XML_MAPPING", "Publication Template FileName : " + xmlFileName, e);
    }

}

From source file:org.sonar.plugins.kt.advance.batch.FsAbstraction.java

public void cacheApiFile(final File apiXml) {
    try {/*w  ww.  j  av a 2  s.  c om*/
        final ApiFile api = FsAbstraction.readApiXml(apiXml);
        functionNameToApiMap.put(api.function.name, api);
        functionNameToApiMap.put(api.function.cfilename + "::" + api.function.name, api);

    } catch (final JAXBException e) {
        LOG.error("XML parsing failed: " + e.getMessage());
    }
}

From source file:org.squidy.manager.heuristics.HeuristicsHandler.java

/**
 * @param outputStream//from  ww  w  .  j av  a2s  . c o m
 * @param xmi
 */
public void save(OutputStream outputStream, Heuristics data) {
    try {
        Marshaller marshaller = getContext().createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new DefaultNamespacePrefixMapper());
        marshaller.marshal(data, outputStream);
    } catch (JAXBException e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getMessage(), e);
        }
    }
}

From source file:org.squidy.nodes.laserpointer.config.ConfigConnection.java

public ConfigConnection(ConfigManager configManager, Socket socket) {
    this.configManager = configManager;
    this.socket = socket;

    try {/*w w  w.  j a va 2s  . com*/
        unmarshaller = ConfigManager.getJAXBContext().createUnmarshaller();
        marshaller = ConfigManager.getJAXBContext().createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

        start();
    } catch (JAXBException e) {
        if (LOG.isErrorEnabled()) {
            LOG.error("Couldn't initiate JAXB: " + e.getMessage(), e);
        }
    }
}