Examples of MediatorException


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

        return faultNode;
    }

    public void setFaultNode(URI faultNode) {
        if (soapVersion == SOAP11) {
            throw new MediatorException("A fault node does not apply to a SOAP 1.1 fault");
        }
        this.faultNode = faultNode;
    }
View Full Code Here

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

        } else if (faultCodeExpr != null) {
            SynapseXPathSerializer.serializeXPath(faultCodeExpr, code, "expression");

        } else if (soapVersion != POX) {
            throw new MediatorException("Fault code is required for a fault " +
                    "mediator unless it is a pox fault");
        }

        OMElement reason = fac.createOMElement("reason", synNS, fault);
        if (faultReasonValue != null) {
            reason.addAttribute(fac.createOMAttribute(
                "value", nullNS, faultReasonValue));

        } else if (faultReasonExpr != null) {

            SynapseXPathSerializer.serializeXPath(
                faultReasonExpr, reason, "expression");

        } else if (soapVersion != POX) {
            throw new MediatorException("Fault reason is required for a fault " +
                    "mediator unless it is a pox fault");
        }


        if (faultNode != null) {
View Full Code Here

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

            } else if (SOAP12_STRING.equals(version.getAttributeValue())) {
                soapVersion = SOAP12;
            } else if (POX_STRING.equals(version.getAttributeValue())) {
                soapVersion = POX;
            } else {
                throw new MediatorException("Invalid SOAP version");
            }
        }

        OMAttribute response = elem.getAttribute(ATT_RESPONSE_Q);
        if (response != null) {
            if ("true".equals(response.getAttributeValue())) {
                markAsResponse = true;
            } else if ("false".equals(response.getAttributeValue())) {
                markAsResponse = false;
            } else {
                throw new MediatorException("Invalid value '" + response.getAttributeValue()
                        + "' passed as response. Expected 'true' or 'false'");
            }
            serializeResponse = true;
        }

        OMElement code = elem.getFirstChildWithName(CODE_Q);
        if (code != null) {
            OMAttribute value = code.getAttribute(ATT_VALUE);
            OMAttribute expression = code.getAttribute(ATT_EXPRN);

            if (value != null) {
                String strValue = value.getAttributeValue();
                String prefix = null;
                String name = null;
                if (strValue.indexOf(":") != -1) {
                    prefix = strValue.substring(0, strValue.indexOf(":"));
                    name = strValue.substring(strValue.indexOf(":")+1);
                } else {
                    throw new MediatorException("A QName is expected for fault code as prefix:name");
                }
                String namespaceURI = OMElementUtils.getNameSpaceWithPrefix(prefix, code);
                if (namespaceURI == null) {
                    throw new MediatorException("Invalid namespace prefix '" + prefix + "' in code attribute");
                }
                faultCodeValue = new QName(namespaceURI, name, prefix);
            } else if (expression != null) {
                try {
                    faultCodeExpr = SynapseXPathFactory.getSynapseXPath(code, ATT_EXPRN);
                } catch (JaxenException je) {
                    throw new MediatorException("Invalid fault code expression : " + je.getMessage());
                }
            } else {
                throw new MediatorException("A 'value' or 'expression' attribute must specify the fault code");
            }

        } else if (soapVersion != POX) {
            throw new MediatorException("The fault code is a required attribute for the " +
                    "makefault mediator unless it is a pox fault");
        }

        OMElement reason = elem.getFirstChildWithName(REASON_Q);
        if (reason != null) {
            OMAttribute value = reason.getAttribute(ATT_VALUE);
            OMAttribute expression = reason.getAttribute(ATT_EXPRN);

            if (value != null) {
                faultReasonValue = value.getAttributeValue();
            } else if (expression != null) {
                try {
                    faultReasonExpr = SynapseXPathFactory.getSynapseXPath(reason, ATT_EXPRN);
                } catch (JaxenException je) {
                    throw new MediatorException("Invalid fault reason expression : " + je.getMessage());
                }
            } else {
                throw new MediatorException("A 'value' or 'expression' attribute must specify the fault code");
            }

        } else if (soapVersion != POX) {
            throw new MediatorException("The fault reason is a required attribute for the " +
                    "makefault mediator unless it is a pox fault");
        }

        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processAuditStatus(this, elem);

        OMElement node = elem.getFirstChildWithName(NODE_Q);
        if (node != null && node.getText() != null) {
            try {
                faultNode = new URI(node.getText());
            } catch (URISyntaxException e) {
                throw new MediatorException("Invalid URI specified for fault node : " + node.getText());
            }
        }

        OMElement role = elem.getFirstChildWithName(ROLE_Q);
        if (role != null && role.getText() != null) {
            try {
                faultRole = new URI(role.getText());
            } catch (URISyntaxException e) {
                throw new MediatorException("Invalid URI specified for fault role : " + role.getText());
            }
        }

        OMElement detail = elem.getFirstChildWithName(DETAIL_Q);
        if (detail != null) {
            OMAttribute detailExpr = detail.getAttribute(ATT_EXPRN);
            if (detailExpr != null && detailExpr.getAttributeValue() != null) {
                try {
                    faultDetailExpr = SynapseXPathFactory.getSynapseXPath(detail, ATT_EXPRN);
                } catch (JaxenException e) {
                    throw new MediatorException("Unable to build the XPath for fault detail " +
                            "from the expression : " + detailExpr.getAttributeValue());
                }
            } else if (detail.getFirstOMChild() != null) {
                OMNode detailNode = detail.getFirstOMChild();
                if (detailNode instanceof OMText) {
View Full Code Here

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

        if (name != null) {
            property.addAttribute(fac.createOMAttribute(
                    "name", nullNS, name));
        } else {
            throw new MediatorException("Property name not specified");
        }

        if (action == ACTION_SET) {
            if (value != null) {
                property.addAttribute(fac.createOMAttribute(
                        "value", nullNS, value));
            } else if (expression != null) {
                SynapseXPathSerializer.serializeXPath(expression, property, "expression");
            } else if (valueElement != null) {
                property.addChild(valueElement);
            } else {
                throw new MediatorException("Property value, expression or inline " +
                        "element must be set");
            }

            if (pattern != null) {
                property.addAttribute(fac.createOMAttribute("pattern", nullNS, pattern));
View Full Code Here

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

        OMAttribute patternAttr = elem.getAttribute(ATT_PATTERN);
        OMAttribute groupAttr = elem.getAttribute(ATT_GROUP);

        if (nameAttr == null) {
            String msg = "The 'name' attribute is required for the configuration of a property mediator";
            throw new MediatorException(msg);
        } else if ((valueAttr == null && expressionAttr == null) && !(actionAttr != null && "remove".equals(actionAttr.getAttributeValue()))) {
            String msg = "Either an 'value' or 'expression' attribute is required for a property mediator when action is SET";
            throw new MediatorException(msg);
        }

        this.name = nameAttr.getAttributeValue();

        // The action attribute is optional, if provided and equals to 'remove' the
        // property mediator will act as a property remove mediator
        if (actionAttr != null && "remove".equals(actionAttr.getAttributeValue())) {
            this.action = ACTION_REMOVE;
        }

        if (valueAttr != null) {
            this.value = valueAttr.getAttributeValue();
        } else if (expressionAttr != null) {
            try {
                this.expression = SynapseXPathFactory.getSynapseXPath(elem, ATT_EXPRN);
            } catch (JaxenException e) {
                String msg = "Invalid XPath expression for attribute 'expression' : " + expressionAttr.getAttributeValue();
                throw new MediatorException(msg);
            }
        } else if (elem.getFirstElement() != null) {
            valueElement = elem.getFirstElement();
        }

        if (scopeAttr != null) {
            String valueStr = scopeAttr.getAttributeValue();
            if (!XMLConfigConstants.SCOPE_AXIS2.equals(valueStr) && !XMLConfigConstants.SCOPE_TRANSPORT.equals(valueStr)
                    && !XMLConfigConstants.SCOPE_DEFAULT.equals(valueStr) && !XMLConfigConstants.SCOPE_CLIENT.equals(valueStr)) {
                String msg = "Only '" + XMLConfigConstants.SCOPE_AXIS2 + "' or '" + XMLConfigConstants.SCOPE_TRANSPORT + "' or '" + XMLConfigConstants.SCOPE_CLIENT
                        + "' values are allowed for attribute scope for a property mediator"
                        + ", Unsupported scope " + valueStr;
                throw new MediatorException(msg);
            }
            this.scope = valueStr;
        }

        if (typeAttr != null) {
View Full Code Here

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

        if (command != null) {
            pojoCommand.addAttribute(fac.createOMAttribute(
                "name", nullNS, command));
        } else {
            throw new MediatorException("Invalid POJO Command mediator. The command class name is required");
        }

        for (String propName : getStaticSetterProperties().keySet()) {
            Object value = getStaticSetterProperties().get(propName);
            OMElement prop = fac.createOMElement(PROP_Q.getLocalPart(), synNS);
            prop.addAttribute(fac.createOMAttribute("name", nullNS, propName));

            if (value instanceof String) {
                prop.addAttribute(fac.createOMAttribute("value", nullNS, (String) value));
            } else if (value instanceof OMElement) {
                prop.addChild((OMElement) value);
            } else {
                throw new MediatorException("Unable to serialize the command " +
                    "mediator property with the naem " + propName + " : Unknown type");
            }

            if (getContextGetterProperties().containsKey(propName)) {
                prop.addAttribute(fac.createOMAttribute("context-name", nullNS,
View Full Code Here

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

    public void build(OMElement elem) {
        OMAttribute name = elem.getAttribute(ATT_NAME);
        if (name == null) {
            String msg = "The name of the actual POJO command implementation class" +
                    " is a required attribute";
            throw new MediatorException(msg);
        }

        this.command = name.getAttributeValue();

        // setting the properties to the command. these properties will be instantiated
        // at the mediation time
        for (Iterator it = elem.getChildElements(); it.hasNext();) {
            OMElement child = (OMElement) it.next();
            if("property".equals(child.getLocalName())) {

                OMAttribute nameAttr = child.getAttribute(ATT_NAME);
                if (nameAttr != null && nameAttr.getAttributeValue() != null
                    && !"".equals(nameAttr.getAttributeValue())) {

                    handlePropertyAction(nameAttr.getAttributeValue(), child);
                } else {
                    throw new MediatorException("A POJO command mediator " +
                        "property must specify the name attribute");
                }
            }
        }
    }
View Full Code Here

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

        try {
            if (exprAttr != null) {
                xpath = SynapseXPathFactory.getSynapseXPath(propElem, ATT_EXPRN);
            }
        } catch (JaxenException e) {
            throw new MediatorException("Error in building the expression as an SynapseXPath" + e);
        }

        // if there is a value attribute there is no action (action is implied as read value)
        if (valueAttr != null) {
            String value = valueAttr.getAttributeValue();
            // all other three attributes can not co-exists
            if (exprAttr != null && ctxNameAttr != null) {
                throw new MediatorException("Command properties can not contain all three 'value', " +
                    "'expression' and 'context-name' attributes. Only one or " +
                    "combination of two can be there.");
            } else {
                addStaticSetterProperty(name, value);
                if (exprAttr != null) {
                    // action ==> ReadValueAndUpdateMesssage
                    addMessageGetterProperty(name, xpath);
                } else if (ctxNameAttr != null) {
                    // action ==> ReadValueAndUpdateContext
                    addContextGetterProperty(name, ctxNameAttr.getAttributeValue());
                } // else the action ==> ReadValue
            }
        } else if (propElem.getFirstElement() != null) {
            // all other two attributes can not co-exists
            if (exprAttr != null && ctxNameAttr != null) {
                throw new MediatorException("Command properties can not contain all the " +
                    "'expression' and 'context-name' attributes with a child. Only one " +
                    "attribute of those can co-exists with a child");
            } else {
                addStaticSetterProperty(name, propElem.getFirstElement());
                if (exprAttr != null) {
                    // action ==> ReadValueAndUpdateMesssage
                    addMessageGetterProperty(name, xpath);
                } else if (ctxNameAttr != null) {
                    // action ==> ReadValueAndUpdateContext
                    addContextGetterProperty(name, ctxNameAttr.getAttributeValue());
                } // else the action ==> ReadValue
            }
        } else {
            // if both context-name and expression is there
            if (exprAttr != null && ctxNameAttr != null) {
                if (actionAttr != null && actionAttr.getAttributeValue() != null) {
                    String action = actionAttr.getAttributeValue();
                    if (RM_ACTION.equals(action) || UC_ACTION.equals(action)) {
                        // action ==> ReadMessageAndUpdateContext
                        addMessageSetterProperty(name, xpath);
                        addContextGetterProperty(name, ctxNameAttr.getAttributeValue());
                    } else if (RC_ACTION.equals(action) || UM_ACTION.equals(action)) {
                        // action ==> ReadContextAndUpdateMessage
                        addContextSetterProperty(name, ctxNameAttr.getAttributeValue());
                        addMessageGetterProperty(name, xpath);
                    } else {
                        throw new MediatorException("Invalid action for " +
                            "the command property with the name " + name);
                    }
                } else {
                    throw new MediatorException("Action attribute " +
                        "is required for the command property with name " + name);
                }
            } else {
                // only one of expression or context-name is present
                if (actionAttr != null && actionAttr.getAttributeValue() != null) {
                    String action = actionAttr.getAttributeValue();
                    if (exprAttr != null) {
                        if (RM_ACTION.equals(action)) {
                            // action ==> ReadMessage
                            addMessageSetterProperty(name, xpath);
                        } else if (UM_ACTION.equals(action)) {
                            // action ==> UpdateMessage
                            addMessageGetterProperty(name, xpath);
                        } else if (RAUM_ACTION.equals(action)) {
                            // action ==> ReadAndUpdateMessage
                            addMessageSetterProperty(name, xpath);
                            addMessageGetterProperty(name, xpath);
                        } else {
                            throw new MediatorException("Invalid action for " +
                                "the command property with the name " + name);
                        }
                    } else if (ctxNameAttr != null) {
                        String ctxName = ctxNameAttr.getAttributeValue();
                        if (RC_ACTION.equals(action)) {
                            // action ==> ReadContext
                            addContextSetterProperty(name, ctxName);
                        } else if (UC_ACTION.equals(action)) {
                            // action ==> UpdateContext
                            addContextGetterProperty(name, ctxName);
                        } else if (RAUC_ACTION.equals(action)) {
                            // action ==> ReadAndUpdateContext
                            addContextSetterProperty(name, ctxName);
                            addContextGetterProperty(name, ctxName);
                        } else {
                            throw new MediatorException("Invalid action for " +
                                "the command property with the name " + name);
                        }
                    } else {
                        throw new MediatorException("Unrecognized command property with the name " + name);
                    }
                } else {
                    // action ==> ReadAndUpdateMessage/Context
                    if (exprAttr != null) {
                        addMessageSetterProperty(name, xpath);
                        addMessageGetterProperty(name, xpath);
                    } else if (ctxNameAttr != null) {
                        String ctxName = ctxNameAttr.getAttributeValue();
                        addContextSetterProperty(name, ctxName);
                        addContextGetterProperty(name, ctxName);
                    } else {
                        throw new MediatorException("Unrecognized command property with the name " + name);
                    }
                }
            }
        }
    }
View Full Code Here

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

                        && !sourceXpathAttr.getAttributeValue().equals("")) {
                    try {
                        sourceExpression = SynapseXPathFactory.getSynapseXPath(childElem, new QName(XPATH));
                    } catch (JaxenException e) {
                        String msg = "Invalid XPath expression for 'source' attribute 'xpath' : " + sourceXpathAttr.getAttributeValue();
                        throw new MediatorException(msg);
                    }
                }

                OMAttribute sourcePropertyAttr = childElem.getAttribute(new QName(PROPERTY));
                if (sourcePropertyAttr != null && sourcePropertyAttr.getAttributeValue() != null) {
                    sourceProperty = sourcePropertyAttr.getAttributeValue();
                }

                OMElement inlineXMLElement = childElem.getFirstElement();
                if (inlineXMLElement != null) {
                    sourceInlineXML = inlineXMLElement.toString();
                } else if (childElem.getAttributeValue(new QName(null, INLINE_REG_KEY)) != null) {
                    inlineSourceRegKey = childElem.getAttributeValue(new QName(null, INLINE_REG_KEY));
                }
            }

            if (childElem.getLocalName().equals(TARGET)) {
                OMAttribute actionAttr = childElem.getAttribute(new QName(ACTION));
                if (actionAttr != null && actionAttr.getAttributeValue() != null) {
                    targetAction = actionAttr.getAttributeValue();
                } else {
                    targetAction = DEFAULT_TARGET_ACTION_TYPE;
                }

                OMAttribute targetTypeAttr = childElem.getAttribute(new QName(TYPE));
                if (targetTypeAttr != null && targetTypeAttr.getAttributeValue() != null) {
                    targetType = targetTypeAttr.getAttributeValue();
                } else {
                    targetType = DEFAULT_TARGET_TYPE;
                }

                OMAttribute targetXpathAttr = childElem.getAttribute(new QName(XPATH));
                if (targetXpathAttr != null
                        && targetXpathAttr.getAttributeValue() != null
                        && !targetXpathAttr.getAttributeValue().equals("")) {
                    try {
                        targetExpression = SynapseXPathFactory.getSynapseXPath(childElem, new QName(XPATH));
                    } catch (JaxenException e) {
                        String msg = "Invalid XPath expression for 'target' attribute 'xpath' : " + targetXpathAttr.getAttributeValue();
                        throw new MediatorException(msg);
                    }

                }

                OMAttribute targetPropertyAttr = childElem.getAttribute(new QName(PROPERTY));
View Full Code Here

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

            for (MediatorProperty mp : explicityFeatures) {
                OMElement feature = fac.createOMElement("feature", synNS, validate);
                if (mp.getName() != null) {
                    feature.addAttribute(fac.createOMAttribute("name", nullNS, mp.getName()));
                } else {
                    throw new MediatorException("The Feature name is missing");
                }
                if (mp.getValue() != null) {
                    feature.addAttribute(fac.createOMAttribute("value", nullNS, mp.getValue()));
                } else {
                    throw new MediatorException("The Feature value is missing");
                }
            }
        }
        OMElement onFail = fac.createOMElement("on-fail", synNS, validate);
        serializeChildren(onFail, getList());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.