Code Review
/
aai
/
champ.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix serialization of the "key" property
[aai/champ.git]
/
champ-lib
/
champ-core
/
src
/
main
/
java
/
org
/
onap
/
aai
/
champcore
/
event
/
envelope
/
ChampEventHeader.java
diff --git
a/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/envelope/ChampEventHeader.java
b/champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/envelope/ChampEventHeader.java
index
9ff6deb
..
3e19aa5
100644
(file)
--- a/
champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/envelope/ChampEventHeader.java
+++ b/
champ-lib/champ-core/src/main/java/org/onap/aai/champcore/event/envelope/ChampEventHeader.java
@@
-27,9
+27,10
@@
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.UUID;
import org.apache.commons.lang3.builder.EqualsBuilder;
import java.util.Objects;
import java.util.UUID;
import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.onap.aai.champcore.event.envelope.util.GsonUtil;
-import com.google.gson.Gson;
-import com.google.gson.annotations.SerializedName;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class ChampEventHeader {
public class ChampEventHeader {
@@
-50,28
+51,26
@@
public class ChampEventHeader {
}
}
}
}
- @
SerializedName
("request-id")
+ @
JsonProperty
("request-id")
private String requestId;
private String timestamp;
private String requestId;
private String timestamp;
- @
SerializedName
("source-name")
+ @
JsonProperty
("source-name")
private String sourceName;
private String sourceName;
- @
SerializedName
("event-type")
+ @
JsonProperty
("event-type")
private String eventType;
private String eventType;
- @
SerializedName
("validation-entity-type")
+ @
JsonProperty
("validation-entity-type")
private String validationEntityType;
private String validationEntityType;
- @
SerializedName
("validation-top-entity-type")
+ @
JsonProperty
("validation-top-entity-type")
private String validationTopEntityType;
private String validationTopEntityType;
- @
SerializedName
("entity-link")
+ @
JsonProperty
("entity-link")
private String entityLink;
private String entityLink;
- private static final Gson gson = GsonUtil.createGson();
-
public static class Builder {
private final EventType eventType;
public static class Builder {
private final EventType eventType;
@@
-127,7
+126,14
@@
public class ChampEventHeader {
* @return a JSON format string representation of this object.
*/
public String toJson() {
* @return a JSON format string representation of this object.
*/
public String toJson() {
- return gson.toJson(this);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setSerializationInclusion(Include.NON_NULL);
+
+ try {
+ return mapper.writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ return "Unmarshallable: " + e.getMessage();
+ }
}
///////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////