use of org.apache.axiom.om.OMText in project wso2-synapse by wso2.
the class HessianMessageFormatter method extractSynapseBinaryDataSource.
/**
* Tries to extract the binary data source containing the Hessian message.
*
* @param omElement
*
* @return the binary data source containing the Hessian message or null, if the OMElement
* does not contain a binary datasource.
*/
private SynapseBinaryDataSource extractSynapseBinaryDataSource(OMElement omElement) {
SynapseBinaryDataSource synapseBinaryDataSource = null;
Iterator it = omElement.getChildren();
while (it.hasNext() && synapseBinaryDataSource == null) {
OMNode hessianElement = (OMNode) it.next();
if (hessianElement instanceof OMText) {
OMText tempNode = (OMText) hessianElement;
if (tempNode.getDataHandler() != null && ((DataHandler) tempNode.getDataHandler()).getDataSource() instanceof SynapseBinaryDataSource) {
synapseBinaryDataSource = (SynapseBinaryDataSource) ((DataHandler) tempNode.getDataHandler()).getDataSource();
}
}
}
return synapseBinaryDataSource;
}
use of org.apache.axiom.om.OMText in project wso2-synapse by wso2.
the class XFormURLEncodedBuilder method addRequestParameter.
private static void addRequestParameter(SOAPFactory soapFactory, OMElement bodyFirstChild, OMNamespace ns, String key, Object parameter) {
if (parameter instanceof DataHandler) {
DataHandler dataHandler = (DataHandler) parameter;
OMText dataText = bodyFirstChild.getOMFactory().createOMText(dataHandler, true);
soapFactory.createOMElement(key, ns, bodyFirstChild).addChild(dataText);
} else {
String textValue = parameter.toString();
soapFactory.createOMElement(key, ns, bodyFirstChild).setText(textValue);
}
}
use of org.apache.axiom.om.OMText in project wso2-synapse by wso2.
the class InboundEndpointFactory method createInboundEndpoint.
public static InboundEndpoint createInboundEndpoint(OMElement inboundEndpointElem, SynapseConfiguration config) {
InboundEndpoint inboundEndpoint = new InboundEndpoint();
if (inboundEndpointElem.getAttributeValue(ATT_NAME) != null) {
inboundEndpoint.setName(inboundEndpointElem.getAttributeValue(ATT_NAME));
} else {
String msg = "Inbound Endpoint name cannot be null";
log.error(msg);
throw new SynapseException(msg);
}
if (inboundEndpointElem.getAttributeValue(ATT_PROTOCOL) != null) {
inboundEndpoint.setProtocol(inboundEndpointElem.getAttributeValue(ATT_PROTOCOL));
}
if (inboundEndpointElem.getAttributeValue(ATT_ENDPOINT_CLASS) != null) {
inboundEndpoint.setClassImpl(inboundEndpointElem.getAttributeValue(ATT_ENDPOINT_CLASS));
}
if (inboundEndpointElem.getAttributeValue(ATT_ENDPOINT_SUSPEND) != null) {
inboundEndpoint.setSuspend(Boolean.parseBoolean(inboundEndpointElem.getAttributeValue(ATT_ENDPOINT_SUSPEND)));
} else {
inboundEndpoint.setSuspend(false);
}
if (inboundEndpointElem.getAttributeValue(ATT_SEQUENCE) != null) {
inboundEndpoint.setInjectingSeq(inboundEndpointElem.getAttributeValue(ATT_SEQUENCE));
}
if (inboundEndpointElem.getAttributeValue(ATT_ERROR_SEQUENCE) != null) {
inboundEndpoint.setOnErrorSeq(inboundEndpointElem.getAttributeValue(ATT_ERROR_SEQUENCE));
}
String nameString = inboundEndpoint.getName();
if (nameString == null || "".equals(nameString)) {
nameString = SynapseConstants.INBOUND_ENDPOINT_NAME;
}
AspectConfiguration aspectConfiguration = new AspectConfiguration(nameString);
inboundEndpoint.configure(aspectConfiguration);
OMAttribute statistics = inboundEndpointElem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.STATISTICS_ATTRIB_NAME));
if (statistics != null) {
String statisticsValue = statistics.getAttributeValue();
if (statisticsValue != null) {
if (XMLConfigConstants.STATISTICS_ENABLE.equals(statisticsValue)) {
aspectConfiguration.enableStatistics();
}
}
}
OMAttribute tracing = inboundEndpointElem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.TRACE_ATTRIB_NAME));
if (tracing != null) {
String tracingValue = tracing.getAttributeValue();
if (tracingValue != null) {
if (XMLConfigConstants.TRACE_ENABLE.equals(tracingValue)) {
aspectConfiguration.enableTracing();
}
}
}
// Set parameters
OMElement parametersElt = inboundEndpointElem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, InboundEndpointConstants.INBOUND_ENDPOINT_PARAMETERS));
if (parametersElt != null) {
Iterator parameters = parametersElt.getChildrenWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, InboundEndpointConstants.INBOUND_ENDPOINT_PARAMETER));
while (parameters.hasNext()) {
OMElement parameter = (OMElement) parameters.next();
String paramName = parameter.getAttributeValue(new QName(InboundEndpointConstants.INBOUND_ENDPOINT_PARAMETER_NAME));
String paramKey = parameter.getAttributeValue(new QName(InboundEndpointConstants.INBOUND_ENDPOINT_PARAMETER_KEY));
if (paramKey != null) {
Object obj = config.getEntry(paramKey);
if (obj == null) {
obj = config.getEntryDefinition(paramKey);
obj = config.getEntry(paramKey);
}
if (obj != null && obj instanceof OMTextImpl) {
OMText objText = (OMText) obj;
inboundEndpoint.addParameter(paramName, objText.getText(), paramKey);
} else {
String msg = "Error while deploying inbound endpoint " + inboundEndpoint.getName() + ".Registry entry defined with key: " + paramKey + " not found.";
log.error(msg);
throw new SynapseException(msg);
}
} else if (parameter.getFirstElement() != null) {
inboundEndpoint.addParameter(paramName, parameter.getFirstElement().toString());
} else {
inboundEndpoint.addParameter(paramName, parameter.getText());
}
}
}
inboundEndpoint.setFileName(inboundEndpointElem.getAttributeValue(new QName(InboundEndpointConstants.INBOUND_ENDPOINT_NAME)) + ".xml");
return inboundEndpoint;
}
use of org.apache.axiom.om.OMText in project wso2-synapse by wso2.
the class AbstractDBMediatorSerializer method createStatementElement.
private OMNode createStatementElement(Statement statement) {
OMElement stmntElt = fac.createOMElement(AbstractDBMediatorFactory.STMNT_Q.getLocalPart(), synNS);
OMElement sqlElt = fac.createOMElement(AbstractDBMediatorFactory.SQL_Q.getLocalPart(), synNS);
OMText sqlText = fac.createOMText(statement.getRawStatement(), XMLStreamConstants.CDATA);
sqlElt.addChild(sqlText);
stmntElt.addChild(sqlElt);
// serialize parameters of the statement
for (Statement.Parameter param : statement.getParameters()) {
OMElement paramElt = createStatementParamElement(param);
stmntElt.addChild(paramElt);
}
// serialize any optional results of the statement
for (String name : statement.getResultsMap().keySet()) {
String columnStr = statement.getResultsMap().get(name);
OMElement resultElt = fac.createOMElement(AbstractDBMediatorFactory.RESULT_Q.getLocalPart(), synNS);
resultElt.addAttribute(fac.createOMAttribute("name", nullNS, name));
resultElt.addAttribute(fac.createOMAttribute("column", nullNS, columnStr));
stmntElt.addChild(resultElt);
}
return stmntElt;
}
use of org.apache.axiom.om.OMText in project wso2-synapse by wso2.
the class AbstractDBMediator method fetchFromRegistry.
/**
* Fetch the registry resources pointed by registry path.
* @param config
* @param key
* @return Resource value
*/
private String fetchFromRegistry(SynapseConfiguration config, String key) {
Object obj = config.getEntry(key);
if (obj == null) {
config.getEntryDefinition(key);
obj = config.getEntry(key);
}
if (obj != null && obj instanceof OMTextImpl) {
OMText objText = (OMText) obj;
return objText.getText();
} else {
String msg = "Error DB Mediator datasource: " + dataSourceName + ".Registry entry defined with key: " + key + " not found.";
log.error(msg);
throw new SynapseException(msg);
}
}
Aggregations