use of com.mulesoft.tools.migration.library.mule.steps.http.HttpsInboundEndpoint in project mule-migration-assistant by mulesoft.
the class InboundEndpoint method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
object.getChildren("property", CORE_NAMESPACE).forEach(p -> {
object.setAttribute(p.getAttributeValue("key"), p.getAttributeValue("value"));
});
object.removeChildren("property", CORE_NAMESPACE);
addMigrationAttributeToElement(object, new Attribute("isMessageSource", "true"));
AbstractApplicationModelMigrationStep migrator = null;
if (object.getAttribute("address") != null) {
String address = object.getAttributeValue("address");
// TODO MMT-132 make available migrators discoverable
if (address.startsWith("file://")) {
migrator = new FileInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FILE_NS_PREFIX, FILE_NS_URI));
} else if (address.startsWith("ftp://")) {
migrator = new FtpEeInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FTP_NS_PREFIX, FTP_NS_URI));
} else if (address.startsWith("sftp://")) {
migrator = new SftpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(SFTP_NS_PREFIX, SFTP_NS_URI));
} else if (address.startsWith("http://")) {
migrator = new HttpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(HTTP_NS_PREFIX, HTTP_NS_URI));
} else if (address.startsWith("https://")) {
migrator = new HttpsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("https", "http://www.mulesoft.org/schema/mule/https"));
} else if (address.startsWith("imap://")) {
migrator = new ImapInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imap", "http://www.mulesoft.org/schema/mule/imap"));
} else if (address.startsWith("imaps://")) {
migrator = new ImapsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imaps", "http://www.mulesoft.org/schema/mule/imaps"));
} else if (address.startsWith("pop3://")) {
migrator = new Pop3InboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3", "http://www.mulesoft.org/schema/mule/pop3"));
} else if (address.startsWith("pop3s://")) {
migrator = new Pop3sInboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3s", "http://www.mulesoft.org/schema/mule/pop3s"));
} else if (address.startsWith("jms://")) {
migrator = new JmsInboundEndpoint();
object.setNamespace(Namespace.getNamespace(JMS_NS_PREFIX, JMS_NS_URI));
} else if (address.startsWith("vm://")) {
migrator = new VmInboundEndpoint();
object.setNamespace(Namespace.getNamespace(VM_NS_PREFIX, VM_NS_URI));
}
if (migrator != null) {
migrator.setApplicationModel(getApplicationModel());
if (migrator instanceof ExpressionMigratorAware) {
((ExpressionMigratorAware) migrator).setExpressionMigrator(getExpressionMigrator());
}
migrator.execute(object, report);
}
object.removeAttribute("address");
} else if (object.getAttribute("ref") != null) {
Element globalEndpoint = getApplicationModel().getNode("/*/*[@name = '" + object.getAttributeValue("ref") + "']");
// TODO MMT-132 make available migrators discoverable
if (globalEndpoint.getAttribute("address") != null) {
String address = globalEndpoint.getAttributeValue("address");
if (address.startsWith("file://")) {
migrator = new FileInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FILE_NS_PREFIX, FILE_NS_URI));
} else if (address.startsWith("ftp://")) {
migrator = new FtpEeInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FTP_NS_PREFIX, FTP_NS_URI));
} else if (address.startsWith("sftp://")) {
migrator = new SftpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(SFTP_NS_PREFIX, SFTP_NS_URI));
} else if (address.startsWith("http://")) {
migrator = new HttpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(HTTP_NS_PREFIX, HTTP_NS_URI));
} else if (address.startsWith("https://")) {
migrator = new HttpsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("https", "http://www.mulesoft.org/schema/mule/https"));
} else if (address.startsWith("imap://")) {
migrator = new ImapInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imap", "http://www.mulesoft.org/schema/mule/imap"));
} else if (address.startsWith("imaps://")) {
migrator = new ImapsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imaps", "http://www.mulesoft.org/schema/mule/imaps"));
} else if (address.startsWith("pop3://")) {
migrator = new Pop3InboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3", "http://www.mulesoft.org/schema/mule/pop3"));
} else if (address.startsWith("pop3s://")) {
migrator = new Pop3sInboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3s", "http://www.mulesoft.org/schema/mule/pop3s"));
} else if (address.startsWith("jms://")) {
migrator = new JmsInboundEndpoint();
object.setNamespace(Namespace.getNamespace(JMS_NS_PREFIX, JMS_NS_URI));
} else if (address.startsWith("vm://")) {
migrator = new VmInboundEndpoint();
object.setNamespace(Namespace.getNamespace(VM_NS_PREFIX, VM_NS_URI));
}
if (migrator != null) {
migrator.setApplicationModel(getApplicationModel());
if (migrator instanceof ExpressionMigratorAware) {
((ExpressionMigratorAware) migrator).setExpressionMigrator(getExpressionMigrator());
}
for (Attribute attribute : globalEndpoint.getAttributes()) {
if (object.getAttribute(attribute.getName()) == null) {
object.setAttribute(attribute.getName(), attribute.getValue());
}
}
migrator.execute(object, report);
}
}
}
if (object.getAttribute("exchange-pattern") != null) {
object.removeAttribute("exchange-pattern");
}
}
Aggregations