Example usage for javax.xml.xpath XPathExpressionException getMessage

List of usage examples for javax.xml.xpath XPathExpressionException getMessage

Introduction

In this page you can find the example usage for javax.xml.xpath XPathExpressionException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:uk.ac.ebi.fg.biostudies.utils.saxon.search.AbstractIndexEnvironment.java

public Document processEntryIndex(Object node, Configuration config, XPathQueryService service,
        Map<String, XPathExpression> fieldXpe) throws Exception {
    //logger.info("new doc");
    Document luceneDoc = new Document();
    XPath xp = new XPathEvaluator(config);
    for (FieldInfo field : fields.values()) {
        try {/*w  ww .  j a va  2s.c  o  m*/
            if (!field.process) {
                List values = (List) fieldXpe.get(field.name).evaluate(node, XPathConstants.NODESET);
                for (Object v : values) {

                    if ("integer".equals(field.type)) {
                        addIntIndexField(luceneDoc, field.name, v, field.shouldStore, field.shouldSort);

                    } else if ("date".equals(field.type)) {
                        // todo:
                        // addDateIndexField(d,
                        // field.name,
                        // v);
                        logger.error("Date fields are not supported yet, field [{}] will not be created",
                                field.name);
                    } else if ("boolean".equals(field.type)) {
                        addBooleanIndexField(luceneDoc, field.name, v, field.shouldSort);
                    } else {
                        addIndexField(luceneDoc, field.name, v, field.shouldAnalyze, field.shouldStore,
                                field.shouldSort);
                    }
                }

            } else {
                if (field.name.equalsIgnoreCase("attributes")) {
                    // implement here the biosamples
                    // database sample attributes
                    // logic
                    // TODO: rpe
                    // logger.debug("There is A special treatment for this field->"
                    // + field.name);
                    List values = (List) fieldXpe.get(field.name).evaluate(node, XPathConstants.NODESET);

                    for (Iterator iterator = values.iterator(); iterator.hasNext();) {
                        Object object = (Object) iterator.next();
                        // logger.debug("attributes->" + object);
                        String attributeName = (String) fieldXpe.get("attributeName").evaluate(object,
                                XPathConstants.STRING);
                        String attributeValue = (String) fieldXpe.get("attributeValue").evaluate(object,
                                XPathConstants.STRING);
                        //logger.info(attributeName+"->" + attributeValue);
                        addIndexField(luceneDoc, attributeName.toLowerCase(), attributeValue, true, true, true);
                    }
                }
            }
        } catch (XPathExpressionException x) {
            String xmlError = PrintUtils.printNodeInfo((NodeInfo) node, config);
            logger.error("Field being processed->[{}]", field.name);
            xmlError = "##FIELD BEING PROCESSED##->" + field.name + "\n" + xmlError;
            logger.error("XPathExpressionException->[{}]", x.getMessage());
            logger.error("Caught an exception while indexing expression [" + field.path + "] for document ["
                    + ((NodeInfo) node).getStringValue().substring(0, 20) + "...]", x);

            throw new Exception("XPathExpressionException Xml:" + xmlError, x);
        } catch (Exception xe) {
            String xmlError = PrintUtils.printNodeInfo((NodeInfo) node, config);
            logger.error("Generic Exception->[{}]", xe.getMessage());
            throw new Exception("Generic Exception Xml:" + xmlError, xe);
        }
    }

    return luceneDoc;
}