use of org.apache.synapse.mediators.elementary.Source in project wso2-synapse by wso2.
the class CallMediatorSerializer method serializeSource.
private OMElement serializeSource(CallMediator mediator) {
Source source = mediator.getSourceForOutboundPayload();
String sourceContentType = mediator.getSourceMessageType();
OMElement sourceEle = fac.createOMElement("source", synNS);
sourceEle.addAttribute(fac.createOMAttribute("type", nullNS, intTypeToString(source.getSourceType())));
if (sourceContentType != null) {
sourceEle.addAttribute(fac.createOMAttribute("contentType", nullNS, sourceContentType));
}
if (source.getSourceType() == EnrichMediator.PROPERTY) {
sourceEle.setText(source.getProperty());
} else if (source.getSourceType() == EnrichMediator.CUSTOM) {
sourceEle.setText(source.getXpath().toString());
} else if (source.getSourceType() == EnrichMediator.INLINE) {
if (source.getInlineOMNode() instanceof OMElement) {
sourceEle.addChild(((OMElement) source.getInlineOMNode()).cloneOMElement());
} else if (source.getInlineOMNode() instanceof OMText) {
sourceEle.setText(((OMText) source.getInlineOMNode()).getText());
}
}
return sourceEle;
}
use of org.apache.synapse.mediators.elementary.Source in project wso2-synapse by wso2.
the class CallMediatorFactory method createSpecificMediator.
public Mediator createSpecificMediator(OMElement elem, Properties properties) {
CallMediator callMediator = new CallMediator();
// after successfully creating the mediator
// set its common attributes such as tracing etc
processAuditStatus(callMediator, elem);
OMElement sourceEle = elem.getFirstChildWithName(SOURCE_Q);
if (sourceEle != null) {
Source source = new Source();
populateSource(callMediator, source, sourceEle);
callMediator.setSourceForOutboundPayload(source);
}
OMElement targetEle = elem.getFirstChildWithName(TARGET_Q);
if (targetEle != null) {
Target target = new Target();
populateTarget(callMediator, target, targetEle);
callMediator.setTargetForInboundPayload(target);
}
OMElement epElement = elem.getFirstChildWithName(ENDPOINT_Q);
if (epElement != null) {
// create the endpoint and set it in the call mediator
Endpoint endpoint = EndpointFactory.getEndpointFromElement(epElement, true, properties);
if (endpoint != null) {
callMediator.setEndpoint(endpoint);
}
}
OMAttribute blockingAtt = elem.getAttribute(BLOCKING_Q);
if (blockingAtt != null) {
callMediator.setBlocking(Boolean.parseBoolean(blockingAtt.getAttributeValue()));
if (callMediator.isBlocking()) {
OMAttribute initAxis2ClientOptions = elem.getAttribute(ATT_INIT_AXIS2_CLIENT_OPTIONS);
OMAttribute axis2xmlAttr = elem.getAttribute(ATT_AXIS2XML);
OMAttribute repoAttr = elem.getAttribute(ATT_REPOSITORY);
if (initAxis2ClientOptions != null) {
callMediator.setInitClientOptions(Boolean.parseBoolean(initAxis2ClientOptions.getAttributeValue()));
}
if (axis2xmlAttr != null && axis2xmlAttr.getAttributeValue() != null) {
File axis2xml = new File(axis2xmlAttr.getAttributeValue());
if (axis2xml.exists() && axis2xml.isFile()) {
callMediator.setAxis2xml(axis2xmlAttr.getAttributeValue());
} else {
handleException("Invalid axis2.xml path: " + axis2xmlAttr.getAttributeValue());
}
}
if (repoAttr != null && repoAttr.getAttributeValue() != null) {
File repo = new File(repoAttr.getAttributeValue());
if (repo.exists() && repo.isDirectory()) {
callMediator.setClientRepository(repoAttr.getAttributeValue());
} else {
handleException("Invalid repository path: " + repoAttr.getAttributeValue());
}
}
}
}
addAllCommentChildrenToList(elem, callMediator.getCommentsList());
return callMediator;
}
use of org.apache.synapse.mediators.elementary.Source in project wso2-synapse by wso2.
the class CallMediatorEnrichUtil method createSourceWithBody.
public static Source createSourceWithBody() {
Source source = new Source();
source.setClone(false);
source.setSourceType(CallMediatorEnrichUtil.convertTypeToInt("body"));
return source;
}
Aggregations