use of com.mulesoft.tools.migration.step.util.XmlDslUtils.CORE_EE_NAMESPACE in project mule-migration-assistant by mulesoft.
the class JmsInboundEndpoint method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
jmsTransportLib(getApplicationModel());
addMigrationAttributeToElement(object, new Attribute("isMessageSource", "true"));
Element tx = object.getChild("transaction", JMS_NAMESPACE);
while (tx != null) {
String txAction = mapTransactionalAction(tx.getAttributeValue("action"), report, tx, object);
object.setAttribute("transactionalAction", txAction);
object.removeChild("transaction", JMS_NAMESPACE);
tx = object.getChild("transaction", JMS_NAMESPACE);
}
while (object.getChild("xa-transaction", CORE_NAMESPACE) != null) {
Element xaTx = object.getChild("xa-transaction", CORE_NAMESPACE);
String txAction = mapTransactionalAction(xaTx.getAttributeValue("action"), report, xaTx, object);
object.setAttribute("transactionalAction", txAction);
object.setAttribute("transactionType", "XA");
object.removeChild("xa-transaction", CORE_NAMESPACE);
}
while (object.getChild("multi-transaction", CORE_EE_NAMESPACE) != null) {
Element multiTx = object.getChild("multi-transaction", CORE_EE_NAMESPACE);
String txAction = mapTransactionalAction(multiTx.getAttributeValue("action"), report, multiTx, object);
object.setAttribute("transactionalAction", txAction);
object.removeChild("multi-transaction", CORE_EE_NAMESPACE);
}
getApplicationModel().addNameSpace(JMS_NAMESPACE, "http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd", object.getDocument());
object.setNamespace(JMS_NAMESPACE);
object.setName("listener");
Optional<Element> connector = resolveJmsConnector(object, getApplicationModel());
String configName = migrateJmsConfig(object, report, connector, getApplicationModel());
connector.ifPresent(m3c -> {
migrateReconnect(m3c, object, report, object);
if (m3c.getAttributeValue("acknowledgementMode") != null) {
switch(m3c.getAttributeValue("acknowledgementMode")) {
case "CLIENT_ACKNOWLEDGE":
object.setAttribute("ackMode", "MANUAL");
break;
case "DUPS_OK_ACKNOWLEDGE":
object.setAttribute("ackMode", "DUPS_OK");
break;
default:
}
}
if (m3c.getAttributeValue("numberOfConsumers") != null) {
object.setAttribute("numberOfConsumers", m3c.getAttributeValue("numberOfConsumers"));
}
handleConnectorChildElements(m3c, getApplicationModel().getNode("*/*[namespace-uri()='" + JMS_NAMESPACE_URI + "' and local-name()='config' and @name='" + configName + "']"), new Element("connection", CORE_NAMESPACE), report);
});
String destination = processAddress(object, report).map(address -> {
String path = address.getPath();
if ("topic".equals(path)) {
configureTopicListener(object, JMS_NAMESPACE, connector);
return address.getPort();
} else {
return path;
}
}).orElseGet(() -> {
if (object.getAttributeValue("queue") != null) {
return object.getAttributeValue("queue");
} else {
configureTopicListener(object, JMS_NAMESPACE, connector);
return object.getAttributeValue("topic");
}
});
if (object.getAttribute("exchange-pattern") == null || object.getAttributeValue("exchange-pattern").equals("request-response")) {
Element outboundBuilder = new Element("response", JMS_NAMESPACE);
outboundBuilder.addContent(compatibilityProperties(getApplicationModel()));
outboundBuilder.setAttribute("correlationId", "#[migration::JmsTransport::jmsCorrelationId(correlationId, vars)]");
report.report("jms.propertiesListener", object, object);
connector.ifPresent(m3c -> {
if (m3c.getAttributeValue("persistentDelivery") != null) {
outboundBuilder.setAttribute("persistentDelivery", m3c.getAttributeValue("persistentDelivery"));
}
});
object.addContent(outboundBuilder);
}
if (object.getChild("selector", JMS_NAMESPACE) != null) {
object.setAttribute("selector", object.getChild("selector", JMS_NAMESPACE).getAttributeValue("expression"));
object.removeChild("selector", JMS_NAMESPACE);
}
object.setAttribute("config-ref", configName);
if (destination != null) {
object.setAttribute("destination", destination);
}
object.removeAttribute("queue");
object.removeAttribute("topic");
object.removeAttribute("name");
object.removeAttribute("responseTimeout");
// TODO
object.removeAttribute("xaPollingTimeout");
if (object.getAttribute("exchange-pattern") == null || object.getAttributeValue("exchange-pattern").equals("request-response")) {
migrateInboundEndpointStructure(getApplicationModel(), object, report, true);
} else {
migrateInboundEndpointStructure(getApplicationModel(), object, report, false);
}
addAttributesToInboundProperties(object, getApplicationModel(), report);
}
use of com.mulesoft.tools.migration.step.util.XmlDslUtils.CORE_EE_NAMESPACE in project mule-migration-assistant by mulesoft.
the class VmInboundEndpoint method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
addMigrationAttributeToElement(object, new Attribute("isMessageSource", "true"));
Element tx = object.getChild("transaction", VM_NAMESPACE);
while (tx != null) {
String txAction = mapTransactionalAction(tx.getAttributeValue("action"), report, tx, object);
object.setAttribute("transactionalAction", txAction);
if (!"NONE".equals(txAction)) {
if (object.getChild("redelivery-policy", CORE_NAMESPACE) == null) {
object.addContent(new Element("redelivery-policy", CORE_NAMESPACE));
}
}
object.removeChild("transaction", VM_NAMESPACE);
tx = object.getChild("transaction", VM_NAMESPACE);
}
while (object.getChild("xa-transaction", CORE_NAMESPACE) != null) {
Element xaTx = object.getChild("xa-transaction", CORE_NAMESPACE);
String txAction = mapTransactionalAction(xaTx.getAttributeValue("action"), report, xaTx, object);
object.setAttribute("transactionalAction", txAction);
object.setAttribute("transactionType", "XA");
if (!"NONE".equals(txAction)) {
if (object.getChild("redelivery-policy", CORE_NAMESPACE) == null) {
object.addContent(new Element("redelivery-policy", CORE_NAMESPACE));
}
}
if ("true".equals(xaTx.getAttributeValue("interactWithExternal"))) {
report.report("vm.externalTx", xaTx, object);
}
object.removeChild("xa-transaction", CORE_NAMESPACE);
}
while (object.getChild("multi-transaction", CORE_EE_NAMESPACE) != null) {
Element multiTx = object.getChild("multi-transaction", CORE_EE_NAMESPACE);
String txAction = mapTransactionalAction(multiTx.getAttributeValue("action"), report, multiTx, object);
object.setAttribute("transactionalAction", txAction);
if (!"NONE".equals(txAction)) {
if (object.getChild("redelivery-policy", CORE_NAMESPACE) == null) {
object.addContent(new Element("redelivery-policy", CORE_NAMESPACE));
}
}
object.removeChild("multi-transaction", CORE_EE_NAMESPACE);
}
getApplicationModel().addNameSpace(VM_NAMESPACE, "http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd", object.getDocument());
object.setNamespace(VM_NAMESPACE);
object.setName("listener");
Optional<Element> connector = resolveVmConector(object, getApplicationModel());
String configName = getVmConfigName(object, connector);
Element vmConfig = migrateVmConfig(object, connector, configName, getApplicationModel());
String path = processAddress(object, report).map(address -> address.getPath()).orElseGet(() -> obtainPath(object));
addQueue(VM_NAMESPACE, connector, vmConfig, path);
connector.ifPresent(conn -> {
handleServiceOverrides(conn, report);
Integer consumers = null;
if (conn.getAttribute("numberOfConcurrentTransactedReceivers") != null) {
consumers = parseInt(conn.getAttributeValue("numberOfConcurrentTransactedReceivers"));
} else if (conn.getChild("receiver-threading-profile", CORE_NAMESPACE) != null && conn.getChild("receiver-threading-profile", CORE_NAMESPACE).getAttribute("maxThreadsActive") != null) {
consumers = parseInt(conn.getChild("receiver-threading-profile", CORE_NAMESPACE).getAttributeValue("maxThreadsActive"));
}
if (consumers != null) {
getContainerElement(object).setAttribute("maxConcurrency", "" + consumers);
object.setAttribute("numberOfConsumers", "" + consumers);
}
handleConnectorChildElements(conn, vmConfig, new Element("connection", CORE_NAMESPACE), report);
});
if (object.getAttribute("mimeType") != null) {
Element setMimeType = new Element("set-payload", CORE_NAMESPACE).setAttribute("value", "#[output " + object.getAttributeValue("mimeType") + " --- payload]");
addElementAfter(setMimeType, object);
object.removeAttribute("mimeType");
}
if (object.getAttribute("responseTimeout") != null) {
object.setAttribute("timeout", object.getAttributeValue("responseTimeout"));
object.setAttribute("timeoutUnit", "MILLISECONDS");
object.removeAttribute("responseTimeout");
}
object.setAttribute("config-ref", configName);
object.setAttribute("queueName", path);
object.removeAttribute("path");
object.removeAttribute("name");
object.removeAttribute("disableTransportTransformer");
Element content = buildContent(VM_NAMESPACE);
object.addContent(new Element("response", VM_NAMESPACE).addContent(content));
report.report("vm.sessionVars", content, content);
if (object.getAttribute("exchange-pattern") == null || object.getAttributeValue("exchange-pattern").equals("one-way")) {
migrateInboundEndpointStructure(getApplicationModel(), object, report, false, true);
} else {
migrateInboundEndpointStructure(getApplicationModel(), object, report, true, true);
}
}
Aggregations