Package org.wso2.carbon.mediator.service

Examples of org.wso2.carbon.mediator.service.MediatorException


            if (corelateExpr != null) {
                try {
                    correlateExpression =
                        SynapseXPathFactory.getSynapseXPath(corelateOn, EXPRESSION_Q);
                } catch (JaxenException e) {
                    throw new MediatorException("Unable to load the corelate XPATH expression");
                }
            }
        }

        OMElement completeCond = elem.getFirstChildWithName(COMPLETE_CONDITION_Q);
        if (completeCond != null) {
            OMAttribute completeTimeout = completeCond.getAttribute(TIMEOUT_Q);
            if (completeTimeout != null) {
                completionTimeoutSec =
                        Long.parseLong(completeTimeout.getAttributeValue());
            }

            OMElement messageCount = completeCond.getFirstChildWithName(MESSAGE_COUNT_Q);
            if (messageCount != null) {
                OMAttribute min = messageCount.getAttribute(MIN_Q);
                if (min != null) {
                    minMessagesToComplete = Integer.parseInt(min.getAttributeValue());
                }

                OMAttribute max = messageCount.getAttribute(MAX_Q);
                if (max != null) {
                    maxMessagesToComplete = Integer.parseInt(max.getAttributeValue());
                }
            }
        }

        OMElement onComplete = elem.getFirstChildWithName(ON_COMPLETE_Q);
        if (onComplete != null) {

            OMAttribute aggregateExpr = onComplete.getAttribute(EXPRESSION_Q);
            if (aggregateExpr != null) {
                try {
                    aggregationExpression =
                        SynapseXPathFactory.getSynapseXPath(onComplete, EXPRESSION_Q);
                } catch (JaxenException e) {
                    throw new MediatorException("Unable to load the aggregating XPATH");
                }
            }
          
            OMAttribute onCompleteSequence = onComplete.getAttribute(SEQUENCE_Q);
            if (onCompleteSequence != null) {
View Full Code Here


        if (configKey != null) {
            smooksEle.addAttribute(fac.createOMAttribute(
                    "config-key", nullNS, configKey));
        } else {
            throw new MediatorException("config-key not specified");
        }

        smooksEle.addChild(serializeInput());
        smooksEle.addChild(serializeOutput());
View Full Code Here

    public void build(OMElement elem) {
        OMAttribute key = elem.getAttribute(ATT_CONFIG_KEY);

        if (key == null) {
            String msg = "The 'config-key' attribute is required";
            throw new MediatorException(msg);
        }
        this.configKey = key.getAttributeValue();

        OMElement inputElement = elem.getFirstChildWithName(
                new QName(SynapseConstants.SYNAPSE_NAMESPACE, "input"));
View Full Code Here

        }

        if (expression != null) {
            SynapseXPathSerializer.serializeXPath(expression, itrElem, "expression");
        } else {
            throw new MediatorException("Missing expression of the IterateMediator which is required.");
        }

        if(id != null) {
          itrElem.addAttribute("id", id, nullNS);
        }
View Full Code Here

        OMAttribute expression = elem.getAttribute(ATT_EXPRN);
        if (expression != null) {
            try {
                this.expression = SynapseXPathFactory.getSynapseXPath(elem, ATT_EXPRN);
            } catch (JaxenException e) {
                throw new MediatorException("Unable to build the IterateMediator. " + "Invalid XPATH " +
                    expression.getAttributeValue());
            }
        } else {
            throw new MediatorException("XPATH expression is required " +
                "for an IterateMediator under the \"expression\" attribute");
        }

        OMAttribute attachPath = elem.getAttribute(ATT_ATTACHPATH);
        String attachPathValue = "";
        if (attachPath != null && !this.preservePayload) {
            throw new MediatorException("Wrong configuration for the iterate mediator " +
                    ":: if the iterator should not preserve payload, " +
                    "then attachPath can not be present");
        } else if (attachPath != null) {
            attachPathValue = attachPath.getAttributeValue();
        }

        if (!attachPathValue.equals("")) {
            try {
                SynapseXPath xp = new SynapseXPath(attachPathValue);
                OMElementUtils.addNameSpaces(xp, elem, null);
                this.attachPath = xp;
            } catch (JaxenException e) {
                throw new MediatorException("Unable to build the IterateMediator. Invalid XPATH " +
                        attachPathValue);
            }
        }
        OMElement targetElement = elem.getFirstChildWithName(TARGET_Q);
        if (targetElement != null) {
            addChildren(elem, this);
        } else {
            throw new MediatorException("Target for an iterate mediator is required :: missing target");
        }
    }
View Full Code Here

                        } else if (XQItemType.XQITEMKIND_DOCUMENT_ELEMENT == varibelType) {
                            type = "DOCUMENT_ELEMENT";
                        } else if (XQItemType.XQITEMKIND_ELEMENT == varibelType) {
                            type = "ELEMENT";
                        } else {
                            throw new MediatorException("Unknown Type " + varibelType);
                        }
                        if (type != null) {
                            baseElement.addAttribute(fac.createOMAttribute(
                                    "type", nullNS, type));

                        }
                        xquery.addChild(baseElement);
                    }
                } else if (variable.getVariableType() == Variable.CUSTOM_VARIABLE) {
                    QName name = variable.getName();
                    if (name != null) {
                        OMElement customElement = fac.createOMElement("variable", synNS);
                        customElement.addAttribute(fac.createOMAttribute(
                                "name", nullNS, name.getLocalPart()));
                        String regkey = variable.getRegKey();
                        if (regkey != null) {
                            customElement.addAttribute(fac.createOMAttribute(
                                    "key", nullNS, regkey));
                        }
                        SynapseXPath expression = variable.getExpression();
                        if (expression != null) {
                            SynapseXPathSerializer.serializeXPath(expression,
                                    customElement, "expression");
                        }
                        String type = null;
                        int varibelType = variable.getType();
                        if (XQItemType.XQITEMKIND_DOCUMENT == varibelType) {
                            type = "DOCUMENT";
                        } else if (XQItemType.XQITEMKIND_DOCUMENT_ELEMENT == varibelType) {
                            type = "DOCUMENT_ELEMENT";
                        } else if (XQItemType.XQITEMKIND_ELEMENT == varibelType) {
                            type = "ELEMENT";
                        } else if (XQItemType.XQBASETYPE_INT == varibelType) {
                            type = "INT";
                        } else if (XQItemType.XQBASETYPE_INTEGER == varibelType) {
                            type = "INTEGER";
                        } else if (XQItemType.XQBASETYPE_BOOLEAN == varibelType) {
                            type = "BOOLEAN";
                        } else if (XQItemType.XQBASETYPE_BYTE == varibelType) {
                            type = "BYTE";
                        } else if (XQItemType.XQBASETYPE_DOUBLE == varibelType) {
                            type = "DOUBLE";
                        } else if (XQItemType.XQBASETYPE_SHORT == varibelType) {
                            type = "SHORT";
                        } else if (XQItemType.XQBASETYPE_LONG == varibelType) {
                            type = "LONG";
                        } else if (XQItemType.XQBASETYPE_FLOAT == varibelType) {
                            type = "FLOAT";
                        } else if (XQItemType.XQBASETYPE_STRING == varibelType) {
                            type = "STRING";
                        } else {
                            throw new MediatorException("Unknown Type " + varibelType);
                        }
                        if (type != null) {
                            customElement.addAttribute(fac.createOMAttribute(
                                    "type", nullNS, type));
View Full Code Here

        if (xqueryKey != null) {
            //Use KeyFactory to create Key
            ValueFactory keyFactory = new ValueFactory();
            queryKey = keyFactory.createValue(XMLConfigConstants.KEY, elem);
        } else {
            throw new MediatorException("The 'key' attribute is required for the XQuery mediator");
        }
        if (attrTarget != null) {
            String targetValue = attrTarget.getAttributeValue();
            if (targetValue != null && !"".equals(targetValue)) {
                try {
                    this.querySource = targetValue;
                    this.target = SynapseXPathFactory.getSynapseXPath(elem, ATT_TARGET);
                } catch (JaxenException e) {
                    throw new MediatorException("Invalid XPath specified for the target attribute : " +
                            targetValue);
                }
            }
        }
        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processAuditStatus(this, elem);
        OMElement dataSource = elem.getFirstChildWithName(
                new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "dataSource"));
        if (dataSource != null) {
            dataSourceProperties.addAll(getMediatorProperties(dataSource));
        }

        Iterator it = elem.getChildrenWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE,
                "variable"));
        while (it.hasNext()) {
            OMElement variableOM = (OMElement) it.next();
            String name = variableOM.getAttributeValue(ATT_NAME_Q);
            if (name != null && !"".equals(name)) {
                String type = variableOM.getAttributeValue(ATT_TYPE_Q);
                if (type != null && !"".equals(type)) {
                    String value = variableOM.getAttributeValue(ATT_VALUE_Q);
                    Variable variable;
                    if (value != null && !"".equals(value)) {
                        variable = new Variable(new QName(name.trim()));
                        variable.setValue(value.trim());
                        variable.setType(Variable.BASE_VARIABLE);
                    } else {
                        String key = variableOM.getAttributeValue(ATT_KEY_Q);
                        String expr = variableOM.getAttributeValue(ATT_EXPR_Q);
                        variable = new Variable(new QName(name.trim()));
                        variable.setVariableType(Variable.CUSTOM_VARIABLE);
                        if (key != null) {
                            variable.setRegKey(key.trim());
                        }
                        if (expr != null && !"".equals(expr)) {
                            try {
                                variable.setExpression(SynapseXPathFactory.getSynapseXPath(
                                        variableOM, MediatorProperty.ATT_EXPR_Q));
                            } catch (JaxenException e) {
                                throw new MediatorException("Invalid XPath specified for" +
                                        " the expression attribute : " + expr);
                            }
                        }
                    }
                    if ("INT".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_INT);
                    } else if ("INTEGER".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_INTEGER);
                    } else if ("BOOLEAN".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_BOOLEAN);
                    } else if ("BYTE".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_BYTE);
                    } else if ("DOUBLE".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_DOUBLE);
                    } else if ("SHORT".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_SHORT);
                    } else if ("LONG".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_LONG);
                    } else if ("FLOAT".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_FLOAT);
                    } else if ("STRING".equals(type.trim())) {
                        variable.setType(XQItemType.XQBASETYPE_STRING);
                    } else if ("DOCUMENT".equals(type.trim())) {
                        variable.setType(XQItemType.XQITEMKIND_DOCUMENT);
                    } else if ("DOCUMENT_ELEMENT".equals(type.trim())) {
                        variable.setType(XQItemType.XQITEMKIND_DOCUMENT_ELEMENT);
                    } else if ("ELEMENT".equals(type.trim())) {
                        variable.setType(XQItemType.XQITEMKIND_ELEMENT);
                    } else {
                        throw new MediatorException("Unsupported Type");
                    }
                    variables.add(variable);
                }
            }
        }
View Full Code Here

                    case Types.TIMESTAMP: {
                        paramElt.addAttribute(fac.createOMAttribute("type", nullNS, "TIMESTAMP"));
                        break;
                    }
                    default: {
                        throw new MediatorException("Unknown or unsupported JDBC type : " +
                            param.getType());
                    }
                }

                stmntElt.addChild(paramElt);
View Full Code Here

                    if (xpath != null) {
                        try {
                            xp = SynapseXPathFactory.getSynapseXPath(paramElt, ATT_EXPRN);

                        } catch (JaxenException e) {
                            throw new MediatorException("Invalid XPath specified for the source attribute : " +
                                    xpath);
                        }
                    }
                    statement.addParameter(
                            value,
View Full Code Here

                createCustomDataSource(pool);

            } else if (pool.getFirstChildWithName(DSNAME_Q) != null) {
                lookupDataSource(pool);
            } else {
                throw new MediatorException("The DataSource connection information must be specified for " +
                        "using a custom DataSource connection pool or for a JNDI lookup");
            }

        } catch (JaxenException e) {
            throw new MediatorException("Error looking up DataSource connection information");
        }
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.mediator.service.MediatorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.