-
Notifications
You must be signed in to change notification settings - Fork 0
/
Updated-implementation-file
132 lines (120 loc) · 10.4 KB
/
Updated-implementation-file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit"
xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
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/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-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd">
<file:connector name="File_outbound" autoDelete="true" streaming="true" validateConnections="true" doc:name="File" />
<file:connector name="File" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/>
<flow name="implementation-fileFlow">
<file:inbound-endpoint path="C:\Users\zubair.rafaqat\Desktop\New folder\input" connector-ref="File" pollingFrequency="100000" fileAge="5000" responseTimeout="10000" doc:name="File">
<file:filename-regex-filter pattern="(.*)" caseSensitive="false"/>
</file:inbound-endpoint>
<logger message="Start Reading Zip file and taking backup of file" level="INFO" doc:name="Logger"/>
<set-variable variableName="fileName" value="#[message.inboundProperties.originalFilename.replaceFirst("[.][^.]+$", "")]" doc:name="fileName"/>
<set-variable variableName="UUID" value="#[java.util.UUID.randomUUID()]" doc:name="UUID"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-variable variableName="timeStamp"><![CDATA[%dw 1.0
%output application/java
---
(now as :string {format: "yyyyMMddHHmmssSSS"})]]></dw:set-variable>
</dw:transform-message>
<file:outbound-endpoint path="C:\Users\zubair.rafaqat\Desktop\New folder\staging" outputPattern="#[flowVars.fileName]-#[flowVars.UUID]-#[flowVars.timeStamp].zip" connector-ref="File_outbound" responseTimeout="10000" doc:name="File"/>
<logger message="File Saved to backup Folder" level="INFO" doc:name="Logger"/>
</flow>
<flow name="zipfile_to_textfile">
<file:inbound-endpoint path="C:\Users\zubair.rafaqat\Desktop\New folder\staging" responseTimeout="10000" doc:name="File" fileAge="5000" connector-ref="File" moveToDirectory="C:\Users\zubair.rafaqat\Desktop\New folder\backup" moveToPattern="#[message.inboundProperties.originalFilename]">
<file:filename-regex-filter pattern="(.*)" caseSensitive="false"/>
</file:inbound-endpoint>
<logger message="Start Reading Zip file" level="INFO" doc:name="Logger"/>
<custom-transformer class="com.mule.zip.UnzipTransformer" doc:name="Java">
</custom-transformer>
<logger message="#[message.inboundProperties.originalFilename.replaceFirst("[.][^.]+$", "")]" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="C:\Users\zubair.rafaqat\Desktop\New folder\output" outputPattern="#[message.inboundProperties.originalFilename.replaceFirst("[.][^.]+$", ".txt")]" connector-ref="File_outbound" responseTimeout="10000" doc:name="File"/>
<logger message="Process End" level="INFO" doc:name="Logger"/>
<choice-exception-strategy doc:name="Choice Exception Strategy">
<apikit:mapping-exception-strategy doc:name="Mapping Exception Strategy">
<apikit:mapping statusCode="404">
<apikit:exception value="org.mule.module.apikit.exception.NotFoundException" />
<apikit:exception value="org.mule.module.http.internal.request.ResponseValidatorException"/>
<set-property propertyName="http.reason" value="#[message.inboundProperties['http.reason'] ]" doc:name="Property"/>
<set-variable variableName="errMsg" value="#[message.inboundProperties['http.reason'] == null || message.inboundProperties['http.reason'].length() == 0 ? "Resource not found" : message.inboundProperties['http.reason'] ]" doc:name="errMsg"/>
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "errorCode": 404, "message": "#[flowVars.errMsg]" }" doc:name="Set Payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
<apikit:mapping statusCode="405">
<apikit:exception value="org.mule.module.apikit.exception.MethodNotAllowedException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property" />
<set-payload value="{ "errorCode": 405, "message": "Method not allowed" } " doc:name="Set Payload" />
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
<apikit:mapping statusCode="415">
<apikit:exception value="org.mule.module.apikit.exception.UnsupportedMediaTypeException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property" />
<set-payload value="{ "errorCode": 415, "message": "Unsupported media type" } " doc:name="Set Payload" />
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
<apikit:mapping statusCode="406">
<apikit:exception value="org.mule.module.apikit.exception.NotAcceptableException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property" />
<set-payload value="{ "errorCode": 406, "message": "Not acceptable" } " doc:name="Set Payload" />
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
<apikit:mapping statusCode="400">
<apikit:exception value="org.mule.module.apikit.exception.BadRequestException" />
<set-property propertyName="Content-Type" value="application/json" doc:name="Property" />
<set-payload value="{ "errorCode": 400, "message": "Bad request" } " doc:name="Set Payload" />
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
<apikit:mapping statusCode="410">
<apikit:exception value="org.mule.api.MessagingException"/>
<choice doc:name="Choice">
<when expression="exception.message.contains('org.mule.module.json.validation.JsonSchemaValidationException')">
<set-property propertyName="http.status" value="#[412]" doc:name="http.status"/>
<set-property propertyName="http.reason" value="Schema Validation Error" doc:name="http.reason"/>
<set-payload value="{ "errorCode": 412, "message": "#[exception.message]" }" doc:name="Set Payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</when>
<otherwise>
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-variable variableName="errMsg" value="#[message.inboundProperties['http.reason'] == null ? "Resource not available" : message.inboundProperties['http.reason'] ]" doc:name="errMsg"/>
<set-payload value="{ "errorCode": 410, "message": "#[flowVars.errMsg]" }" doc:name="Set Payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</otherwise>
</choice>
</apikit:mapping>
<apikit:mapping statusCode="412">
<apikit:exception value="org.mule.api.MessagingException"/>
<apikit:exception value="org.mule.module.json.validation.JsonSchemaValidationException"/>
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-variable variableName="errMsg" value="#[message.inboundProperties['http.reason'] == null ? "Resource not available" : message.inboundProperties['http.reason'] ]" doc:name="errMsg"/>
<set-payload value="{ "errorCode": 412, "message": "#[flowVars.errMsg]" }" doc:name="Set Payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
<apikit:mapping statusCode="500">
<apikit:exception value="org.mule.component.ComponentException"/>
<apikit:exception value="java.lang.Exception"/>
<apikit:exception value="org.mule.api.expression.InvalidExpressionException"/>
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "errorCode": 500, "message": "Internal server error" } " doc:name="Set Payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
<apikit:mapping statusCode="504">
<apikit:exception value="java.net.SocketTimeoutException"/>
<apikit:exception value="java.net.ConnectException"/>
<apikit:exception value="javax.net.ssl.SSLException"/>
<apikit:exception value="java.sql.SQLException"/>
<set-property propertyName="Content-Type" value="application/json" doc:name="Property"/>
<set-payload value="{ "errorCode": 504, "message": "Connection timed out" } " doc:name="Set Payload"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</apikit:mapping>
</apikit:mapping-exception-strategy>
</choice-exception-strategy>
</flow>
</mule>