Skip to content

Commit

Permalink
Report interceptors as not migrated (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
svacas authored Jun 8, 2022
1 parent 523b7e2 commit ab992ec
Show file tree
Hide file tree
Showing 17 changed files with 352 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

<interceptor-stack name="stack">
<custom-interceptor
class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor" />
</interceptor-stack>

<flow name="MyService">
<custom-interceptor class="org.my.CustomInterceptor"/>
<logging-interceptor/>
<interceptor-stack ref="stack"/>
<timer-interceptor/>
</flow>

<flow name="flow1">
<log-component>
<interceptor-stack ref="stack" />
</log-component>
</flow>

<flow name="flow2">
<echo-component/>
<echo-component>
<custom-interceptor class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor" />
</echo-component>

<log-component/>
<log-component>
<custom-interceptor class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor" />
</log-component>

<null-component/>
<null-component>
<custom-interceptor class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor" />
</null-component>
</flow>

</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"projectType": "MULE_THREE_APPLICATION",
"projectName": "input",
"connectorsMigrated": [],
"numberOfMuleComponents": 21,
"numberOfMuleComponentsMigrated": 11,
"componentDetails": {
"mule": {
"success": 1,
"failure": 0
},
"flow": {
"success": 3,
"failure": 0
},
"interceptor-stack": {
"success": 0,
"failure": 3
},
"custom-interceptor": {
"success": 0,
"failure": 5
},
"logging-interceptor": {
"success": 0,
"failure": 1
},
"timer-interceptor": {
"success": 0,
"failure": 1
},
"echo-component": {
"success": 1,
"failure": 0
},
"set-payload": {
"success": 1,
"failure": 0
},
"logger": {
"success": 3,
"failure": 0
},
"raise-error": {
"success": 2,
"failure": 0
}
},
"numberOfMELExpressions": 0,
"numberOfMELExpressionsMigrated": 0,
"numberOfMELExpressionLines": 0,
"numberOfMELExpressionLinesMigrated": 0,
"numberOfDWTransformations": 0,
"numberOfDWTransformationsMigrated": 0,
"numberOfDWTransformationLines": 0,
"numberOfDWTransformationLinesMigrated": 0,
"detailedMessages": [
{
"level": "ERROR",
"key": "components.interceptors",
"component": "interceptor-stack",
"lineNumber": 4,
"columnNumber": 37,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "custom-interceptor",
"lineNumber": 8,
"columnNumber": 124,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "custom-interceptor",
"lineNumber": 16,
"columnNumber": 62,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "logging-interceptor",
"lineNumber": 22,
"columnNumber": 30,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "interceptor-stack",
"lineNumber": 28,
"columnNumber": 40,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "timer-interceptor",
"lineNumber": 34,
"columnNumber": 28,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "interceptor-stack",
"lineNumber": 44,
"columnNumber": 44,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "custom-interceptor",
"lineNumber": 55,
"columnNumber": 128,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "custom-interceptor",
"lineNumber": 65,
"columnNumber": 128,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
},
{
"level": "ERROR",
"key": "components.interceptors",
"component": "custom-interceptor",
"lineNumber": 75,
"columnNumber": 128,
"message": "Interceptors have been replaced by custom policies in Mule 4.",
"filePath": "src/main/mule/mule-config.xml",
"documentationLinks": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

<interceptor-stack name="stack">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
<custom-interceptor class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</custom-interceptor>
</interceptor-stack>

<flow name="MyService">
<custom-interceptor class="org.my.CustomInterceptor">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</custom-interceptor>

<logging-interceptor>
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</logging-interceptor>

<interceptor-stack ref="stack">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</interceptor-stack>

<timer-interceptor>
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</timer-interceptor>

</flow>

<flow name="flow1">
<logger message="#[payload]">
<interceptor-stack ref="stack">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</interceptor-stack>
</logger>

</flow>

<flow name="flow2">
<set-payload value="#[payload]">
<custom-interceptor class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</custom-interceptor>
</set-payload>

<logger message="#[payload]" />

<logger message="#[payload]">
<custom-interceptor class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</custom-interceptor>
</logger>

<raise-error type="COMPATIBILITY:UNSUPPORTED" description="This service cannot receive messages" />

<raise-error type="COMPATIBILITY:UNSUPPORTED" description="This service cannot receive messages">
<custom-interceptor class="org.mule.test.integration.interceptor.SharedInterceptorStackTestCase$CustomInterceptor">
<!--Migration ERROR: Interceptors have been replaced by custom policies in Mule 4.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/api-manager/2.x/policies-custom-landing-page-->
</custom-interceptor>
</raise-error>

</flow>

</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2020, Mulesoft, LLC. All rights reserved.
* Use of this source code is governed by a BSD 3-Clause License
* license that can be found in the LICENSE.txt file.
*/
package com.mulesoft.tools.migration.library.mule.steps.core;

import com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep;
import com.mulesoft.tools.migration.step.category.MigrationReport;

import org.jdom2.Element;

/**
* Unsupported interceptor elements.
*
* @author Mulesoft Inc.
* @since 1.0.0
*/
public class InterceptorElements extends AbstractApplicationModelMigrationStep {

public static final String XPATH_SELECTOR = ""
+ "//*["
+ "local-name()='interceptor-stack' or "
+ "local-name()='custom-interceptor' or "
+ "local-name()='logging-interceptor' or "
+ "local-name()='timer-interceptor'"
+ "]";

@Override
public String getDescription() {
return "Interceptor elements are no longer supported";
}

public InterceptorElements() {
this.setAppliedTo(XPATH_SELECTOR);
}

@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
report.report("components.interceptors", object, object, object.getName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class JavaReferenceElements extends AbstractApplicationModelMigrationStep
+ "local-name()='custom-processing-strategy' or "
+ "local-name()='custom-transaction-manager' or "
+ "local-name()='custom-security-filter' or "
+ "local-name()='custom-interceptor' or "
+ "local-name()='custom-transformer' or " // actually deprecated
+ "local-name()='custom-exception-strategy' or "
+ "local-name()='custom-connector' or "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public class RemovedElements extends AbstractApplicationModelMigrationStep {
public static final String XPATH_SELECTOR = ""
+ "//*["
+ "local-name()='static-component' or "
+ "local-name()='dynamic-all' or "
+ "local-name()='interceptor-stack'"
+ "local-name()='dynamic-all'"
+ "]";

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public EchoComponent() {
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
if (!object.getChildren().isEmpty()) {
report.report("components.interceptors", object, object);
object.setName("set-payload");
object.setAttribute("value", "#[payload]");
object.removeContent();
} else {
object.detach();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public LogComponent() {
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
object.setName("logger");
if (!object.getChildren().isEmpty()) {
report.report("components.interceptors", object, object);
object.removeContent();
}
object.setAttribute("message", "#[payload]");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public NullComponent() {
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
object.setName("raise-error");
if (!object.getChildren().isEmpty()) {
report.report("components.interceptors", object, object);
object.removeContent();
}
object.setAttribute("type", "COMPATIBILITY:UNSUPPORTED");
object.setAttribute("description", "This service cannot receive messages");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.mulesoft.tools.migration.library.mule.steps.core.CopyProperties;
import com.mulesoft.tools.migration.library.mule.steps.core.DataMapper;
import com.mulesoft.tools.migration.library.mule.steps.core.ExpressionComponent;
import com.mulesoft.tools.migration.library.mule.steps.core.InterceptorElements;
import com.mulesoft.tools.migration.library.mule.steps.core.JavaReferenceElements;
import com.mulesoft.tools.migration.library.mule.steps.core.MessageAttachmentsListExpressionEvaluator;
import com.mulesoft.tools.migration.library.mule.steps.core.MessagePropertiesTransformer;
Expand Down Expand Up @@ -63,6 +64,7 @@ public String getFrom() {
@Override
public List<MigrationStep> getSteps() {
return newArrayList(new CompatibilityPomContribution(),
new InterceptorElements(),
new EchoComponent(),
new LogComponent(),
new NullComponent(),
Expand Down
Loading

0 comments on commit ab992ec

Please sign in to comment.