Class Target


  • public class Target
    extends Object
    Inset an Axiom element to the current message. The target to insert the OMElement can be 1. A property 2. SOAP Body child element 3. SOAP envelope 4. A XPath expression to get the correct node

    In case the target is an SOAP Envelope, the current SOAP envelope will be replaced by the OMNode. So the OMNode must me a SOAPEnvelope.

    In case of Body the first child of the Body will be replaced by the new Node or a sibling will be added to it depending on the replace property.

    In case of Expression a SOAP Element will be chosen based on the XPath. If replace is true that element will be replaced, otherwise a sibling will be added to that element.

    Property case is simple. The OMNode will be stored in the given property

    • Constructor Detail

      • Target

        public Target()
    • Method Detail

      • insert

        public void insert​(MessageContext synContext,
                           ArrayList<org.apache.axiom.om.OMNode> sourceNodeList,
                           SynapseLog synLog)
                    throws org.jaxen.JaxenException
        Throws:
        org.jaxen.JaxenException
      • setProperty

        public void setProperty​(String scope,
                                MessageContext messageContext,
                                Object documentElement)
        Sets the property value in appropriate message context
        Parameters:
        scope - which property needs to set
        messageContext - messageContext used in the mediation
        documentElement - target element which needs to set as property
      • insertJson

        public void insertJson​(MessageContext synCtx,
                               Object sourceJsonElement,
                               SynapseLog synLog)
        This method will insert a provided json element to a specified target.
        Parameters:
        synCtx - Current Message Context.
        sourceJsonElement - Evaluated Json Element by the Source.
        synLog - Default Logger for the package.
      • removeJsonFromBody

        public void removeJsonFromBody​(MessageContext synCtx,
                                       SynapsePath jsonPath)
                                throws IOException,
                                       com.jayway.jsonpath.PathNotFoundException
        This method will remove all the matching elements of the given jsonPath from the JSON payload in the msg context.
        Parameters:
        synCtx - message context.
        jsonPath - JSON-path expression to select the removing element.
        Throws:
        IOException
        com.jayway.jsonpath.PathNotFoundException
      • removeJsonFromProperty

        public void removeJsonFromProperty​(MessageContext synCtx,
                                           String property,
                                           SynapsePath jsonPath)
        This method will remove all the matching elements of the given jsonPath from the JSON payload in the property and set the result back to the same property.
        Parameters:
        synCtx - message context.
        property - name of the property.
        jsonPath - JSON-path expression to select the removing element.
      • renameKey

        public void renameKey​(MessageContext synapseContext,
                              String jsonPath,
                              String keyName,
                              String newKeyName)
                       throws IOException
        Renames a json key name at the specified json path with a new key name
        Parameters:
        synapseContext - Current message context
        jsonPath - The path to locate the key. Should be resolved to a map or an array including map items.
        keyName - Current name of the key
        newKeyName - New name of the key
        Throws:
        IOException - if failed to set the new json payload
      • getProperty

        public String getProperty()
      • getTargetType

        public int getTargetType()
      • setXpath

        public void setXpath​(SynapsePath xpath)
      • setProperty

        public void setProperty​(String property)
      • setTargetType

        public void setTargetType​(int targetType)
      • getAction

        public String getAction()
      • setAction

        public void setAction​(String action)