Class Target
- java.lang.Object
-
- org.apache.synapse.mediators.elementary.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
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACTION_ADD_CHILD
static String
ACTION_ADD_SIBLING
static String
ACTION_REMOVE
static String
ACTION_REPLACE
static String
XPATH_PROPERTY_PATTERN
-
Constructor Summary
Constructors Constructor Description Target()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAction()
String
getProperty()
int
getTargetType()
SynapsePath
getXpath()
void
insert(MessageContext synContext, ArrayList<org.apache.axiom.om.OMNode> sourceNodeList, SynapseLog synLog)
void
insertJson(MessageContext synCtx, Object sourceJsonElement, SynapseLog synLog)
This method will insert a provided json element to a specified target.void
removeJsonFromBody(MessageContext synCtx, SynapsePath jsonPath)
This method will remove all the matching elements of the given jsonPath from the JSON payload in the msg context.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.void
renameKey(MessageContext synapseContext, String jsonPath, String keyName, String newKeyName)
Renames a json key name at the specified json path with a new key namevoid
setAction(String action)
void
setProperty(String property)
void
setProperty(String scope, MessageContext messageContext, Object documentElement)
Sets the property value in appropriate message contextvoid
setTargetType(int targetType)
void
setXpath(SynapsePath xpath)
-
-
-
Field Detail
-
ACTION_REMOVE
public static final String ACTION_REMOVE
- See Also:
- Constant Field Values
-
ACTION_REPLACE
public static final String ACTION_REPLACE
- See Also:
- Constant Field Values
-
ACTION_ADD_CHILD
public static final String ACTION_ADD_CHILD
- See Also:
- Constant Field Values
-
ACTION_ADD_SIBLING
public static final String ACTION_ADD_SIBLING
- See Also:
- Constant Field Values
-
XPATH_PROPERTY_PATTERN
public static final String XPATH_PROPERTY_PATTERN
- See Also:
- Constant Field Values
-
-
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 setmessageContext
- messageContext used in the mediationdocumentElement
- 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 contextjsonPath
- The path to locate the key. Should be resolved to a map or an array including map items.keyName
- Current name of the keynewKeyName
- New name of the key- Throws:
IOException
- if failed to set the new json payload
-
getXpath
public SynapsePath getXpath()
-
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)
-
-