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.wso2.carbon.oc.agent.internal.OCAgentUtils.java

/**
 * Extract all enabled publisher info/*  w ww. j  a  v  a  2 s.c  o m*/
 *
 * @return Publishers - get all publisher objects
 */
public static OCPublishers getOcPublishers() {
    OCPublishers publishers = null;
    try {
        JAXBContext context = JAXBContext.newInstance(OCConfiguration.class);
        Unmarshaller um = context.createUnmarshaller();
        OCConfiguration oc = (OCConfiguration) um.unmarshal(new FileReader(
                CarbonUtils.getCarbonConfigDirPath() + File.separator + OCAgentConstants.OC_XML));
        publishers = oc.getOcPublishers();
    } catch (JAXBException e) {
        logger.error(e.getMessage(), e);
    } catch (FileNotFoundException e) {
        logger.error(OCAgentConstants.OC_XML + " is missing in this path", e);
    }

    return publishers;
}

From source file:org.wso2.carbon.rssmanager.core.util.RSSManagerUtil.java

/**
 * Create data source xml definition//w w w . j a v  a2 s  .  c om
 *
 * @param rdbmsConfiguration RDBMS configuration
 * @return DataSourceDefinition
 * @throws RSSManagerException if error occurred while creating xml definition
 */
private static DataSourceMetaInfo.DataSourceDefinition createDSXMLDefinition(
        RDBMSConfiguration rdbmsConfiguration) throws RSSManagerException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        createMarshaller().marshal(rdbmsConfiguration, out);
    } catch (JAXBException e) {
        String msg = "Error occurred while marshalling datasource configuration";
        throw new RSSManagerException(msg, e);
    }
    DataSourceMetaInfo.DataSourceDefinition defn = new DataSourceMetaInfo.DataSourceDefinition();
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    defn.setType(RSSManagerConstants.RDBMS_DATA_SOURCE_TYPE);
    try {
        defn.setDsXMLConfiguration(DataSourceUtils.convertToDocument(in).getDocumentElement());
    } catch (DataSourceException e) {
        throw new RSSManagerException(e.getMessage(), e);
    }
    return defn;
}

From source file:org.wso2.carbon.rssmanager.core.util.RSSManagerUtil.java

private static Marshaller createMarshaller() throws RSSManagerException {
    JAXBContext ctx;/*from ww  w.jav  a 2  s  .c  o m*/
    try {
        ctx = JAXBContext.newInstance(RDBMSConfiguration.class);
        return ctx.createMarshaller();
    } catch (JAXBException e) {
        throw new RSSManagerException(
                "Error creating rdbms data source configuration " + "info marshaller: " + e.getMessage(), e);
    }
}

From source file:org.zaproxy.zap.extension.exportreport.Export.ReportExport.java

public static String generateDUMP(String path, String fileName, String reportTitle, String reportBy,
        String reportFor, String scanDate, String scanVersion, String reportDate, String reportVersion,
        String reportDesc, ArrayList<String> alertSeverity, ArrayList<String> alertDetails)
        throws UnsupportedEncodingException {

    SiteMap siteMap = Model.getSingleton().getSession().getSiteTree();
    SiteNode root = (SiteNode) siteMap.getRoot();
    int siteNumber = root.getChildCount();

    Report report = new Report();
    report.setTitle(entityEncode(reportTitle));
    report.setBy(entityEncode(reportBy));
    report.setFor(entityEncode(reportFor));
    report.setScanDate(entityEncode(scanDate));
    report.setScanVersion(entityEncode(scanVersion));
    report.setReportDate(entityEncode(reportDate));
    report.setReportVersion(entityEncode(reportVersion));
    report.setDesc(entityEncode(reportDesc));

    String description = Constant.messages.getString("exportreport.details.description.label");
    String solution = Constant.messages.getString("exportreport.details.solution.label");
    String otherinfo = Constant.messages.getString("exportreport.details.otherinfo.label");
    String reference = Constant.messages.getString("exportreport.details.reference.label");
    String cweid = Constant.messages.getString("exportreport.details.cweid.label");
    String wascid = Constant.messages.getString("exportreport.details.wascid.label");
    String requestheader = Constant.messages.getString("exportreport.details.requestheader.label");
    String responseheader = Constant.messages.getString("exportreport.details.responseheader.label");
    String requestbody = Constant.messages.getString("exportreport.details.requestbody.label");
    String responsebody = Constant.messages.getString("exportreport.details.responsebody.label");

    try {/*w  w w  .  jav  a 2 s  .c  o m*/
        for (int i = 0; i < siteNumber; i++) {
            SiteNode site = (SiteNode) root.getChildAt(i);
            String siteName = ScanPanel.cleanSiteName(site, true);
            String[] hostAndPort = siteName.split(":");
            boolean isSSL = (site.getNodeName().startsWith("https"));

            Sites s = new Sites();
            s.setHost(entityEncode(hostAndPort[0]));
            s.setName(entityEncode(site.getNodeName()));
            s.setPort(entityEncode(hostAndPort[1]));
            s.setSSL(String.valueOf(isSSL));

            List<Alert> alerts = site.getAlerts();
            Alerts a = new Alerts();
            String temp = "";
            for (Alert alert : alerts) {

                if (!alertSeverity.contains(Alert.MSG_RISK[alert.getRisk()])) {
                    continue;
                }

                AlertItem item = new AlertItem();
                item.setPluginID(entityEncode(Integer.toString(alert.getPluginId())));
                item.setAlert(entityEncode(alert.getAlert()));
                item.setRiskCode(entityEncode(Integer.toString(alert.getRisk())));
                item.setRiskDesc(entityEncode(Alert.MSG_RISK[alert.getRisk()]));
                item.setConfidence(entityEncode(Alert.MSG_CONFIDENCE[alert.getConfidence()]));

                for (int j = 0; j < alertDetails.size(); j++) {
                    if (alertDetails.get(j).equalsIgnoreCase(description))
                        item.setDesc(entityEncode(alert.getDescription()));
                    if (alertDetails.get(j).equalsIgnoreCase(solution))
                        item.setSolution(entityEncode(alert.getSolution()));
                    if (alertDetails.get(j).equalsIgnoreCase(otherinfo) && alert.getOtherInfo() != null
                            && alert.getOtherInfo().length() > 0) {
                        item.setOtherInfo(entityEncode(alert.getOtherInfo()));
                    }
                    if (alertDetails.get(j).equalsIgnoreCase(reference))
                        item.setReference(entityEncode(alert.getReference()));
                    if (alertDetails.get(j).equalsIgnoreCase(cweid) && alert.getCweId() > 0)
                        item.setCWEID(entityEncode(Integer.toString(alert.getCweId())));
                    if (alertDetails.get(j).equalsIgnoreCase(wascid))
                        item.setWASCID(entityEncode(Integer.toString(alert.getWascId())));

                    temp = alert.getMessage().getRequestHeader().toString();
                    if (alertDetails.get(j).equalsIgnoreCase(requestheader) && temp != null
                            && temp.length() > 0) {
                        item.setRequestHeader(entityEncode(temp));
                    }

                    temp = alert.getMessage().getRequestBody().toString();
                    if (alertDetails.get(j).equalsIgnoreCase(requestbody) && temp != null
                            && temp.length() > 0) {
                        item.setRequestBody(entityEncode(temp));
                    }

                    temp = alert.getMessage().getResponseHeader().toString();
                    if (alertDetails.get(j).equalsIgnoreCase(responseheader) && temp != null
                            && temp.length() > 0) {
                        item.setResponseHeader(entityEncode(temp));
                    }

                    temp = alert.getMessage().getResponseBody().toString();
                    if (alertDetails.get(j).equalsIgnoreCase(responsebody) && temp != null
                            && temp.length() > 0) {
                        item.setResponseBody(entityEncode(temp));
                    }
                }

                item.setURI(entityEncode(alert.getUri()));
                if (alert.getParam() != null && alert.getParam().length() > 0)
                    item.setParam(entityEncode(alert.getParam()));
                if (alert.getAttack() != null && alert.getAttack().length() > 0)
                    item.setAttack(entityEncode(alert.getAttack()));
                if (alert.getEvidence() != null && alert.getEvidence().length() > 0)
                    item.setEvidence(entityEncode(alert.getEvidence()));

                a.add(item);
            }
            s.setAlerts(a);
            report.add(s);
        }
        javax.xml.bind.JAXBContext jc = javax.xml.bind.JAXBContext.newInstance(Report.class);
        Marshaller jaxbMarshaller = jc.createMarshaller();
        jaxbMarshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, true);
        jaxbMarshaller.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, Utils.utf8); // used to be utf-8, might not be able to change to upper case.

        jaxbMarshaller.marshal(report, new File(path + fileName + Utils.dump));

        return path + fileName + Utils.dump;
    } catch (JAXBException e) {
        logger.error(e.getMessage(), e);
    }
    return "";
}

From source file:ox.softeng.gel.filereceive.FileReceive.java

public static void main(String[] args) {

    if (hasSimpleOptions(args))
        System.exit(0);//from   w w w .ja  v  a2  s  .  c o  m

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(defineMainOptions(), args);

        long start = System.currentTimeMillis();

        try {
            FileReceive fr = new FileReceive(line.getOptionValue('c'), line.getOptionValue('r'),
                    (Integer) line.getParsedOptionValue("p"),
                    line.getOptionValue('u', ConnectionFactory.DEFAULT_USER),
                    line.getOptionValue('w', ConnectionFactory.DEFAULT_PASS), line.getOptionValue('e'),
                    line.getOptionValue('b'), (Long) line.getParsedOptionValue("t"));
            fr.startMonitors();

            logger.info("File receiver started in {}ms", System.currentTimeMillis() - start);
        } catch (JAXBException ex) {
            logger.error("Could not create file receiver because of JAXBException: {}",
                    ex.getLinkedException().getMessage());
        } catch (IOException | TimeoutException ex) {
            logger.error("Could not create file receiver because: {}", ex.getMessage());
            ex.printStackTrace();
        }
    } catch (ParseException exp) {
        logger.error("Could not start file-receiver because of ParseException: " + exp.getMessage());
        help();
    }
}

From source file:pl.nask.hsn2.workflow.parser.HWLParser.java

private WorkflowSyntaxException makeWorkflowSyntaxException(JAXBException e) {
    int lineNo = -1;
    int colNo = -1;
    String msg = e.getMessage();
    if (e.getLinkedException() instanceof SAXParseException) {
        SAXParseException linked = (SAXParseException) e.getLinkedException();
        lineNo = linked.getLineNumber();
        colNo = linked.getColumnNumber();
        msg = linked.getMessage();//from w w  w  .j  a va2  s . com
    }

    return new WorkflowSyntaxException(e, lineNo, colNo, msg);
}

From source file:scp.cli.Generator.java

/**
 * Entry point (main function) for command line generator
 * //from www  . j  a v a  2 s .  c  o  m
 * @param args command line arguments
 */
public static void main(String args[]) {
    Generator clg = null;
    try {
        clg = new Generator();
        clg.configure(args);
    } catch (JAXBException e) {
        System.out.println("Error while parsing XML: " + e.getMessage());
        return;
    } catch (ParseException e) {
        System.out.println("Error while parsing arguments: " + e.getMessage());
        return;
    } catch (NoArgumentsException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -cp scp.jar scp.cli.Generator OUTPUTFILE [options]", clg.options);
        return;
    } catch (NoFileSpecifiedException e) {
        System.out.println(e.getMessage());
        return;
    }

    clg.generate();

    try {
        clg.save();
    } catch (FileNotFoundException e) {
        System.out.println("Error while saving file: " + e.getMessage());
        return;
    } catch (JAXBException e) {
        System.out.println("Error while generating XML: " + e.getMessage());
        return;
    }
}

From source file:scp.cli.Solver.java

/**
 * Entry point (main function) for command line solver
 * /*  w w  w .j  a  v  a  2 s.  c o  m*/
 * @param args command line arguments
 */
public static void main(String[] args) {

    Solver clh = null;

    try {
        clh = new Solver();
        clh.configure(args);
    } catch (JAXBException e) {
        System.out.println("Error while parsing XML: " + e.getMessage());
        return;
    } catch (ParseException e) {
        System.out.println("Error while parsing arguments: " + e.getMessage());
        return;
    } catch (NoFileSpecifiedException e) {
        System.out.println(e.getMessage());
        return;
    } catch (NoArgumentsException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -cp scp.jar scp.cli.Solver INPUTFILE [options]", clh.options);
        return;
    }

    try {
        clh.run();
    } catch (WrongPlacementException e) {
        System.out.println("Error during placement: " + e.getMessage());
        return;
    }

    try {
        clh.save();
    } catch (FileNotFoundException e) {
        System.out.println("Error while saving file: " + e.getMessage());
        return;
    } catch (JAXBException e) {
        System.out.println("Error while generating XML: " + e.getMessage());
        return;
    }
}

From source file:tds.dll.common.rtspackage.student.StudentPackageReader.java

@Override
public boolean read(String pkg) throws RtsPackageReaderException {
    if (pkg == null) {
        throw new RtsPackageReaderException("Package XML is null");
    }/*  w  w  w.  j  ava  2s .c om*/
    try {
        Unmarshaller jaxbUnmarshaller = _jaxbContext.createUnmarshaller();
        _studentPackage = (StudentPackage) jaxbUnmarshaller.unmarshal(new StringReader(pkg));
        _student = _studentPackage.getStudent();
    } catch (JAXBException e) {
        _logger.debug("Student Package: {}", pkg);
        throw new RtsPackageReaderException(e.getMessage(), e);
    }
    return true;

}

From source file:tds.dll.common.rtspackage.student.StudentPackageReader.java

private static JAXBContext getJaxbContext() {
    try {/*from w w  w.  j a v  a2s.  c  o  m*/
        return JAXBContext.newInstance(StudentPackage.class);
    } catch (JAXBException e) {
        _logger.error(e.getMessage(), e);
    }
    return null;
}