Package org.wso2.carbon.mediator.service

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


      if (URLRewriteActions.TYPE_APPEND.equals(type) ||
          URLRewriteActions.TYPE_PREPEND.equals(type) ||
          URLRewriteActions.TYPE_SET.equals(type) ||
          URLRewriteActions.TYPE_REPLACE.equals(type)) {
        if (value == null && xpath == null) {
          throw new MediatorException("Set, Append, Prepend," + "Repalce actions need"
                                      + "value attribute/xpath" + "attribute need to be"
                                      + "specified");

        }
        if (xpath != null) {
          SynapseXPathSerializer.serializeXPath(xpath, actionElement, "xpath");
        }
        if (value != null) {
          actionElement.addAttribute(fac.createOMAttribute("value", nullNS, value));
        }

      }
      // 'regex' attribute must be specified
      if (URLRewriteActions.TYPE_REPLACE.equals(type)) {
        if (regex != null) {
          actionElement.addAttribute(fac.createOMAttribute("regex", nullNS,regex));
        } else {
          throw new MediatorException("Replace action needs " + "'regex'attribute to"
                                      + " be specified");
        }
      }
      if(type !=null){
        actionElement.addAttribute(fac.createOMAttribute("type", nullNS,type));
View Full Code Here


        if (beanName != null) {
            spring.addAttribute(fac.createOMAttribute(
                "bean", nullNS, beanName));
        } else {
            throw new MediatorException("Invalid mediator. Bean name required.");
        }
        saveTracingState(spring, this);

        if (configKey != null) {
            spring.addAttribute(fac.createOMAttribute(
View Full Code Here

    public void build(OMElement elem) {
        OMAttribute bean = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "bean"));
        OMAttribute key  = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key"));

        if (bean == null) {
            throw new MediatorException("The 'bean' attribute is required for a Spring mediator definition");
        } else if (key == null) {
            throw new MediatorException("A 'key' attribute is required for a Spring mediator definition");
        } else {

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

        OMElement   targetElt     = elem.getFirstChildWithName(Q_TARGET);

        if (attServiceURL != null) {
            serviceURL = attServiceURL.getAttributeValue();
        } else {
            throw new MediatorException("The 'serviceURL' attribute is required for the Callout mediator");
        }

        if (attAction != null) {
            action = attAction.getAttributeValue();
        }

        if (configElt != null) {

            OMAttribute axis2xmlAttr = configElt.getAttribute(ATT_AXIS2XML);
            OMAttribute repoAttr = configElt.getAttribute(ATT_REPOSITORY);

            if (axis2xmlAttr != null && axis2xmlAttr.getAttributeValue() != null) {
                axis2xml = axis2xmlAttr.getAttributeValue();
            }

            if (repoAttr != null && repoAttr.getAttributeValue() != null) {
                clientRepository = repoAttr.getAttributeValue();
            }
        }

        if (sourceElt != null) {
            if (sourceElt.getAttribute(ATT_XPATH) != null) {
                try {
                    requestXPath = SynapseXPathFactory.getSynapseXPath(sourceElt, ATT_XPATH);
                } catch (JaxenException e) {
                    throw new MediatorException("Invalid source XPath : "
                        + sourceElt.getAttributeValue(ATT_XPATH));
                }
            } else if (sourceElt.getAttribute(ATT_KEY) != null) {
                requestKey = sourceElt.getAttributeValue(ATT_KEY);
            } else {
                throw new MediatorException("A 'xpath' or 'key' attribute " +
                    "is required for the Callout 'source'");
            }
        } else {
            throw new MediatorException("The message 'source' must be specified for a Callout mediator");
        }

        if (targetElt != null) {
            if (targetElt.getAttribute(ATT_XPATH) != null) {
                try {
                    targetXPath = SynapseXPathFactory.getSynapseXPath(targetElt, ATT_XPATH);
                } catch (JaxenException e) {
                    throw new MediatorException("Invalid target XPath : "
                        + targetElt.getAttributeValue(ATT_XPATH));
                }
            } else if (targetElt.getAttribute(ATT_KEY) != null) {
                targetKey = targetElt.getAttributeValue(ATT_KEY);
            } else {
                throw new MediatorException("A 'xpath' or 'key' attribute " +
                    "is required for the Callout 'target'");
            }
        } else {
            throw new MediatorException("The message 'target' must be specified for a Callout mediator");
        }       
    }
View Full Code Here

        if (getSource() != null) {
            SynapseXPathSerializer.serializeXPath(getSource(), switchMed, "source");

        } else {
            throw new MediatorException("Invalid switch mediator. Source required");
        }


        serializeChildren(switchMed, getList());
View Full Code Here

        }

        OMAttribute source = elem.getAttribute(ATT_SOURCE);
        if (source == null) {
            String msg = "A 'source' XPath attribute is required for a switch mediator";
            throw new MediatorException(msg);
        } else {
            try {

                setSource(SynapseXPathFactory.getSynapseXPath(elem, ATT_SOURCE));

            } catch (JaxenException e) {
                String msg = "Invalid XPath for attribute 'source' : " + source.getAttributeValue();
                throw new MediatorException(msg);
            }
        }
        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processAuditStatus(this, elem);
View Full Code Here

                elsePresent = true;
            }
        }
        if (!thenPresent) {
            if (elsePresent) {
                throw new MediatorException("Else without Then, Invalid syntax.");
            }
            ThenMediator thenMediator = new ThenMediator();
            for (Mediator m : getList()) {
                thenMediator.addChild(m);
            }
View Full Code Here

        saveTracingState(caseElem, this);
        if (regex != null) {
            caseElem.addAttribute(fac.createOMAttribute(
                    "regex", nullNS, regex.pattern()));
        } else {
            throw new MediatorException("Invalid switch case. Regex required");
        }
        serializeChildren(caseElem, getList());

        if (parent != null) {
            parent.addChild(caseElem);
View Full Code Here

    public void build(OMElement elem) {
        this.regex = null;
        OMAttribute regex = elem.getAttribute(ATT_REGEX);
        if (regex == null) {
            String msg = "The 'regex' attribute is required for a switch case definition";
            throw new MediatorException(msg);
        }
        try {
            this.regex = Pattern.compile(regex.getAttributeValue());
        } catch (PatternSyntaxException pse) {
            String msg = "Invalid Regular Expression for attribute 'regex' : " + regex.getAttributeValue();
            throw new MediatorException(msg);
        }
        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processAuditStatus(this, elem);
        addChildren(elem, this);
View Full Code Here

            } else if ("TIME".equals(type)) {
                this.type = Types.TIME;
             } else if ("TIMESTAMP".equals(type)) {
                this.type = Types.TIMESTAMP;
            } else {
                throw new MediatorException("Unknown or unsupported JDBC type : " + type);
            }
        }
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.