Search in sources :

Example 16 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute 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);
}
Also used : XmlDslUtils.addMigrationAttributeToElement(com.mulesoft.tools.migration.step.util.XmlDslUtils.addMigrationAttributeToElement) CORE_EE_NAMESPACE(com.mulesoft.tools.migration.step.util.XmlDslUtils.CORE_EE_NAMESPACE) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) TransportsUtils.processAddress(com.mulesoft.tools.migration.step.util.TransportsUtils.processAddress) Attribute(org.jdom2.Attribute) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) TransportsUtils.handleConnectorChildElements(com.mulesoft.tools.migration.step.util.TransportsUtils.handleConnectorChildElements) TransportsUtils.migrateInboundEndpointStructure(com.mulesoft.tools.migration.step.util.TransportsUtils.migrateInboundEndpointStructure) CORE_NAMESPACE(com.mulesoft.tools.migration.step.util.XmlDslUtils.CORE_NAMESPACE) Optional(java.util.Optional) Namespace(org.jdom2.Namespace) XmlDslUtils.copyAttributeIfPresent(com.mulesoft.tools.migration.step.util.XmlDslUtils.copyAttributeIfPresent) XmlDslUtils.migrateReconnect(com.mulesoft.tools.migration.step.util.XmlDslUtils.migrateReconnect) Element(org.jdom2.Element) Attribute(org.jdom2.Attribute) XmlDslUtils.addMigrationAttributeToElement(com.mulesoft.tools.migration.step.util.XmlDslUtils.addMigrationAttributeToElement) Element(org.jdom2.Element)

Example 17 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute 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");
}
Also used : TransportsUtils.processAddress(com.mulesoft.tools.migration.step.util.TransportsUtils.processAddress) Attribute(org.jdom2.Attribute) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) TransportsUtils.handleConnectorChildElements(com.mulesoft.tools.migration.step.util.TransportsUtils.handleConnectorChildElements) CORE_EE_NAMESPACE(com.mulesoft.tools.migration.step.util.XmlDslUtils.CORE_EE_NAMESPACE) CORE_NAMESPACE(com.mulesoft.tools.migration.step.util.XmlDslUtils.CORE_NAMESPACE) Optional(java.util.Optional) Namespace(org.jdom2.Namespace) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) TransportsUtils.migrateOutboundEndpointStructure(com.mulesoft.tools.migration.step.util.TransportsUtils.migrateOutboundEndpointStructure) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) Element(org.jdom2.Element) Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 18 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.

the class OSConfig method execute.

@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
    migrateOS(element);
    element.setName("object-store");
    element.removeAttribute("partition");
    Attribute persistent = element.getAttribute("persistent");
    if (persistent == null) {
        element.setAttribute(new Attribute("persistent", "false"));
    }
    Attribute config = element.getAttribute("objectStore-ref");
    if (config != null) {
        report.report("os.config", element, element);
        element.removeAttribute(config);
    }
}
Also used : Attribute(org.jdom2.Attribute)

Example 19 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.

the class OSRetrieve method execute.

@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
    migrateOS(element);
    element.removeAttribute("targetScope");
    Attribute targetProp = element.getAttribute("targetProperty");
    if (targetProp != null) {
        targetProp.setName("target");
    }
    Attribute defaultValue = element.getAttribute("defaultValue-ref");
    if (defaultValue != null) {
        Element childValue = new Element("default-value", NEW_OS_NAMESPACE);
        childValue.addContent(new CDATA(getExpressionMigrator().migrateExpression(defaultValue.getValue(), true, element)));
        element.addContent(childValue);
        element.removeAttribute(defaultValue);
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) CDATA(org.jdom2.CDATA)

Example 20 with Attribute

use of com.github.zhenwei.core.asn1.x509.Attribute in project mule-migration-assistant by mulesoft.

the class OSStore method execute.

@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
    migrateOS(element);
    Attribute overwriteAtt = element.getAttribute("overwrite");
    if (overwriteAtt == null) {
        addFailAttribute(element, report);
    } else {
        if (overwriteAtt.getValue().equals("false")) {
            addFailAttribute(element, report);
        }
        element.removeAttribute(overwriteAtt);
    }
    Attribute valueAtt = element.getAttribute("value-ref");
    if (valueAtt != null) {
        Element childValue = new Element("value", NEW_OS_NAMESPACE);
        childValue.addContent(new CDATA(getExpressionMigrator().migrateExpression(valueAtt.getValue(), true, element)));
        element.addContent(childValue);
        element.removeAttribute(valueAtt);
    }
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) CDATA(org.jdom2.CDATA)

Aggregations

Attribute (org.jdom2.Attribute)316 Element (org.jdom2.Element)210 IOException (java.io.IOException)98 ArrayList (java.util.ArrayList)75 Attribute (ucar.nc2.Attribute)65 List (java.util.List)46 Document (org.jdom2.Document)43 Variable (ucar.nc2.Variable)39 HashMap (java.util.HashMap)26 Extensions (org.bouncycastle.asn1.x509.Extensions)26 X509Certificate (java.security.cert.X509Certificate)24 Namespace (org.jdom2.Namespace)24 File (java.io.File)23 Attribute (org.bouncycastle.asn1.pkcs.Attribute)21 GeneralName (org.bouncycastle.asn1.x509.GeneralName)21 Array (ucar.ma2.Array)21 Test (org.junit.Test)20 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)19 Dimension (ucar.nc2.Dimension)19 Map (java.util.Map)17