Package org.wso2.carbon.mediator.service

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


            MediatorProperty prop = new MediatorProperty();

            if (attName == null || attName.getAttributeValue() == null ||
                attName.getAttributeValue().trim().length() == 0) {
                String msg = "Entry name is a required attribute for a Log property";
                throw new MediatorException(msg);
            } else {
                prop.setName(attName.getAttributeValue());
            }

            // if a value is specified, use it, else look for an expression
            if (attValue != null) {

                if (attValue.getAttributeValue() == null ||
                    attValue.getAttributeValue().trim().length() == 0) {

                    String msg = "Entry attribute value (if specified) " +
                        "is required for a Log property";
                    throw new MediatorException(msg);

                } else {
                    prop.setValue(attValue.getAttributeValue());
                }

            } else if (attExpr != null) {

                if (attExpr.getAttributeValue() == null ||
                    attExpr.getAttributeValue().trim().length() == 0) {

                    String msg = "Entry attribute expression (if specified) " +
                        "is required for a mediator property";
                    throw new MediatorException(msg);

                } else {
                    try {
                        prop.setExpression(SynapseXPathFactory.getSynapseXPath(
                            propEle, MediatorProperty.ATT_EXPR_Q));

                    } catch (JaxenException e) {
                        String msg = "Invalid XPapth expression : " + attExpr.getAttributeValue();
                        throw new MediatorException(msg);
                    }
                }

            } else {
                String msg = "Entry attribute value OR expression must " +
                    "be specified for a mediator property";
                throw new MediatorException(msg);
            }

            propertyList.add(prop);
        }
View Full Code Here


            OMAttribute attValue = child.getAttribute(ATT_VALUE);
            if (attName != null && attValue != null) {
                String name = attName.getAttributeValue().trim();
                String value = attValue.getAttributeValue().trim();
                if (result.containsKey(name)) {
                    throw new MediatorException("Duplicate " + childElementName.getLocalPart()
                            + " with name " + name);
                } else {
                    result.put(name, value);
                }
            } else {
                throw new MediatorException("Both of the name and value attributes are required for a "
                        + childElementName.getLocalPart());
            }
        }
        return result;
    }
View Full Code Here

        if (remoteServiceUrl != null) {
            entitlementService.addAttribute(fac.createOMAttribute("remoteServiceUrl", nullNS,
                    remoteServiceUrl));
        } else {
            throw new MediatorException(
                    "Invalid Entitlement mediator.Entitlement service epr required");
        }

        if (remoteServiceUserName != null) {
            entitlementService.addAttribute(fac.createOMAttribute("remoteServiceUserName", nullNS,
                    remoteServiceUserName));
        } else {
            throw new MediatorException(
                    "Invalid Entitlement mediator. Remote service user name required");
        }

        if (remoteServicePassword != null) {
            entitlementService.addAttribute(fac.createOMAttribute("remoteServicePassword", nullNS,
                    remoteServicePassword));
        } else {
            throw new MediatorException(
                    "Invalid Entitlement mediator. Remote service password required");
        }

        saveTracingState(entitlementService, this);
View Full Code Here

        OMAttribute attRemoteServicePassword = elem.getAttribute(PROP_NAME_PASSWORD);

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

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

        if (attRemoteServicePassword != null) {
            remoteServicePassword = attRemoteServicePassword.getAttributeValue();
        } else {
            throw new MediatorException(
                    "The 'remoteServicePassword' attribute is required for the Entitlement mediator");
        }
    }
View Full Code Here

        if (valueAttr == null && xpathAttr == null) {
          String msg =
                       "The 'value'/'xpath' attribute is required for "
                               + "the configuration for the 'set'/'append'"
                               + "/'prepend' or repalce action";
          throw new MediatorException(msg);
        }

        if (valueAttr != null && valueAttr.getAttributeValue() != null) {
          urlRewriteActions.setValue(valueAttr.getAttributeValue());
        }
        if (xpathAttr != null && xpathAttr.getAttributeValue() != null) {
          try {
            urlRewriteActions.setXpath(SynapseXPathFactory.getSynapseXPath(actionEle,
                                                                           ATT_XPATH));

          } catch (JaxenException e) {
            throw new MediatorException("Could not construct the" + " xpath");
          }
        }
      }

      if ("replace".equals(typeAttr.getAttributeValue())) {
        if (regexAttr == null) {
          String msg =
                       "The 'regex' attribute is required for the "
                               + "configuration for the 'replace' action";
          throw new MediatorException(msg);
        }
        urlRewriteActions.setRegex(regexAttr.getAttributeValue());
      }
      if (typeAttr.getAttributeValue() != null) {
        urlRewriteActions.setAction(typeAttr.getAttributeValue());
      }

      if (fragmentAttr != null) {
        urlRewriteActions.setFragment(fragmentAttr.getAttributeValue());
      }

      // if a value is specified, use it, else look for an expression
      if (valueAttr != null) {
        urlRewriteActions.setValue(valueAttr.getAttributeValue());
      } else if (xpathAttr != null) {
        try {
          urlRewriteActions.setXpath(SynapseXPathFactory.getSynapseXPath(actionEle,
                                                                         XPATH_Q));

        } catch (JaxenException e) {
          String msg = "Invalid XPapth expression : " + xpathAttr.getAttributeValue();
          throw new MediatorException(msg);
        }
      }
      actionList.add(urlRewriteActions);
    }
    return actionList;
View Full Code Here

        processAuditStatus(this, elem);

        OMAttribute msName = elem.getAttribute(ATT_MESSAGE_STORE_Q);
        if(msName == null) {
            String msg = "Name of the Message Store name is a required attribute";
            throw new MediatorException(msg);
        }

        this.messageStoreName = msName.getAttributeValue();

        OMAttribute sqName = elem.getAttribute(ATT_SEQUENCE_Q);
View Full Code Here

                "language"));
        OMAttribute funcAtt = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE,
                "function"));

        if (langAtt == null) {
            throw new MediatorException("The 'language' attribute is required for" +
                    " a script mediator");           
        }
        if (keyAtt == null && funcAtt != null) {
            throw new MediatorException("Cannot use 'function' attribute without 'key' " +
                    "attribute for a script mediator");
        }

        getIncludeKeysMap(elem);
View Full Code Here

            OMElement includeElem = (OMElement) iter.next();
            OMAttribute key = includeElem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE,
                    "key"));

            if (key == null) {
                throw new MediatorException("Cannot use 'include' element without 'key'" +
                        " attribute for a script mediator");
            }

            String keyText = key.getAttributeValue();
            includes.put(keyText, null);
View Full Code Here

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

        if (action == null) {
            throw new MediatorException("The 'action' attribute " +
                    "is required for Transaction mediator definition");
        } else {

            // after successfully creating the mediator
            // set its common attributes such as tracing etc
View Full Code Here

            if (key != null) {
                String keyValue = key.getAttributeValue();
                if (keyValue != null && !"".equals(keyValue)) {
                    policyKey = keyValue;
                } else {
                    throw new MediatorException("key attribute should have a value ");
                }
            } else {
                OMElement inLine = policy.getFirstElement();
                if (inLine != null) {
                    inLinePolicy = inLine;
                }
            }
        }
        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processAuditStatus(this, elem);

        String id = elem.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "id"));
        if (id != null && !"".equals(id)) {
            this.id = id.trim();
        } else {
           throw new MediatorException("Idy attribute must have defined ");
        }

        OMAttribute onReject = elem.getAttribute(
                new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.ONREJECT));
        if (onReject != null) {
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.