forked from mulesoft-consulting/json-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mulesoft-consulting#22 - added isBlank checks for mimeType and if isB…
…lank then will just return the initial inputData
- Loading branch information
bcoveny
committed
Feb 1, 2021
1 parent
e48def4
commit 5dc7952
Showing
1 changed file
with
52 additions
and
40 deletions.
There are no files selected for viewing
92 changes: 52 additions & 40 deletions
92
json-logger/src/main/resources/modules/JSONLoggerModule.dwl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,56 @@ | ||
%dw 2.0 | ||
fun stringifyAny(inputData: Any) = if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw" or | ||
inputData.^mimeType == "application/json") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else if (inputData.^mimeType == "*/*") | ||
inputData | ||
else | ||
write(inputData,inputData.^mimeType) | ||
fun stringifyAny(inputData: Any) = | ||
if (isBlank(inputData.^mimeType) or | ||
inputData.^mimeType == "*/*") | ||
inputData | ||
else if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw" or | ||
inputData.^mimeType == "application/json") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else | ||
write(inputData,inputData.^mimeType) | ||
|
||
fun stringifyNonJSON(inputData: Any) = if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else if (inputData.^mimeType == "application/json" or inputData.^mimeType == "*/*") | ||
inputData | ||
else | ||
write(inputData,inputData.^mimeType) | ||
fun stringifyNonJSON(inputData: Any) = | ||
if (isBlank(inputData.^mimeType) or | ||
inputData.^mimeType == "*/*" or | ||
inputData.^mimeType == "application/json") | ||
inputData | ||
else if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else | ||
write(inputData,inputData.^mimeType) | ||
|
||
fun stringifyAnyWithMetadata(inputData: Any) = { | ||
data: if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw" or | ||
inputData.^mimeType == "application/json") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else if (inputData.^mimeType == "*/*") | ||
inputData | ||
else | ||
write(inputData,inputData.^mimeType), | ||
(contentLength: inputData.^contentLength) if (inputData.^contentLength != null), | ||
(dataType: inputData.^mimeType) if (inputData.^mimeType != null), | ||
(class: inputData.^class) if (inputData.^class != null) | ||
} | ||
fun stringifyAnyWithMetadata(inputData: Any) = | ||
{ | ||
data: if (isBlank(inputData.^mimeType) or | ||
inputData.^mimeType == "*/*") | ||
inputData | ||
else if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw" or | ||
inputData.^mimeType == "application/json") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else | ||
write(inputData,inputData.^mimeType), | ||
|
||
(contentLength: inputData.^contentLength) if (inputData.^contentLength != null), | ||
(dataType: inputData.^mimeType) if (inputData.^mimeType != null), | ||
(class: inputData.^class) if (inputData.^class != null) | ||
} | ||
|
||
fun stringifyNonJSONWithMetadata(inputData: Any) = { | ||
data: if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else if (inputData.^mimeType == "application/json" or inputData.^mimeType == "*/*") | ||
inputData | ||
else | ||
write(inputData,inputData.^mimeType), | ||
(contentLength: inputData.^contentLength) if (inputData.^contentLength != null), | ||
(dataType: inputData.^mimeType) if (inputData.^mimeType != null), | ||
(class: inputData.^class) if (inputData.^class != null) | ||
} | ||
fun stringifyNonJSONWithMetadata(inputData: Any) = | ||
{ | ||
data: if (isBlank(inputData.^mimeType) or | ||
inputData.^mimeType == "*/*" or | ||
inputData.^mimeType == "application/json") | ||
inputData | ||
else if (inputData.^mimeType == "application/xml" or | ||
inputData.^mimeType == "application/dw") | ||
write(inputData,inputData.^mimeType,{indent:false}) | ||
else | ||
write(inputData,inputData.^mimeType), | ||
|
||
(contentLength: inputData.^contentLength) if (inputData.^contentLength != null), | ||
(dataType: inputData.^mimeType) if (inputData.^mimeType != null), | ||
(class: inputData.^class) if (inputData.^class != null) | ||
} |