Example usage for javax.xml.xpath XPathExpressionException XPathExpressionException

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

Introduction

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

Prototype

public XPathExpressionException(Throwable cause) 

Source Link

Document

Constructs a new XPathExpressionException with the specified cause .

Usage

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

public String getDefaultManager(String productGroup) throws XPathExpressionException {
    String managerNode = null;//  w  w  w . ja v  a2s . 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 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   ww w  .  j a  v  a2 s.  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;
}