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:tds.itemrenderer.handler.WordListHandlerBase.java

/**
 * Gets JAXB context//  w  ww  . java 2 s .com
 * 
 * @return JAXBContext
 */
private static JAXBContext getJaxbContext() {
    try {
        return JAXBContext.newInstance(Itemrelease.class);
    } catch (JAXBException e) {
        _logger.error(e.getMessage(), e);
    }
    return null;
}

From source file:tds.itemrenderer.processing.ITSDocumentParser.java

/**
 * Gets JAXB context/*from   w ww  .j a v  a  2  s. c  om*/
 *
 * @return JAXBContext
 */
private static JAXBContext getJaxbContext() {
    try {
        return JAXBContext.newInstance(Itemrelease.class);
    } catch (final JAXBException e) {
        _logger.error(e.getMessage(), e);
        throw new IllegalStateException("Cannot initialize JaxbContext", e);
    }
}

From source file:tds.itemrenderer.processing.ITSDocumentParser.java

private Itemrelease parseDocument(final T document, final URI uri, final ItemDataService itemDataService) {
    try (final InputStream xmlStream = new ByteArrayInputStream(
            itemDataService.readData(uri).getBytes(UTF_8))) {
        Unmarshaller jaxbUnmarshaller = _jaxbContext.createUnmarshaller();
        final Itemrelease itemrelease = (Itemrelease) jaxbUnmarshaller.unmarshal(xmlStream);
        document.setValidated(true);/*from   w ww.j  av  a2 s .  c o  m*/
        return itemrelease;
    } catch (IOException ioException) {
        throw new ITSDocumentProcessingException(ioException);
    } catch (JAXBException e) {
        String message = "The XML schema was not valid for the file \"" + document.getBaseUri() + "\"";
        throw new ITSDocumentProcessingException(message + " " + e.getMessage(), e);
    }
}

From source file:tds.student.services.ItemScoringService.java

private String getDimensionsXmlForSP(ItemScore score) throws ReturnStatusException {
    // TODO Shiva: Why are the rationales being set to null ?
    ItemScoreInfo scoreInfo = score.getScoreInfo();
    scoreInfo.setRationale(null);/*from w ww.ja  va2  s .c  o  m*/

    if (scoreInfo.getSubScores() != null) {
        for (ItemScoreInfo subScore : scoreInfo.getSubScores()) {
            subScore.setRationale(null);
        }
    }

    String xml;
    try {
        xml = scoreInfo.toXmlString();
        // TODO Shiva: hack!!! I am not sure at this late stage how the AA will
        // react to the xml string. so i am going to take it out.
        xml = StringUtils.replace(xml, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>", "");
    } catch (JAXBException e) {
        _logger.error(e.getMessage());
        throw new ReturnStatusException("Could not parse scoreinfo xml");
    }
    return xml;
}

From source file:visualoozie.api.UploadXmlAction.java

private UploadXmlResult generateResult(String rawXml) {
    UploadXmlResult result = new UploadXmlResult();

    Scanner scanner = new Scanner(rawXml);
    List<String> lines = new ArrayList<>();
    while (scanner.hasNextLine()) {
        String line = scanner.nextLine();
        lines.add(line);/*from   w w w. ja  va2 s  . c  o m*/
    }
    result.xml = lines.toArray(new String[0]);

    // find xmlns to identify a version for the oozie xsd
    Pattern xmlnsPattern = Pattern.compile("workflow-app *xmlns *= *['|\"](.*?)['|\"]"); // TODO this is not good enough. e.g. when xmlns is on a line after.
    Matcher m = xmlnsPattern.matcher(rawXml);
    String xmlns = null;
    while (m.find()) {
        xmlns = m.group(1);
    }

    result.setIdentifiedNamespace(xmlns);
    List<WorkflowNode> nodes;
    try {
        if ("uri:oozie:workflow:0.1".equals(xmlns)) {
            nodes = new Workflow01Parser().parse(rawXml);
        } else if ("uri:oozie:workflow:0.2".equals(xmlns)) {
            nodes = new Workflow02Parser().parse(rawXml);
        } else if ("uri:oozie:workflow:0.2.5".equals(xmlns)) {
            nodes = new Workflow025Parser().parse(rawXml);
        } else if ("uri:oozie:workflow:0.3".equals(xmlns)) {
            nodes = new Workflow03Parser().parse(rawXml);
        } else if ("uri:oozie:workflow:0.4".equals(xmlns)) {
            nodes = new Workflow04Parser().parse(rawXml);
        } else {
            nodes = new Workflow04Parser().parse(rawXml);
        }
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        result.succeeded = false;
        if (e.getLinkedException() instanceof SAXParseException) {
            SAXParseException e2 = (SAXParseException) e.getLinkedException();
            result.lineNumber = e2.getLineNumber();
            result.columnNumber = e2.getColumnNumber();
            result.errorMessage = e2.getMessage();

        } else {
            e.printStackTrace();
            result.errorMessage = e.getMessage();
        }
        return result;
    } catch (Exception e) {
        e.printStackTrace();
        result.succeeded = false;
        result.errorMessage = e.getMessage();
        return result;
    }

    result.setNodes(nodes);
    result.succeeded = true;
    return result;
}