Package org.apache.synapse.util.xpath

Examples of org.apache.synapse.util.xpath.SynapseXPath


        if (attKey != null) {
            String attributeValue = attKey.getAttributeValue();
            boolean hasEscape = isEscapedExpression(attributeValue);
            if (!hasEscape && isDynamicKey(attributeValue)) {
                /** dynamic key */
                SynapseXPath synXpath = createSynXpath(elem, attributeValue);
                key = new Value(synXpath);
            } else if (hasEscape) {
                /** escaped expr */
                key = new Value(getEscapedExpression(attributeValue));
                key.setNamespaces(elem);
View Full Code Here


     */
    public SynapseXPath createSynXpath(OMElement elem, String key) {
        //derive XPath Expression from key
        String xpathExpr = key.trim().substring(1, key.length() - 1);

        SynapseXPath synapseXPath = null;

        try {
            synapseXPath = SynapseXPathFactory.getSynapseXPath(elem, xpathExpr);
        } catch (JaxenException e) {
            handleException("Can not create Synapse Xpath from given key");
View Full Code Here

    public BaseXPath createXPath(String xpath, Collection<OMNamespace> omNameSpaces) {
        if (xpath == null || "".equals(xpath)) {
            throw new LoggedRuntimeException("XPath expression is null or empty", log);
        }
        try {
            SynapseXPath synapseXPath = new SynapseXPath(xpath);
            for (OMNamespace omNamespace : omNameSpaces) {
                if (omNamespace != null) {
                    synapseXPath.addNamespace(omNamespace.getPrefix(), omNamespace.getNamespaceURI());
                }
            }
            return synapseXPath;
        } catch (JaxenException e) {
            throw new LoggedRuntimeException("Invalid XPapth expression : " +
View Full Code Here

                SendMediator send = new SendMediator();
                LoadbalanceEndpoint lb = new LoadbalanceEndpoint();

                FilterMediator filterMediator = new FilterMediator();
                in.addChild(filterMediator);
                SynapseXPath xpath = new SynapseXPath("get-property('To')");
                filterMediator.setSource(xpath);
                filterMediator.setRegex(Pattern.compile("/carbon"));

                PropertyMediator httpSCProperty = new PropertyMediator();
                httpSCProperty.setName("HTTP_SC");
View Full Code Here

    private SynapseXPath getXPath(OMElement subjectElement,
                                  QName childAttribName, boolean isMandatoryAttr) {

        OMAttribute credentialAttr = subjectElement.getAttribute(
                new QName(childAttribName.getLocalPart()));
        SynapseXPath xpath = null;
        if (null == credentialAttr && isMandatoryAttr) {
            handleException(String.format("Attribute %s is mandatory as an input",
                                          childAttribName.getLocalPart()));
        }
View Full Code Here

     */
    public String evaluate(MessageContext synCtx, String credentialElemName) {
        String sourceObject = null;
        // expression is required to perform the match
        if (credentialTokensMap.containsKey(credentialElemName)) {
            SynapseXPath xpath = credentialTokensMap.get(credentialElemName);
            sourceObject = xpath.stringValueOf(synCtx);
            if (null == sourceObject) {
                log.debug(String.format("Source String : %s evaluates to null",
                                        xpath.toString()));
            }
        } else if (credentialTokenValueMap.containsKey(credentialElemName)) {
            sourceObject = credentialTokenValueMap.get(credentialElemName);
        }
        return sourceObject;
View Full Code Here

    private SynapseXPath getXPath(OMElement requestCredentialElement,
                                  QName childElementName, boolean isMandatoryElement) {

        OMElement credentialElem = requestCredentialElement
                .getFirstChildWithName(childElementName);
        SynapseXPath xpath = null;
        if (null == credentialElem && isMandatoryElement) {
            handleException(String.format("Credential element %s is mandatory",
                                          childElementName.getLocalPart()));
        }
        if (null != credentialElem) {
View Full Code Here

    private SynapseXPath getXPath(OMElement subjectElement,
                                  QName childAttribName, boolean isMandatoryAttr) {

        OMAttribute credentialAttr = subjectElement.getAttribute(
                new QName(childAttribName.getLocalPart()));
        SynapseXPath xpath = null;
        if (null == credentialAttr && isMandatoryAttr) {
            handleException(String.format("Attribute %s is mandatory as an input",
                                          childAttribName.getLocalPart()));
        }
View Full Code Here

  private SynapseXPath getXPath(OMElement requestCredentialElement,
      QName childElementName, boolean isMandatoryElement) {

    OMElement credentialElem = requestCredentialElement
        .getFirstChildWithName(childElementName);
    SynapseXPath xpath = null;
    if (null == credentialElem && isMandatoryElement) {
      handleException(String.format("Credential element %s is mandatory",
          childElementName.getLocalPart()));
    }
    if (null != credentialElem) {
View Full Code Here

    public static void validateInputProperties(Input input, Input testInput) {
        Assert.assertEquals(testInput.getName(), input.getName());
        Assert.assertEquals(testInput.isRequired(), input.isRequired());
        if (testInput.getSourceXPath() != null && input.getSourceXPath() != null) {
            SynapseXPath inputXpath = input.getSourceXPath();
            SynapseXPath testXpath = testInput.getSourceXPath();
            validateXpathExpressions(inputXpath, testXpath);
        } else {
            Assert.assertEquals(testInput.getSourceXPath(), input.getSourceXPath());
        }
        Assert.assertEquals(testInput.getSourceValue(), input.getSourceValue());
View Full Code Here

TOP

Related Classes of org.apache.synapse.util.xpath.SynapseXPath

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.