Search in sources :

Example 46 with Attribute

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

the class AbstractFilterMigrator method handleFilter.

protected void handleFilter(Element filter) {
    if (filter.getAttribute("name") != null) {
        Attribute nameAttribute = filter.getAttribute("name");
        if (filter.getAttribute("name", DOCS_NAMESPACE) != null) {
            nameAttribute.detach();
        } else {
            filter.getDocument().getRootElement().addNamespaceDeclaration(DOCS_NAMESPACE);
            nameAttribute.setNamespace(DOCS_NAMESPACE);
        }
    }
    if (!(filter.getParentElement().getNamespace().equals(VALIDATION_NAMESPACE) && filter.getParentElement().getName().endsWith("filter"))) {
        Element flow = getContainerElement(filter);
        if (flow != null) {
            if ("flow".equals(flow.getName())) {
                Element errorHandler = getFlowExceptionHandlingElement(flow);
                if (errorHandler == null) {
                    errorHandler = new Element("error-handler", CORE_NAMESPACE);
                    flow.addContent(errorHandler);
                }
                resolveValidationHandler(errorHandler);
            } else {
                Element wrappingTry = new Element("try", CORE_NAMESPACE);
                addElementAfter(wrappingTry, filter);
                wrappingTry.addContent(filter.clone());
                filter.detach();
                Element errorHandler = new Element("error-handler", CORE_NAMESPACE);
                wrappingTry.addContent(errorHandler);
                resolveValidationHandler(errorHandler);
            }
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) XmlDslUtils.getFlowExceptionHandlingElement(com.mulesoft.tools.migration.step.util.XmlDslUtils.getFlowExceptionHandlingElement) XmlDslUtils.getContainerElement(com.mulesoft.tools.migration.step.util.XmlDslUtils.getContainerElement) Element(org.jdom2.Element)

Example 47 with Attribute

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

the class BatchHistoryExpiration method execute.

@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
    Attribute maxAge = object.getAttribute("max-age");
    if (maxAge != null) {
        maxAge.setName("maxAge");
    }
    Attribute ageUnit = object.getAttribute("age-unit");
    if (ageUnit != null) {
        ageUnit.setName("ageUnit");
    }
}
Also used : Attribute(org.jdom2.Attribute)

Example 48 with Attribute

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

the class AbstractCompressionMigrationStep method removeArgumentAndReport.

protected void removeArgumentAndReport(Element element, String argumentName, String reportEntryKey, MigrationReport report) {
    Attribute attribute = element.getAttribute(argumentName);
    if (attribute != null) {
        report.report(reportEntryKey, element, element);
        element.removeAttribute(attribute);
    }
}
Also used : Attribute(org.jdom2.Attribute)

Example 49 with Attribute

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

the class RollbackExceptionStrategy method execute.

@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
    changeNodeName("", "on-error-propagate").apply(element);
    encapsulateException(element);
    boolean hadWhen = element.getAttribute("when") != null;
    migrateWhenExpression(element);
    if (element.getAttribute("maxRedeliveryAttempts") != null) {
        Attribute maxRedelivery = element.getAttribute("maxRedeliveryAttempts");
        maxRedelivery.detach();
        Element flow = getContainerElement(element);
        if (flow != null && !flow.getChildren().isEmpty()) {
            Element source = flow.getChildren().get(0);
            if (source.getAttribute("isMessageSource", Namespace.getNamespace("migration")) != null) {
                Element redelivery = source.getChild("idempotent-redelivery-policy", CORE_NAMESPACE);
                if (redelivery != null) {
                    redelivery.setName("redelivery-policy");
                    Attribute exprAttr = redelivery.getAttribute("idExpression");
                    exprAttr.setValue(getExpressionMigrator().migrateExpression(exprAttr.getValue(), true, redelivery));
                    Attribute maxRedeliveryCountAtt = redelivery.getAttribute("maxRedeliveryCount");
                    if (maxRedeliveryCountAtt != null) {
                        maxRedeliveryCountAtt.setValue(maxRedelivery.getValue());
                    } else {
                        redelivery.setAttribute("maxRedeliveryCount", maxRedelivery.getValue());
                    }
                    if (getExpressionMigrator().isWrapped(exprAttr.getValue())) {
                        exprAttr.setValue(getExpressionMigrator().wrap(getExpressionMigrator().migrateExpression(exprAttr.getValue(), true, element)));
                    }
                    migrateRedeliveryPolicyChildren(redelivery, report);
                } else {
                    Element redeliveryPolicy = new Element("redelivery-policy");
                    redeliveryPolicy.setNamespace(CORE_NAMESPACE);
                    redeliveryPolicy.setAttribute("maxRedeliveryCount", maxRedelivery.getValue());
                    source.addContent(0, redeliveryPolicy);
                }
            }
        } else {
            report.report("errorHandling.redelivery", element, element);
        }
    }
    if (element.getChild("on-redelivery-attempts-exceeded", element.getNamespace()) != null) {
        Element redeliverySection = element.getChild("on-redelivery-attempts-exceeded", element.getNamespace());
        redeliverySection.detach();
        Element newOnError = new Element("on-error-propagate");
        newOnError.setNamespace(element.getNamespace());
        newOnError.setAttribute("type", "REDELIVERY_EXHAUSTED");
        List<Element> redeliveryElements = new ArrayList<>();
        element.getChildren().forEach(e -> redeliveryElements.add(e.clone()));
        redeliverySection.getChildren().forEach(e -> {
            e.detach();
            redeliveryElements.add(e);
        });
        newOnError.addContent(redeliveryElements);
        element.getParentElement().addContent(newOnError);
        if (!hadWhen) {
            element.detach();
        }
    }
}
Also used : Attribute(org.jdom2.Attribute) XmlDslUtils.getContainerElement(com.mulesoft.tools.migration.step.util.XmlDslUtils.getContainerElement) Element(org.jdom2.Element) ArrayList(java.util.ArrayList)

Example 50 with Attribute

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

the class SpringImport method execute.

@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
    Attribute resource = element.getAttribute("resource");
    Element parent = element.getParentElement();
    if (resource != null && isMuleConfigFile(resource.getValue(), getApplicationModel().getProjectBasePath())) {
        element.setNamespace(CORE_NAMESPACE);
        resource.setName("file");
        element.detach();
        addTopLevelElement(element, parent.getDocument());
    }
    if (parent.getChildren().isEmpty()) {
        parent.detach();
    }
}
Also used : Attribute(org.jdom2.Attribute) XmlDslUtils.addTopLevelElement(com.mulesoft.tools.migration.step.util.XmlDslUtils.addTopLevelElement) Element(org.jdom2.Element)

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