summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java
index 565911eaa9..5eed7eeb0d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java
@@ -85,6 +85,7 @@ public class RepresentationUtils {
JsonObject jsonElement = new JsonObject();
ArtifactDefinition resourceInfo = null;
+
try {
Gson gson = new Gson();
jsonElement = gson.fromJson(content, jsonElement.getClass());
@@ -109,13 +110,19 @@ public class RepresentationUtils {
payload = artifactPayload.getAsString();
}
jsonElement.remove(Constants.ARTIFACT_PAYLOAD_DATA);
- resourceInfo = gson.fromJson(jsonElement, clazz);
+ String json = gson.toJson(jsonElement);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(Feature.FAIL_ON_EMPTY_BEANS, false);
+ mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
+
+ resourceInfo = mapper.readValue(json, clazz);
resourceInfo.setPayloadData(payload);
} catch (Exception e) {
BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeArtifactInformationInvalidError, "Artifact Upload / Update");
BeEcompErrorManager.getInstance().logBeArtifactInformationInvalidError("Artifact Upload / Update");
- log.debug("Failed to convert the content {} to object. {}", content.substring(0, Math.min(50, content.length())), e);
+ log.debug("Failed to convert the content {} to object.", content.substring(0, Math.min(50, content.length())), e);
}
return resourceInfo;