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:org.talend.job.Configer.java

static String getStringValue(String path, String dv) {
    org.w3c.dom.Document doc = loadDocument();
    if (null != doc) {
        try {//from w  w  w .  j  a va  2s  .  c  o m
            XPathExpression x_path = xpath.compile(path);
            String value = (String) x_path.evaluate(doc, XPathConstants.STRING);
            if (StringUtils.isEmpty(value)) {
                return dv;
            }
            return value;
        } catch (XPathExpressionException e) {
            logger.error(e.getMessage());
        }
    }
    return dv;
}

From source file:org.wso2.appserver.integration.tests.extension.CarbonServerWithReadWriteLdapUSerStoreExtension.java

@Override
public void initiate() throws AutomationFrameworkException {
    AutomationContext context;/*from   w  w w  . ja  va2s .c  om*/
    try {
        context = new AutomationContext("AS", TestUserMode.SUPER_TENANT_ADMIN);
    } catch (XPathExpressionException e) {
        throw new AutomationFrameworkException("Error Initiating Server Information", e);
    }

    //if port offset is not set, setting it to 0
    if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
        getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "0");
    }

    asServerWithApacheLdap = new TestServerManager(context, null, getParameters()) {
        public void configureServer() throws AutomationFrameworkException {

            String userMgtXml = TestConfigurationProvider.getResourceLocation("AS") + File.separator + "configs"
                    + File.separator + "readwriteldap" + File.separator + "user-mgt.xml";

            try {
                log.info("Changing the primary user store configuration to read write ldap");
                FileManager.copyFile(new File(userMgtXml),
                        asServerWithApacheLdap.getCarbonHome() + File.separator + "repository" + File.separator
                                + "conf" + File.separator + "user-mgt.xml");
            } catch (IOException e) {
                log.error("Error while coping user-mgt.xml", e);
                throw new AutomationFrameworkException(e.getMessage(), e);
            }
        }
    };
}

From source file:org.wso2.carbon.appserver.integration.test.server.security.manager.extension.CarbonServerWithSecurityManagerExtension.java

@Override
public void initiate() throws AutomationFrameworkException {
    if (!System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_OS_NAME).toLowerCase()
            .contains(OperatingSystems.WINDOWS.toString().toLowerCase())) {
        AutomationContext context;//from   www  .  j  a  va2 s  . co m
        try {
            context = new AutomationContext("AS", TestUserMode.SUPER_TENANT_ADMIN);
        } catch (XPathExpressionException e) {
            throw new AutomationFrameworkException("Error Initiating Server Information", e);
        }

        //if port offset is not set, setting it to 0
        if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
            getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "0");
        }

        testServerWithSecurityManager = new TestServerManager(context, null, getParameters()) {
            public void configureServer() throws AutomationFrameworkException {

                String resourcePtah = TestConfigurationProvider.getResourceLocation("AS") + File.separator
                        + "security" + File.separator + "manager";

                //copying java options to wso2server.sh
                /**
                 -Djava.security.manager=org.wso2.carbon.bootstrap.CarbonSecurityManager \
                 -Djava.security.policy=$CARBON_HOME/repository/conf/sec.policy \
                 -Drestricted.packages=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.
                 ,com.sun.imageio.,org.wso2.carbon. \
                 -Ddenied.system.properties=javax.net.ssl.trustStore,javax.net.ssl.trustStorePassword
                 ,denied.system.properties \
                 */
                try {
                    addSecOptions(new File(testServerWithSecurityManager.getCarbonHome() + File.separator
                            + "bin" + File.separator + "wso2server.sh"));
                    //copying script file to sign the jar files
                    FileManager.copyFile(new File(resourcePtah + File.separator + "sign-packs.sh"),
                            testServerWithSecurityManager.getCarbonHome() + File.separator + "sign-packs.sh");

                    File commandDir = new File(testServerWithSecurityManager.getCarbonHome());
                    //signing the jar files
                    Process signingProcess = Runtime.getRuntime().exec(new String[] { "sh", "sign-packs.sh" },
                            null, commandDir);
                    ServerLogReader signingProcessInputStreamHandler = new ServerLogReader("inputStream",
                            signingProcess.getInputStream());
                    signingProcessInputStreamHandler.start();
                    //wait signing process to complete
                    signingProcess.waitFor();
                } catch (IOException e) {
                    throw new AutomationFrameworkException(e.getMessage(), e);
                } catch (InterruptedException e) {
                    throw new AutomationFrameworkException(e.getMessage(), e);
                }

            }
        };
    }
}

From source file:org.wso2.carbon.automation.engine.context.DefaultInstance.java

public String getUserKey(String tenantDomain, boolean isAdminUser) throws XPathExpressionException {
    String tenantKey = null;/*www.  j  a v  a 2 s .  c o  m*/
    String adminUserReplacement = ContextXpathConstants.ADMIN;
    try {

        if (!isAdminUser) {
            adminUserReplacement = ContextXpathConstants.USERS;
        }
        if (tenantDomain.equals(getConfigurationValue(ContextXpathConstants.SUPER_TENANT_DOMAIN))) {

            tenantKey = getConfigurationValue(String
                    .format(ContextXpathConstants.USER_MANAGEMENT_SUPER_TENANT_USER_KEY, adminUserReplacement));
        } else {
            tenantKey = getConfigurationValue(String.format(
                    ContextXpathConstants.USER_MANAGEMENT_TENANT_USER_KEY, tenantDomain, adminUserReplacement));
        }
    } catch (XPathExpressionException e) {
        log.error("Error while reading the Tenant:" + e.getMessage());
        throw new XPathExpressionException(
                "Error While Reading default User Key:- " + e.getStackTrace().toString());
    }
    return tenantKey;
}

From source file:org.wso2.carbon.automation.engine.context.DefaultInstance.java

public String getDefaultManager(String productGroup) throws XPathExpressionException {
    String managerNode = null;/* w  w w.j av a 2 s  . co m*/
    try {
        boolean isClustered = Boolean.parseBoolean(getConfigurationValue(
                String.format(ContextXpathConstants.PRODUCT_GROUP_CLUSTERING_ENABLED, productGroup)));
        String xpathNodeType = ContextXpathConstants.PRODUCT_GROUP_INSTANCE_TYPE;
        NodeList lbWorkerManagerList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.lb_worker_manager));
        NodeList lbManagerNodeList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.lb_manager));
        NodeList managerNodeList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.manager));
        NodeList standAloneNodeList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.standalone));

        if (isClustered) {
            if (lbWorkerManagerList.getLength() >= 1) {
                managerNode = lbWorkerManagerList.item(0).getAttributes()
                        .getNamedItem(ContextXpathConstants.NAME).getTextContent();
            } else if (lbManagerNodeList.getLength() >= 1) {
                managerNode = lbManagerNodeList.item(0).getAttributes().getNamedItem(ContextXpathConstants.NAME)
                        .getTextContent();
            } else if (managerNodeList.getLength() >= 1) {
                managerNode = managerNodeList.item(0).getAttributes().getNamedItem(ContextXpathConstants.NAME)
                        .getTextContent();
            } else {
                managerNode = standAloneNodeList.item(0).getAttributes()
                        .getNamedItem(ContextXpathConstants.NAME).getTextContent();
            }
        } else {
            managerNode = standAloneNodeList.item(0).getAttributes().getNamedItem(ContextXpathConstants.NAME)
                    .getTextContent();
        }

    } catch (XPathExpressionException e) {
        log.error("Error while reading the default Manager:" + e.getMessage());
        throw new XPathExpressionException(
                "Error While Reading default Tenant Domain:- " + e.getStackTrace().toString());
    }
    return managerNode;
}

From source file:org.wso2.carbon.automation.engine.context.DefaultInstance.java

public String getDefaultWorker(String productGroup) throws XPathExpressionException {
    String workerNode = null;//from   w  w  w  .  j ava2s .c  om
    try {
        boolean isClustered = Boolean.parseBoolean(getConfigurationValue(
                String.format(ContextXpathConstants.PRODUCT_GROUP_CLUSTERING_ENABLED, productGroup)));
        String xpathNodeType = ContextXpathConstants.PRODUCT_GROUP_INSTANCE_TYPE;
        NodeList lbWorkerManagerList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.lb_worker_manager));
        NodeList lbWorkerNodeList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.lb_worker));
        NodeList workerNodeList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.worker));
        NodeList standAloneNodeList = getConfigurationNodeList(
                String.format(xpathNodeType, productGroup, InstanceType.standalone));

        if (isClustered) {
            if (lbWorkerManagerList.getLength() >= 1) {
                workerNode = lbWorkerManagerList.item(0).getAttributes()
                        .getNamedItem(ContextXpathConstants.NAME).getTextContent();
            } else if (lbWorkerNodeList.getLength() >= 1) {
                workerNode = lbWorkerNodeList.item(0).getAttributes().getNamedItem(ContextXpathConstants.NAME)
                        .getTextContent();
            } else if (workerNodeList.getLength() >= 1) {
                workerNode = workerNodeList.item(0).getAttributes().getNamedItem(ContextXpathConstants.NAME)
                        .getTextContent();
            } else {
                workerNode = standAloneNodeList.item(0).getAttributes().getNamedItem(ContextXpathConstants.NAME)
                        .getTextContent();
            }
        } else {
            workerNode = standAloneNodeList.item(0).getAttributes().getNamedItem(ContextXpathConstants.NAME)
                    .getTextContent();
        }
    } catch (XPathExpressionException e) {
        log.error("Error while reading the default worker:" + e.getMessage());
        throw new XPathExpressionException(
                "Error While Reading default Tenant Domain:- " + e.getStackTrace().toString());
    }
    return workerNode;
}

From source file:org.wso2.carbon.esb.extension.ESBServerExtension.java

@Override
public void initiate() throws AutomationFrameworkException {

    AutomationContext context;//from  w w  w  . ja v a 2  s  .  c o  m
    try {
        context = new AutomationContext("ESB", TestUserMode.SUPER_TENANT_ADMIN);
    } catch (XPathExpressionException e) {
        throw new AutomationFrameworkException("Error Initiating Server Information", e);
    }

    //if port offset is not set, setting it to 0
    if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
        getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "200");
    }

    testServerWithSecurityManager = new TestServerManager(context, null, getParameters()) {
        public void configureServer() throws AutomationFrameworkException {

            String jndiPtah = TestConfigurationProvider.getResourceLocation("ESB") + File.separator + "conf"
                    + File.separator + "jndi.properties";
            String axis2Xml = TestConfigurationProvider.getResourceLocation("ESB") + File.separator + "conf"
                    + File.separator + "axis2" + File.separator + "axis2.xml";
            String libPath = TestConfigurationProvider.getResourceLocation("ESB") + File.separator + "lib";
            String esbConfDir = testServerWithSecurityManager.getCarbonHome() + File.separator + "repository"
                    + File.separator + "conf";
            String esbLibDir = testServerWithSecurityManager.getCarbonHome() + File.separator + "repository"
                    + File.separator + "components" + File.separator + "lib";

            try {
                log.info("Replacing jndi.properties");
                FileManager.copyFile(new File(jndiPtah), esbConfDir + File.separator + "jndi.properties");
                FileManager.copyFile(new File(axis2Xml),
                        esbConfDir + File.separator + "axis2" + File.separator + "axis2.xml");
                log.info("Copying jar files to lib folder");
                FileManager.copyJarFile(new File(libPath + File.separator + "andes-client-3.0.1.jar"),
                        esbLibDir + File.separator);
                FileManager.copyJarFile(new File(libPath + File.separator + "geronimo-jms_1.1_spec-1.1.1.jar"),
                        esbLibDir + File.separator);
                FileManager.copyJarFile(
                        new File(libPath + File.separator + "org.wso2.securevault-1.0.0-wso2v2.jar"),
                        esbLibDir + File.separator);

            } catch (IOException e) {
                throw new AutomationFrameworkException(e.getMessage(), e);
            }

        }
    };

}

From source file:ubic.gemma.core.loader.entrez.pubmed.PubMedXMLParser.java

private Node processRecord(BibliographicReference bibRef, Node record) {
    Node article = null;/*from   www  .j  a  v  a2  s.c o m*/

    NodeList recordNodes = record.getChildNodes();
    for (int p = 0; p < recordNodes.getLength(); p++) {
        Node item = recordNodes.item(p);
        if (!(item instanceof Element)) {
            continue;
        }
        String name = item.getNodeName();
        switch (name) {
        case "Article":
            article = item;
            break;
        case "ChemicalList":
            bibRef.setChemicals(this.extractChemicals(item));
            break;
        case "MeshHeadingList":
            this.processMESH(item, bibRef);
            break;
        case "KeywordList":
            bibRef.setKeywords(this.extractKeywords(item));
            break;
        case "MedlineJournalInfo": {
            NodeList jNodes = item.getChildNodes();
            for (int q = 0; q < jNodes.getLength(); q++) {
                Node jitem = jNodes.item(q);
                if (!(jitem instanceof Element)) {
                    continue;
                }
                if (jitem.getNodeName().equals("MedlineTA")) {
                    bibRef.setPublication(XMLUtils.getTextValue((Element) jitem));
                }
            }
            break;
        }
        case "PMID":
            this.processAccession(bibRef, item);
            break;
        case "CommentsCorrectionsList":
            NodeList jNodes = item.getChildNodes();
            for (int q = 0; q < jNodes.getLength(); q++) {
                Node jitem = jNodes.item(q);
                if (!(jitem instanceof Element)) {
                    continue;
                }
                Node reftype = jitem.getAttributes().getNamedItem("RefType");

                if (reftype == null)
                    continue;

                String reftypeName = ((Attr) reftype).getValue();
                PubMedXMLParser.log.debug(reftypeName);
                if (reftypeName.equals("RetractionIn")) {

                    try {
                        XPathFactory xf = XPathFactory.newInstance();
                        XPath xpath = xf.newXPath();
                        XPathExpression xgds = xpath.compile("RefSource/text()");
                        String ref = (String) xgds.evaluate(jitem, XPathConstants.STRING);

                        xgds = xpath.compile("PMID/text()");
                        String pmid = (String) xgds.evaluate(jitem, XPathConstants.STRING);

                        String description = "Retracted [In: " + ref + " PMID=" + pmid + "]";
                        bibRef.setDescription(description);
                    } catch (XPathExpressionException e) {
                        PubMedXMLParser.log.warn(
                                "Error while trying to get details of the retraction: " + e.getMessage(), e);
                    }
                    /*
                     * Such papers also have <PublicationType>Retracted Publication</PublicationType>
                     */
                }

            }

            break;
        default:
            log.warn("Unrecognized node name " + name);
        }
    }
    return article;
}

From source file:ubic.gemma.loader.entrez.pubmed.PubMedXMLParser.java

private Node processRecord(BibliographicReference bibRef, Node record) throws IOException {
    Node article = null;/*  w w w.  j  a v  a2s. co  m*/

    NodeList recordNodes = record.getChildNodes();
    for (int p = 0; p < recordNodes.getLength(); p++) {
        Node item = recordNodes.item(p);
        if (!(item instanceof Element)) {
            continue;
        }
        String name = item.getNodeName();
        if (name.equals("Article")) {
            article = item;
        } else if (name.equals("ChemicalList")) {
            bibRef.setChemicals(extractChemicals(item));
        } else if (name.equals("MeshHeadingList")) {
            processMESH(item, bibRef);
        } else if (name.equals("KeywordList")) {
            bibRef.setKeywords(extractKeywords(item));
        } else if (name.equals("MedlineJournalInfo")) {
            NodeList jNodes = item.getChildNodes();
            for (int q = 0; q < jNodes.getLength(); q++) {
                Node jitem = jNodes.item(q);
                if (!(jitem instanceof Element)) {
                    continue;
                }
                if (jitem.getNodeName().equals("MedlineTA")) {
                    bibRef.setPublication(XMLUtils.getTextValue((Element) jitem));
                }
            }
        } else if (name.equals("PMID")) {
            processAccession(bibRef, item);
        } else if (name.equals("CommentsCorrectionsList")) {

            NodeList jNodes = item.getChildNodes();
            for (int q = 0; q < jNodes.getLength(); q++) {
                Node jitem = jNodes.item(q);
                if (!(jitem instanceof Element)) {
                    continue;
                }
                Node reftype = jitem.getAttributes().getNamedItem("RefType");

                if (reftype == null)
                    continue;

                String reftypeName = ((Attr) reftype).getValue();
                log.debug(reftypeName);
                if (reftypeName.equals("RetractionIn")) {

                    try {
                        XPathFactory xf = XPathFactory.newInstance();
                        XPath xpath = xf.newXPath();
                        XPathExpression xgds = xpath.compile("RefSource/text()");
                        String ref = (String) xgds.evaluate(jitem, XPathConstants.STRING);

                        xgds = xpath.compile("PMID/text()");
                        String pmid = (String) xgds.evaluate(jitem, XPathConstants.STRING);

                        String description = "Retracted [In: " + ref + " PMID=" + pmid + "]";
                        bibRef.setDescription(description);
                    } catch (XPathExpressionException e) {
                        log.warn("Error while trying to get details of the retraction: " + e.getMessage(), e);
                        continue;
                    }
                    /*
                     * Such papers also have <PublicationType>Retracted Publication</PublicationType>
                     */
                }

            }

        }
    }
    return article;
}

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

public Document processEntryIndex(Object node, Configuration config, XPathQueryService service,
        Map<String, XPathExpression> fieldXpe) throws Exception {
    Document luceneDoc = new Document();
    XPath xp = new XPathEvaluator(config);
    for (FieldInfo field : fields.values()) {
        try {//from w  w w  . ja  v  a  2 s .c om
            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 valClass = (String) fieldXpe.get("attributeName").evaluate(object,
                                XPathConstants.STRING);
                        //TODO: document this on trac and on website documentations help
                        valClass = valClass.replace(" ", "_").toLowerCase();
                        //valClass=valClass.toLowerCase();
                        String valType = (String) fieldXpe.get("attributeType").evaluate(object,
                                XPathConstants.STRING);
                        String valValue = (String) fieldXpe.get("attributeValue").evaluate(object,
                                XPathConstants.STRING);

                        if (!valType.equalsIgnoreCase("integer") && !valType.equalsIgnoreCase("real")) {
                            //TODO: change this value
                            valValue = valValue.substring(0, Math.min(valValue.length(), 25));
                            addIndexField(luceneDoc, "attributes", "=" + valClass + "= " + valValue, true,
                                    false, true);
                        } else {

                            valValue = valValue.trim();
                            int val = 0;
                            if (valValue == null || valValue.equalsIgnoreCase("")
                                    || valValue.equalsIgnoreCase("NaN")) {
                                valValue = "0";
                            }
                            BigDecimal num = new BigDecimal(valValue);
                            num = num.multiply(new BigDecimal(100));
                            int taux = num.toBigInteger().intValue();
                            valValue = String.format("%07d", taux);
                            //I need to mantain the spaces for lucene consider different words
                            addIndexField(luceneDoc, "attributes", "=" + valClass + "= " + valValue, true,
                                    false, true);
                        }
                        //                     logger.debug("@class->" + valClass);
                        //                     logger.debug("@type->" + valType);
                        //                     logger.debug("text->" + valValue);
                    }
                } else {
                    // logger.debug("There is NO special treatment for this field->"
                    // + field.name);
                }
            }
        } 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;
}