Skip to content

Commit

Permalink
Fix "cannot move api folder" error (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
svacas authored May 26, 2022
1 parent ca5ceb0 commit 659e817
Show file tree
Hide file tree
Showing 13 changed files with 1,266 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import com.mulesoft.tools.migration.step.category.MigrationReport;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

import org.apache.commons.io.FileUtils;

/**
* Provides reusable methods for common migration scenarios.
*
Expand All @@ -22,10 +25,10 @@ public final class ProjectStructureUtils {
/**
* Method to rename/move an existing file on the application
*
* @param fileName the path of the file
* @param newFileName the new path of the file
* @param fileName the path of the file
* @param newFileName the new path of the file
* @param applicationModel the {@link ApplicationModel} of the application
* @param report the {@link MigrationReport} to update the existing entries on the file
* @param report the {@link MigrationReport} to update the existing entries on the file
*/
public static void renameFile(Path fileName, Path newFileName, ApplicationModel applicationModel, MigrationReport report) {
File fileRename = fileName.toFile();
Expand All @@ -35,4 +38,26 @@ public static void renameFile(Path fileName, Path newFileName, ApplicationModel
report.updateReportEntryFilePath(fileName, newFileName);
}
}

/**
* Moves a directory.
* If the destination directory exists it copies the source directory content and then deletes it.
*
* @param srcDir the directory to be moved.
* @param destDir the destination directory.
* @throws NullPointerException if any of the given {@code File}s are {@code null}.
* @throws IllegalArgumentException if the source or destination is invalid.
* @throws IOException if an error occurs.
*/
public static void moveDirectory(File srcDir, File destDir) throws IOException {
if (srcDir.isDirectory()) {
if (!destDir.exists()) {
FileUtils.moveDirectory(srcDir, destDir);
} else {
FileUtils.copyDirectory(srcDir, destDir);
FileUtils.deleteDirectory(srcDir);
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#%RAML 1.0
title: Sample API
version: 1.0
mediaType: application/json

/resource:
post:
body:
responses:
200:
body:
/{id}:
get:
responses:
201:
body:
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" 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
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/apikit http://www.mulesoft.org/schema/mule/apikit/current/mule-apikit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<http:listener-config name="httpListenerConfig" host="0.0.0.0" port="${httpPort}"/>
<apikit:config name="api-config" raml="api.raml" consoleEnabled="false"/>
<flow name="global-kafka-sys-api-main">
<http:listener config-ref="httpListenerConfig" path="/api/*"/>
<response>
<set-property propertyName="test" value="test"/>
</response>
<apikit:router config-ref="api-config"/>
<exception-strategy ref="apiKitGlobalExceptionMapping"/>
</flow>
<flow name="post:/resource:application/json:api-config">
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{&#xD;&#xA; &quot;response&quot; :{&#xD;&#xA; &quot;status&quot;: &quot;success&quot;,&#xD;&#xA; &quot;http-status&quot; : 201,&#xD;&#xA; &quot;message_ID&quot;: &quot;a7a756040 10/07/2017-14:40:01.6Z&quot;,&#xD;&#xA; &quot;summary&quot;: &quot;The new customer record was written successfully&quot;,&#xD;&#xA; &quot;timestamp&quot; : &quot;2000-01-01T00:00:00.0Z&quot;&#xD;&#xA; }&#xD;&#xA;}"/>
</flow>
<flow name="get:/resource/{id}:application/json:api-config">
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{&#xD;&#xA; &quot;response&quot; :{&#xD;&#xA; &quot;status&quot;: &quot;success&quot;,&#xD;&#xA; &quot;http-status&quot; : 201,&#xD;&#xA; &quot;message_ID&quot;: &quot;a7a756040 10/07/2017-14:40:01.6Z&quot;,&#xD;&#xA; &quot;summary&quot;: &quot;The new customer record was written successfully&quot;,&#xD;&#xA; &quot;timestamp&quot; : &quot;2000-01-01T00:00:00.0Z&quot;&#xD;&#xA; }&#xD;&#xA;}"/>
</flow>
<apikit:mapping-exception-strategy name="apiKitGlobalExceptionMapping">
<apikit:mapping statusCode="404">
<apikit:exception value="org.mule.module.apikit.exception.NotFoundException" />
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{ &quot;message&quot;: &quot;Resource not found&quot; }"/>
</apikit:mapping>
<apikit:mapping statusCode="405">
<apikit:exception value="org.mule.module.apikit.exception.MethodNotAllowedException" />
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{ &quot;message&quot;: &quot;Method not allowed&quot; }"/>
</apikit:mapping>
<apikit:mapping statusCode="415">
<apikit:exception value="org.mule.module.apikit.exception.UnsupportedMediaTypeException" />
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{ &quot;message&quot;: &quot;Unsupported media type&quot; }"/>
</apikit:mapping>
<apikit:mapping statusCode="406">
<apikit:exception value="org.mule.module.apikit.exception.NotAcceptableException" />
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{ &quot;message&quot;: &quot;Not acceptable&quot; }"/>
</apikit:mapping>
<apikit:mapping statusCode="400">
<apikit:exception value="org.mule.module.apikit.exception.BadRequestException" />
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{ &quot;message&quot;: &quot;Bad request&quot; }"/>
</apikit:mapping>
<apikit:mapping statusCode="500">
<apikit:exception value="java.lang.ClassNotFoundException" />
<set-property propertyName="Content-Type" value="application/json"/>
<set-payload value="{ &quot;message&quot;: &quot;Bad request&quot; }"/>
</apikit:mapping>
</apikit:mapping-exception-strategy>
</mule>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:apikit-soap="http://www.mulesoft.org/schema/mule/apikit-soap"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
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
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/apikit-soap http://www.mulesoft.org/schema/mule/apikit-soap/current/mule-apikit-soap.xsd ">
<http:listener-config name="api-httpListenerConfig" host="0.0.0.0" port="${httpPort}" />
<apikit-soap:config name="/TshirtService/TshirtServicePort/api-config" wsdlUrl="tshirt.wsdl" serviceName="TshirtService" portName="TshirtServicePort" />
<flow name="api-main">
<http:listener path="/TshirtService/TshirtServicePort" config-ref="api-httpListenerConfig" doc:name="/TshirtService/TshirtServicePort" />
<apikit-soap:router config-ref="/TshirtService/TshirtServicePort/api-config" />
</flow>
<flow name="OrderTshirt:/TshirtService/TshirtServicePort/api-config">
<set-attachment attachmentName="fileID" value="some content." contentType="text/plain"/>
<set-payload value="&lt;soap:Fault xmlns:soap=&quot;http://www.w3.org/2003/05/soap-envelope&quot;&gt;&lt;faultcode&gt;soap:Server&lt;/faultcode&gt;&lt;faultstring&gt;Operation [OrderTshirt:/TshirtService/TshirtServicePort/api-config] not implemented&lt;/faultstring&gt;&lt;/soap:Fault&gt;" />
<dw:transform-message>
<dw:set-property propertyName="soap.header"><![CDATA[%dw 1.0
%output application/xml
%namespace ns0 http://mulesoft.org/tshirt-service
---
{
ns0#APIUsageInformation: {
apiCallsRemaining: 10
}
}]]> </dw:set-property>
</dw:transform-message>
</flow>
<flow name="ListInventory:/TshirtService/TshirtServicePort/api-config">
<set-payload value="&lt;soap:Fault xmlns:soap=&quot;http://www.w3.org/2003/05/soap-envelope&quot;&gt;&lt;faultcode&gt;soap:Server&lt;/faultcode&gt;&lt;faultstring&gt;Operation [ListInventory:/TshirtService/TshirtServicePort/api-config] not implemented&lt;/faultstring&gt;&lt;/soap:Fault&gt;" />
</flow>
<flow name="TrackOrder:/TshirtService/TshirtServicePort/api-config">
<set-payload value="&lt;soap:Fault xmlns:soap=&quot;http://www.w3.org/2003/05/soap-envelope&quot;&gt;&lt;faultcode&gt;soap:Server&lt;/faultcode&gt;&lt;faultstring&gt;Operation [TrackOrder:/TshirtService/TshirtServicePort/api-config] not implemented&lt;/faultstring&gt;&lt;/soap:Fault&gt;" />
</flow>
</mule>
Loading

0 comments on commit 659e817

Please sign in to comment.