Merge pull request #90 from Codearte/issues/86-fixed-case-for-exception-on-xml

[#86] Fixed the case when an exception is thrown for XML processing
This commit is contained in:
Olga Maciaszek-Sharma
2015-06-19 12:13:25 +02:00

View File

@@ -51,12 +51,19 @@ class ContentUtils {
return extractValueForXML(bodyAsValue, valueProvider)
} catch (Exception exception) {
log.debug("No content type provided and failed to parse as XML - returning the value back to the user", exception)
return bodyAsValue
return extractValueForGString(bodyAsValue, valueProvider)
}
}
}
private static GStringImpl extractValueForGString(GString bodyAsValue, Closure valueProvider) {
return new GStringImpl(
bodyAsValue.values.collect { it instanceof DslProperty ? valueProvider(it) : it } as String[],
bodyAsValue.strings.clone() as String[]
)
}
public static Object extractValue(GString bodyAsValue, Closure valueProvider) {
return extractValue(bodyAsValue, ContentType.UNKNOWN, valueProvider)
}