use of com.mulesoft.tools.migration.project.model.ApplicationModel in project mule-migration-assistant by mulesoft.
the class JmsOutboundEndpoint method migrateOutboundJmsEndpoint.
public static void migrateOutboundJmsEndpoint(Element object, MigrationReport report, Optional<Element> connector, String configName, ApplicationModel appModel) {
String destination = processAddress(object, report).map(address -> {
String path = address.getPath();
if ("topic".equals(path)) {
configureTopicPublisher(object);
return address.getPort();
} else {
return path;
}
}).orElseGet(() -> {
if (object.getAttributeValue("queue") != null) {
return object.getAttributeValue("queue");
} else {
configureTopicPublisher(object);
return object.getAttributeValue("topic");
}
});
report.report("jms.propertiesPublish", object, object);
Element outboundBuilder = new Element("message", JMS_NAMESPACE);
Attribute migrationReplyTo = object.getAttribute("reply-to", Namespace.getNamespace("migration", "migration"));
if (migrationReplyTo != null) {
if (migrationReplyTo.getValue().startsWith("TOPIC:")) {
outboundBuilder.addContent(new Element("reply-to", JMS_NAMESPACE).setAttribute("destination", migrationReplyTo.getValue()).setAttribute("destinationType", "TOPIC"));
} else {
outboundBuilder.addContent(new Element("reply-to", JMS_NAMESPACE).setAttribute("destination", migrationReplyTo.getValue()));
}
migrationReplyTo.detach();
} else {
outboundBuilder.addContent(new Element("reply-to", JMS_NAMESPACE).setAttribute("destination", "#[migration::JmsTransport::jmsPublishReplyTo(vars)]"));
}
outboundBuilder.addContent(compatibilityProperties(appModel));
outboundBuilder.setAttribute("correlationId", "#[migration::JmsTransport::jmsCorrelationId(correlationId, vars)]");
object.setAttribute("sendCorrelationId", "#[migration::JmsTransport::jmsSendCorrelationId(vars)]");
object.addContent(outboundBuilder);
connector.ifPresent(m3c -> {
if (m3c.getAttributeValue("persistentDelivery") != null) {
object.setAttribute("persistentDelivery", m3c.getAttributeValue("persistentDelivery"));
}
// This logic comes from JmsMessageDispatcher#dispatchMessage in Mule 3
if ("true".equals(m3c.getAttributeValue("honorQosHeaders"))) {
report.report("jms.inboundProperties", m3c, object);
String defaultDeliveryMode = "true".equals(m3c.getAttributeValue("persistentDelivery")) ? "2" : "1";
object.setAttribute("persistentDelivery", "#[(vars.compatibility_inboundProperties.JMSDeliveryMode default " + defaultDeliveryMode + ") == 2]");
object.setAttribute("priority", "#[vars.compatibility_inboundProperties.JMSPriority default 4]");
}
handleConnectorChildElements(m3c, appModel.getNode("*/*[namespace-uri()='" + JMS_NAMESPACE_URI + "' and local-name()='config' and @name='" + configName + "']"), new Element("connection", CORE_NAMESPACE), report);
});
if (object.getAttribute("responseTimeout") != null) {
object.addContent(new Element("consume-configuration", JMS_NAMESPACE).setAttribute("maximumWait", object.getAttributeValue("responseTimeout")));
}
object.removeAttribute("responseTimeout");
object.setAttribute("config-ref", configName);
if (destination != null) {
object.setAttribute("destination", destination);
}
object.removeAttribute("queue");
object.removeAttribute("topic");
object.removeAttribute("name");
object.removeAttribute("exchange-pattern");
}
use of com.mulesoft.tools.migration.project.model.ApplicationModel in project mule-migration-assistant by mulesoft.
the class MUnitNamespaces method execute.
@Override
public void execute(ApplicationModel applicationModel, MigrationReport report) throws RuntimeException {
try {
applicationModel.removeNameSpace(MUNIT_MOCK_NAME, MUNIT_MOCK_URI, MUNIT_MOCK_SCHEMA);
Namespace namespace = Namespace.getNamespace(MUNIT_TOOLS_NAME, MUNIT_TOOLS_URI);
applicationModel.getApplicationDocuments().values().stream().filter(d -> isMUnitFile(d)).forEach(e -> applicationModel.addNameSpace(namespace, MUNIT_TOOLS_SCHEMA, e));
} catch (Exception e) {
throw new MigrationStepException("Fail to apply step. " + e.getMessage(), e);
}
}
use of com.mulesoft.tools.migration.project.model.ApplicationModel in project mule-migration-assistant by mulesoft.
the class MigrationJob method execute.
@Override
public void execute(MigrationReport report) throws Exception {
ApplicationModel applicationModel = generateSourceApplicationModel(project);
report.initialize(applicationModel.getProjectType(), project.getFileName().toString());
Path sourceProjectBasePath = applicationModel.getProjectBasePath();
persistApplicationModel(applicationModel);
ProjectType targetProjectType = applicationModel.getProjectType().getTargetType();
applicationModel = generateTargetApplicationModel(outputProject, targetProjectType, sourceProjectBasePath, projectParentGAV, projectGAV);
try {
for (AbstractMigrationTask task : migrationTasks) {
if (task.getApplicableProjectTypes().contains(targetProjectType)) {
task.setApplicationModel(applicationModel);
task.setExpressionMigrator(new MelToDwExpressionMigrator(report, applicationModel));
try {
task.execute(report);
persistApplicationModel(applicationModel);
applicationModel = generateTargetApplicationModel(outputProject, targetProjectType, sourceProjectBasePath, projectParentGAV, projectGAV);
} catch (MigrationTaskException ex) {
if (cancelOnError) {
throw ex;
} else {
logger.error("Failed to apply task, rolling back and continuing with the next one.", ex);
}
} catch (RuntimeException e) {
throw new MigrationJobException("Failed to continue executing migration: " + e.getClass().getName() + ": " + e.getMessage(), e);
}
}
}
} finally {
generateReport(report, applicationModel);
}
}
use of com.mulesoft.tools.migration.project.model.ApplicationModel in project mule-migration-assistant by mulesoft.
the class SpringImportTest method setUp.
@Before
public void setUp() throws Exception {
ApplicationModel appModel = mock(ApplicationModel.class);
springImport = new SpringImport();
springImport.setApplicationModel(appModel);
File projectBaseFolder = temp.newFolder();
write(new File(projectBaseFolder, "import.xml"), "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<mule xmlns=\"http://www.mulesoft.org/schema/mule/core\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd\">\n" + "</mule>\n" + "", UTF_8);
when(appModel.getProjectBasePath()).thenReturn(projectBaseFolder.toPath());
}
use of com.mulesoft.tools.migration.project.model.ApplicationModel in project mule-migration-assistant by mulesoft.
the class MetadataTest method setUp.
@Before
public void setUp() throws Exception {
ApplicationModel appModel = mock(ApplicationModel.class);
setPayload = new SetPayload();
setPayload.setExpressionMigrator(new MelToDwExpressionMigrator(report.getReport(), appModel));
dwTransform = new EETransform();
dwTransform.setApplicationModel(appModel);
metadata = new RemoveMetadataAttributes();
}
Aggregations