use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.
the class ApikitRouterConfig method migrateFlowMappings.
private void migrateFlowMappings(Element config, MigrationReport report) {
final List<Element> flowMappings = config.getChildren().stream().filter(child -> APIKIT_NS_PREFIX.equals(child.getNamespacePrefix()) && FLOW_MAPPING_TAG_NAME.equals(child.getName())).collect(toList());
if (!flowMappings.isEmpty()) {
final Element flowMappingParent = getFlowMappingsParent(config);
flowMappings.forEach(flowMapping -> {
flowMapping.detach();
flowMapping.setNamespace(APIKIT_NAMESPACE);
flowMappingParent.addContent(flowMapping);
});
}
}
use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.
the class PreprocessNamespaces method addReportEntries.
public void addReportEntries(Document document, MigrationReport report, ApplicationModel applicationModel) {
List<Namespace> unsupportedNamespaces = document.getRootElement().getAdditionalNamespaces().stream().filter(n -> !getElementsWithNamespace(document, n, applicationModel).isEmpty() && !containsNamespace(n, applicationModel.getSupportedNamespaces())).collect(toList());
AtomicInteger processedElements = new AtomicInteger(0);
unsupportedNamespaces.forEach(ns -> {
// Ignore nested elements of the same pass to not distort statistics or clutter the report
applicationModel.getNodes("//*[namespace-uri() = '" + ns.getURI() + "' and namespace-uri(..) != '" + ns.getURI() + "']").forEach(node -> {
processedElements.incrementAndGet();
if (ns.getURI().startsWith("http://www.mulesoft.org")) {
report.report("components.unsupported", node, node, ns.getPrefix());
} else {
report.report("components.unknown", node, node, ns.getPrefix(), ns.getURI(), ADDITIONAL_SPRING_NAMESPACES_PROP);
}
report.addComponentFailure(node);
});
});
report.addProcessedElements(processedElements.get());
}
use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.
the class DbStoredProcedure method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
migrateSql(object);
migrateInputParamTypes(object);
migrateInputParams(object);
List<Element> outParams = object.getChildren("out-param", DB_NAMESPACE).stream().map(ip -> new Element("output-parameter", DB_NAMESPACE).setAttribute("key", ip.getAttributeValue("name"))).collect(toList());
if (!outParams.isEmpty()) {
object.addContent(new Element("output-parameters", DB_NAMESPACE).addContent(outParams));
}
object.removeChildren("out-param", DB_NAMESPACE);
List<Element> inoutParams = object.getChildren("inout-param", DB_NAMESPACE).stream().map(ip -> new Element("in-out-parameter", DB_NAMESPACE).setAttribute("key", ip.getAttributeValue("name")).setAttribute("value", ip.getAttributeValue("value"))).collect(toList());
if (!inoutParams.isEmpty()) {
object.addContent(new Element("in-out-parameters", DB_NAMESPACE).addContent(inoutParams));
}
object.removeChildren("inout-param", DB_NAMESPACE);
if (object.getAttribute("streaming") == null || "false".equals(object.getAttributeValue("streaming"))) {
report.report("db.streaming", object, object);
}
object.removeAttribute("streaming");
if (object.getAttribute("source") != null) {
report.report("db.source", object, object);
object.removeAttribute("source");
}
migrateOperationStructure(getApplicationModel(), object, report, false, getExpressionMigrator(), new DefaultMelCompatibilityResolver());
}
use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.
the class QuartzInboundEndpoint method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
if (object.removeAttribute("repeatCount")) {
report.report("quartz.repeatCount", object, object);
}
object.setName("scheduler");
object.setNamespace(CORE_NAMESPACE);
addMigrationAttributeToElement(object, new Attribute("isMessageSource", "true"));
String configName = object.getAttributeValue("connector-ref");
Optional<Element> config;
if (configName != null) {
config = getApplicationModel().getNodeOptional("/*/*[namespace-uri() = '" + QUARTZ_NS_URI + "' and local-name() = 'connector' and @name = '" + configName + "']");
} else {
config = getApplicationModel().getNodeOptional("/*/*[namespace-uri() = '" + QUARTZ_NS_URI + "' and local-name() = 'connector']");
}
config.ifPresent(cfg -> {
Element receiverThreadingProfile = cfg.getChild("receiver-threading-profile", CORE_NAMESPACE);
if (receiverThreadingProfile != null) {
if (receiverThreadingProfile.getAttribute("maxThreadsActive") != null) {
getContainerElement(object).setAttribute("maxConcurrency", receiverThreadingProfile.getAttributeValue("maxThreadsActive"));
}
}
});
Element schedulingStrategy = new Element("scheduling-strategy", CORE_NAMESPACE);
Element fixedFrequecy = null;
Element cron = null;
if (object.getAttribute("repeatInterval") != null) {
if (fixedFrequecy == null) {
fixedFrequecy = new Element("fixed-frequency", CORE_NAMESPACE);
schedulingStrategy.addContent(fixedFrequecy);
}
fixedFrequecy.setAttribute("frequency", object.getAttributeValue("repeatInterval"));
object.removeAttribute("repeatInterval");
}
if (object.getAttribute("startDelay") != null) {
if (fixedFrequecy == null) {
fixedFrequecy = new Element("fixed-frequency", CORE_NAMESPACE);
schedulingStrategy.addContent(fixedFrequecy);
}
fixedFrequecy.setAttribute("startDelay", object.getAttributeValue("startDelay"));
object.removeAttribute("startDelay");
}
if (object.getAttribute("cronExpression") != null) {
if (cron == null) {
cron = new Element("cron", CORE_NAMESPACE);
schedulingStrategy.addContent(cron);
}
cron.setAttribute("expression", object.getAttributeValue("cronExpression"));
object.removeAttribute("cronExpression");
}
if (object.getAttribute("cronTimeZone") != null) {
if (cron == null) {
cron = new Element("cron", CORE_NAMESPACE);
schedulingStrategy.addContent(cron);
}
cron.setAttribute("timeZone", object.getAttributeValue("cronTimeZone"));
object.removeAttribute("cronTimeZone");
}
Element eventGeneratorJob = object.getChild("event-generator-job", QUARTZ_NS);
if (eventGeneratorJob != null) {
String payload = eventGeneratorJob.getChildText("payload", QUARTZ_NS);
if (payload != null) {
addElementAfter(new Element("set-payload", CORE_NAMESPACE).setAttribute("value", payload), object);
}
}
Element endpointPollingJob = object.getChild("endpoint-polling-job", QUARTZ_NS);
if (endpointPollingJob != null) {
Element jobEndpoint = endpointPollingJob.getChild("job-endpoint", QUARTZ_NS);
addMigrationAttributeToElement(jobEndpoint, new Attribute("isPolledConsumer", "true"));
if (JobEndpointMigrableConnector.JMS.equals(resolveEndpointConnector(jobEndpoint))) {
handleGlobalEndpointsRefs(jobEndpoint);
final Optional<Element> jobEndpointConnector = resolveJmsConnector(jobEndpoint, getApplicationModel());
jobEndpointConnector.ifPresent(c -> jobEndpoint.setAttribute("connector-ref", c.getAttributeValue("name")));
getApplicationModel().addNameSpace(JMS_NAMESPACE, "http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd", object.getDocument());
jobEndpoint.setNamespace(JMS_NAMESPACE);
jobEndpoint.setName("consume");
String jmsConfig = migrateJmsConfig(jobEndpoint, report, jobEndpointConnector, getApplicationModel());
migrateOutboundJmsEndpoint(jobEndpoint, report, jobEndpointConnector, jmsConfig, getApplicationModel());
jobEndpoint.detach();
addElementAfter(jobEndpoint, object);
if (object.getAttribute("timeout") != null) {
jobEndpoint.addContent(new Element("consume-configuration", JMS_NAMESPACE).setAttribute("maximumWait", object.getAttributeValue("timeout")));
}
migrateOutboundEndpointStructure(getApplicationModel(), jobEndpoint, report, true);
extractInboundChildren(jobEndpoint, jobEndpoint.getParentElement().indexOf(jobEndpoint) + 2, jobEndpoint.getParentElement(), getApplicationModel());
addAttributesToInboundProperties(jobEndpoint, getApplicationModel(), report);
object.addContent(schedulingStrategy);
} else if (JobEndpointMigrableConnector.VM.equals(resolveEndpointConnector(jobEndpoint))) {
handleGlobalEndpointsRefs(jobEndpoint);
final Optional<Element> jobEndpointConnector = resolveVmConector(jobEndpoint, getApplicationModel());
jobEndpointConnector.ifPresent(c -> jobEndpoint.setAttribute("connector-ref", c.getAttributeValue("name")));
getApplicationModel().addNameSpace(VM_NAMESPACE, "http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd", object.getDocument());
jobEndpoint.setNamespace(VM_NAMESPACE);
jobEndpoint.setName("consume");
final String vmConfigName = getVmConfigName(object, jobEndpointConnector);
Element vmConfig = migrateVmConfig(object, jobEndpointConnector, vmConfigName, getApplicationModel());
migrateVmEndpointConsumer(jobEndpoint, report, jobEndpointConnector, vmConfigName, vmConfig);
jobEndpoint.detach();
addElementAfter(jobEndpoint, object);
if (object.getAttribute("timeout") != null) {
jobEndpoint.setAttribute("timeout", object.getAttributeValue("timeout"));
jobEndpoint.setAttribute("timeoutUnit", "MILLISECONDS");
object.removeAttribute("timeout");
}
migrateOutboundEndpointStructure(getApplicationModel(), jobEndpoint, report, true, true);
extractInboundChildren(jobEndpoint, jobEndpoint.getParentElement().indexOf(jobEndpoint) + 2, jobEndpoint.getParentElement(), getApplicationModel());
object.addContent(schedulingStrategy);
} else if (JobEndpointMigrableConnector.POLLING.equals(resolveEndpointConnector(jobEndpoint))) {
// This handles a Mule 4 connector source that is a polling source
jobEndpoint.setName("inbound-endpoint");
jobEndpoint.setNamespace(CORE_NAMESPACE);
jobEndpoint.detach();
addElementBefore(jobEndpoint, object);
jobEndpoint.addContent(schedulingStrategy);
object.detach();
} else {
object.addContent(schedulingStrategy);
report.report("quartz.unsupportedSource", jobEndpoint, object);
}
} else {
object.addContent(schedulingStrategy);
}
object.removeAttribute("connector-ref");
object.removeAttribute("name");
object.removeAttribute("jobName");
object.removeContent(new ElementFilter(QUARTZ_NS));
}
use of com.mulesoft.tools.migration.step.category.MigrationReport in project mule-migration-assistant by mulesoft.
the class OAuth2ProviderConfig method migrateTokenConfig.
private void migrateTokenConfig(Element element, MigrationReport report) {
final Element tokenConfig = new Element("token-config", OAUTH2_PROVIDER_NAMESPACE);
final String path = element.getAttributeValue("accessTokenEndpointPath");
if (path != null) {
tokenConfig.setAttribute("path", path.startsWith("/") ? path : "/" + path);
element.removeAttribute("accessTokenEndpointPath");
}
AtomicReference<Element> refreshTokens = new AtomicReference<>();
if ("true".equals(element.getAttributeValue("enableRefreshToken"))) {
if ("true".equals(element.getAttributeValue("issueNewRefreshToken"))) {
refreshTokens.set(new Element("multiple-refresh-tokens", OAUTH2_PROVIDER_NAMESPACE));
} else {
refreshTokens.set(new Element("single-refresh-tokens", OAUTH2_PROVIDER_NAMESPACE));
}
element.removeAttribute("issueNewRefreshToken");
tokenConfig.addContent(new Element("refresh-token-strategy", OAUTH2_PROVIDER_NAMESPACE).addContent(refreshTokens.get()));
if (element.getAttributeValue("refreshTokenTtlSeconds") != null) {
report.report("oauth2Provider.refreshTokenTtl", element, tokenConfig);
element.removeAttribute("refreshTokenTtlSeconds");
}
}
element.removeAttribute("enableRefreshToken");
getApplicationModel().getNodeOptional("//*[namespace-uri() = '" + SPRING_BEANS_NS_URI + "' and local-name() = 'bean' and @name='" + element.getAttributeValue("tokenStore-ref") + "']").ifPresent(b -> {
tokenConfig.setAttribute("tokenStore", b.getAttributes().stream().filter(att -> "accessTokenObjectStore-ref".equals(att.getName())).map(att -> att.getValue()).findFirst().get());
if (refreshTokens.get() != null) {
refreshTokens.get().setAttribute("objectStore", b.getAttributes().stream().filter(att -> "refreshTokenObjectStore-ref".equals(att.getName())).map(att -> att.getValue()).findFirst().get());
}
});
if (element.getAttributeValue("tokenStore-ref") != null) {
element.removeAttribute("tokenStore-ref");
if (element.getAttributeValue("tokenTtlSeconds") != null) {
report.report("oauth2Provider.tokenTtl", element, tokenConfig);
element.removeAttribute("tokenTtlSeconds");
}
}
element.addContent(tokenConfig);
}
Aggregations