use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.
the class Pop3InboundEndpoint method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
object.setName("listener-pop3");
object.setNamespace(EMAIL_NAMESPACE);
addMigrationAttributeToElement(object, new Attribute("isMessageSource", "true"));
addAttributesToInboundProperties(object, report);
Optional<Element> pop3Connector = resolveConnector(object, getApplicationModel());
getApplicationModel().addNameSpace(EMAIL_NAMESPACE.getPrefix(), EMAIL_NAMESPACE.getURI(), EMAIL_SCHEMA_LOC);
migrateSchedulingStrategy(object, OptionalInt.empty());
Element fixedFrequency = object.getChild("scheduling-strategy", CORE_NAMESPACE).getChild("fixed-frequency", CORE_NAMESPACE);
pop3Connector.ifPresent(c -> {
handleServiceOverrides(c, report);
migrateReconnection(c, object, report);
if (c.getAttribute("moveToFolder") != null) {
// TODO https://www.mulesoft.org/jira/browse/MULE-15721
report.report("email.moveToFolder", object, c);
}
if (c.getAttribute("mailboxFolder") != null) {
object.setAttribute("folder", c.getAttributeValue("mailboxFolder"));
}
if (c.getAttribute("backupEnabled") != null || c.getAttribute("backupFolder") != null) {
report.report("email.pop3Backup", object, object);
}
if (c.getAttribute("deleteReadMessages") != null) {
object.setAttribute("deleteAfterRetrieve", c.getAttributeValue("deleteReadMessages"));
}
if (c.getAttribute("defaultProcessMessageAction") != null) {
object.removeAttribute("defaultProcessMessageAction");
report.report("email.pop3DefaultProcessMessageAction", object, object);
}
if (c.getAttribute("checkFrequency") != null) {
fixedFrequency.setAttribute("frequency", c.getAttributeValue("checkFrequency"));
}
});
Element m4Config = migratePop3Config(object, report, pop3Connector);
Element connection = getConnection(m4Config);
if (pop3Connector.isPresent() && "gmail-connector".equals(pop3Connector.get().getName())) {
connection.setName("pop3s-connection");
connection.addContent(new Element("context", TLS_NAMESPACE).addContent(new Element("trust-store", TLS_NAMESPACE).setAttribute("insecure", "true")));
connection.setAttribute("host", "pop.gmail.com");
connection.setAttribute("port", "995");
object.removeAttribute("host");
object.removeAttribute("port");
getApplicationModel().addNameSpace(TLS_NAMESPACE.getPrefix(), TLS_NAMESPACE.getURI(), "http://www.mulesoft.org/schema/mule/tls/current/mule-tls.xsd");
report.report("email.gmail", pop3Connector.get(), connection);
} else {
processAddress(object, report).ifPresent(address -> {
connection.setAttribute("host", address.getHost());
connection.setAttribute("port", address.getPort());
if (address.getCredentials() != null) {
String[] credsSplit = address.getCredentials().split(":");
connection.setAttribute("user", credsSplit[0]);
connection.setAttribute("password", credsSplit[1]);
}
});
copyAttributeIfPresent(object, connection, "host");
copyAttributeIfPresent(object, connection, "port");
}
copyAttributeIfPresent(object, connection, "user");
copyAttributeIfPresent(object, connection, "password");
if (object.getAttribute("connector-ref") != null) {
object.getAttribute("connector-ref").setName("config-ref");
} else {
object.removeAttribute("name");
object.setAttribute("config-ref", m4Config.getAttributeValue("name"));
}
if (object.getAttribute("responseTimeout") != null) {
connection.setAttribute("readTimeout", object.getAttributeValue("responseTimeout"));
connection.setAttribute("writeTimeout", object.getAttributeValue("responseTimeout"));
connection.setAttribute("timeoutUnit", "MILLISECONDS");
object.removeAttribute("responseTimeout");
}
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.
the class NotFilter method negateValidator.
public Element negateValidator(Element validator, MigrationReport report, Element original) {
if ("is-true".equals(validator.getName())) {
validator.setName("is-false");
} else if ("is-false".equals(validator.getName())) {
validator.setName("is-true");
} else if ("matches-regex".equals(validator.getName())) {
Attribute regexAttr = validator.getAttribute("regex");
if (regexAttr.getValue().startsWith("(?!") && regexAttr.getValue().endsWith(")")) {
regexAttr.setValue(StringUtils.substring(regexAttr.getValue(), 3, -1));
} else {
regexAttr.setValue("(?!" + regexAttr.getValue() + ")");
}
} else if ("any".equals(validator.getName())) {
validator.setName("all");
validator.getChildren().forEach(c -> negateValidator(c, report, original));
} else if ("all".equals(validator.getName())) {
validator.setName("any");
validator.getChildren().forEach(c -> negateValidator(c, report, original));
} else {
report.report("filters.negated", original, validator);
}
return validator;
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.
the class EETransform method addSessionVariable.
private void addSessionVariable(Element element, MigrationReport report) {
addCompatibilityNamespace(element.getDocument());
Element sessionVar = new Element("set-session-variable", COMPATIBILITY_NAMESPACE);
Attribute varName = element.getAttribute("variableName");
sessionVar.setAttribute(new Attribute(varName.getName(), varName.getValue()));
sessionVar.setAttribute(new Attribute("value", "#[vars." + varName.getValue() + "]"));
addElementAfter(sessionVar, element.getParentElement());
report.report("transform.sessionVars", sessionVar, sessionVar);
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.
the class Poll method execute.
@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
try {
changeNodeName("", POLL_NEW_NAME).apply(element);
addMigrationAttributeToElement(element, new Attribute("isMessageSource", "true"));
List<Element> childElementsToMove = element.getChildren().stream().filter(s -> !StringUtils.equals(s.getName(), FIXED_FREQ_SCHEDULER) && !StringUtils.equals(s.getName(), CRON_FREQ_SCHEDULER) && !StringUtils.equals(s.getName(), WATERMARK)).collect(toList());
movePollChildsToParent(childElementsToMove, element.getParentElement(), element.getParentElement().indexOf(element) + 1);
if (element.getChild(FIXED_FREQ_SCHEDULER, CORE_NAMESPACE) == null && element.getChild(CRON_FREQ_SCHEDULER, SCHEDULERS_NAMESPACE) == null) {
Element schedulingStrategy = new Element("scheduling-strategy", element.getNamespace());
final Element fixedFrequency = new Element("fixed-frequency", element.getNamespace());
schedulingStrategy.addContent(fixedFrequency);
element.addContent(schedulingStrategy);
// support the `frequency` attribute that was deprecated in 3.5.0
final String newFrequency = changeDefault("1000", "60000", element.getAttributeValue("frequency"));
if (newFrequency != null) {
fixedFrequency.setAttribute("frequency", newFrequency);
}
element.removeAttribute("frequency");
} else {
updateCronScheduler(element);
updateFixedFrequencyScheduler(element);
}
if (element.getChild(WATERMARK, CORE_NAMESPACE) != null) {
Element watermark = element.getChild(WATERMARK, CORE_NAMESPACE);
Element osStore = new Element("store", NEW_OS_NAMESPACE);
Element osRetrieve = new Element("retrieve", NEW_OS_NAMESPACE);
addMigrationAttributeToElement(osStore, new Attribute("lastElement", "true"));
osStore.setAttribute("failIfPresent", "false");
osStore.setAttribute("failOnNullValue", "false");
if (watermark.getAttribute("variable") != null) {
osStore.setAttribute("key", watermark.getAttributeValue("variable"));
osRetrieve.setAttribute("key", watermark.getAttributeValue("variable"));
osRetrieve.setAttribute("target", watermark.getAttributeValue("variable"));
}
if (watermark.getAttribute("default-expression") != null) {
String defaultExpression = getExpressionMigrator().migrateExpression(watermark.getAttributeValue("default-expression"), true, element);
setOSValue(osRetrieve, defaultExpression, "default-value");
}
if (watermark.getAttribute("update-expression") != null) {
String updateExpression = getExpressionMigrator().migrateExpression(watermark.getAttributeValue("update-expression"), true, element);
setOSValue(osStore, updateExpression, "value");
} else if (watermark.getAttribute("selector-expression") != null || watermark.getAttribute("selector") != null) {
String selectorExpression = watermark.getAttributeValue("selector-expression");
String selector = watermark.getAttributeValue("selector");
if (selectorExpression == null) {
setOSValue(osStore, getExpressionFromSelector(selector), "value");
} else if (selector == null) {
selectorExpression = getExpressionMigrator().migrateExpression(selectorExpression, true, element);
setOSValue(osStore, selectorExpression, "value");
} else {
selectorExpression = watermarkSelectorMigrator.migrateSelector(selectorExpression, selector.toLowerCase(), element, report, getExpressionMigrator());
setOSValue(osStore, selectorExpression, "value");
}
}
if (watermark.getAttribute("object-store-ref") != null) {
osStore.setAttribute("objectStore", watermark.getAttributeValue("object-store-ref"));
osRetrieve.setAttribute("objectStore", watermark.getAttributeValue("object-store-ref"));
}
addElementAfter(osRetrieve, element);
addElementToBottom(getContainerElement(element), osStore);
watermark.detach();
addOSModule();
}
} catch (Exception ex) {
throw new MigrationStepException("Failed to migrate poll." + ex.getMessage() + ex.getStackTrace());
}
}
use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.
the class PropertyPlaceholder method execute.
@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
Attribute propsLocation = element.getAttribute("location");
if (propsLocation != null) {
Element configProperties = new Element("configuration-properties", CORE_NAMESPACE);
configProperties.setAttribute("file", propsLocation.getValue());
addTopLevelElement(configProperties, element.getDocument());
}
getApplicationModel().removeNameSpace(Namespace.getNamespace(SPRING_CONTEXT_NS_PREFIX, SPRING_CONTEXT_NS_URI), SPRING_CONTEXT_SCHEMA, element.getDocument());
element.detach();
}
Aggregations