summaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/appc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/model-impl/appc/src/main')
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java149
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java99
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java53
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java7
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java55
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java4
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java19
7 files changed, 253 insertions, 133 deletions
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
index 1e92744ef..8ae029b76 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
@@ -28,52 +28,107 @@ import java.util.Map;
import java.util.UUID;
public class CommonHeader implements Serializable {
-
private static final long serialVersionUID = -3581658269910980336L;
- public Instant TimeStamp = Instant.now();
- public String APIver = "1.01";
- public String OriginatorID;
- public UUID RequestID;
- public String SubRequestID;
- public Collection<String> RequestTrack = new ArrayList<>();
- public Collection<Map<String, String>> Flags = new ArrayList<>();
+ private Instant timeStamp = Instant.now();
+ private String apiVer = "1.01";
+ private String originatorID;
+ private UUID requestID;
+ private String subRequestID;
+ private Collection<String> requestTrack = new ArrayList<>();
+ private Collection<Map<String, String>> flags = new ArrayList<>();
public CommonHeader() {
-
}
public CommonHeader(CommonHeader commonHeader) {
- this.OriginatorID = commonHeader.OriginatorID;
- this.RequestID = commonHeader.RequestID;
- this.SubRequestID = commonHeader.SubRequestID;
- if (commonHeader.RequestTrack != null) {
- this.RequestTrack.addAll(commonHeader.RequestTrack);
+ this.originatorID = commonHeader.originatorID;
+ this.requestID = commonHeader.requestID;
+ this.subRequestID = commonHeader.subRequestID;
+ if (commonHeader.requestTrack != null) {
+ this.requestTrack.addAll(commonHeader.requestTrack);
}
- if (commonHeader.Flags != null) {
- this.Flags.addAll(commonHeader.Flags);
+ if (commonHeader.flags != null) {
+ this.flags.addAll(commonHeader.flags);
}
}
+ public Instant getTimeStamp() {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(Instant timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+
+ public String getApiVer() {
+ return apiVer;
+ }
+
+ public void setApiVer(String apiVer) {
+ this.apiVer = apiVer;
+ }
+
+ public String getOriginatorID() {
+ return originatorID;
+ }
+
+ public void setOriginatorID(String originatorID) {
+ this.originatorID = originatorID;
+ }
+
+ public UUID getRequestID() {
+ return requestID;
+ }
+
+ public void setRequestID(UUID requestID) {
+ this.requestID = requestID;
+ }
+
+ public String getSubRequestID() {
+ return subRequestID;
+ }
+
+ public void setSubRequestID(String subRequestID) {
+ this.subRequestID = subRequestID;
+ }
+
+ public Collection<String> getRequestTrack() {
+ return requestTrack;
+ }
+
+ public void setRequestTrack(Collection<String> requestTrack) {
+ this.requestTrack = requestTrack;
+ }
+
+ public Collection<Map<String, String>> getFlags() {
+ return flags;
+ }
+
+ public void setFlags(Collection<Map<String, String>> flags) {
+ this.flags = flags;
+ }
+
@Override
public String toString() {
- return "CommonHeader [TimeStamp=" + TimeStamp + ", APIver=" + APIver + ", OriginatorID=" + OriginatorID
- + ", RequestID=" + RequestID + ", SubrequestID=" + SubRequestID + ", RequestTrack=" + RequestTrack
- + ", Flags=" + Flags + "]";
+ return "CommonHeader [TimeStamp=" + timeStamp + ", APIver=" + apiVer + ", OriginatorID=" + originatorID
+ + ", RequestID=" + requestID + ", SubrequestID=" + subRequestID + ", RequestTrack=" + requestTrack
+ + ", Flags=" + flags + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((APIver == null) ? 0 : APIver.hashCode());
- result = prime * result + ((Flags == null) ? 0 : Flags.hashCode());
- result = prime * result + ((OriginatorID == null) ? 0 : OriginatorID.hashCode());
- result = prime * result + ((RequestID == null) ? 0 : RequestID.hashCode());
- result = prime * result + ((RequestTrack == null) ? 0 : RequestTrack.hashCode());
- result = prime * result + ((SubRequestID == null) ? 0 : SubRequestID.hashCode());
- result = prime * result + ((TimeStamp == null) ? 0 : TimeStamp.hashCode());
+ result = prime * result + ((apiVer == null) ? 0 : apiVer.hashCode());
+ result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+ result = prime * result + ((originatorID == null) ? 0 : originatorID.hashCode());
+ result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
+ result = prime * result + ((requestTrack == null) ? 0 : requestTrack.hashCode());
+ result = prime * result + ((subRequestID == null) ? 0 : subRequestID.hashCode());
+ result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
return result;
}
+
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -83,40 +138,40 @@ public class CommonHeader implements Serializable {
if (getClass() != obj.getClass())
return false;
CommonHeader other = (CommonHeader) obj;
- if (APIver == null) {
- if (other.APIver != null)
+ if (apiVer == null) {
+ if (other.apiVer != null)
return false;
- } else if (!APIver.equals(other.APIver))
+ } else if (!apiVer.equals(other.apiVer))
return false;
- if (Flags == null) {
- if (other.Flags != null)
+ if (flags == null) {
+ if (other.flags != null)
return false;
- } else if (!Flags.equals(other.Flags))
+ } else if (!flags.equals(other.flags))
return false;
- if (OriginatorID == null) {
- if (other.OriginatorID != null)
+ if (originatorID == null) {
+ if (other.originatorID != null)
return false;
- } else if (!OriginatorID.equals(other.OriginatorID))
+ } else if (!originatorID.equals(other.originatorID))
return false;
- if (RequestID == null) {
- if (other.RequestID != null)
+ if (requestID == null) {
+ if (other.requestID != null)
return false;
- } else if (!RequestID.equals(other.RequestID))
+ } else if (!requestID.equals(other.requestID))
return false;
- if (RequestTrack == null) {
- if (other.RequestTrack != null)
+ if (requestTrack == null) {
+ if (other.requestTrack != null)
return false;
- } else if (!RequestTrack.equals(other.RequestTrack))
+ } else if (!requestTrack.equals(other.requestTrack))
return false;
- if (SubRequestID == null) {
- if (other.SubRequestID != null)
+ if (subRequestID == null) {
+ if (other.subRequestID != null)
return false;
- } else if (!SubRequestID.equals(other.SubRequestID))
+ } else if (!subRequestID.equals(other.subRequestID))
return false;
- if (TimeStamp == null) {
- if (other.TimeStamp != null)
+ if (timeStamp == null) {
+ if (other.timeStamp != null)
return false;
- } else if (!TimeStamp.equals(other.TimeStamp))
+ } else if (!timeStamp.equals(other.timeStamp))
return false;
return true;
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
index a9634a7b2..a74626000 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
@@ -25,36 +25,67 @@ import java.util.HashMap;
import java.util.Map;
public class Request implements Serializable{
-
private static final long serialVersionUID = -3912323643990646431L;
- public CommonHeader CommonHeader;
- public String Action;
- public String TargetID;
- public String ObjectID;
- public Map<String, Object> Payload = new HashMap<>();
+ private CommonHeader commonHeader;
+ private String action;
+ private String targetID;
+ private String objectID;
+ private HashMap<String, Object> payload = new HashMap<>();
public Request() {
-
+ // Initiate an empty Request instance
}
public CommonHeader getCommonHeader() {
- return CommonHeader;
+ return commonHeader;
}
public Map<String, Object> getPayload() {
- return Payload;
+ return payload;
}
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getTargetID() {
+ return targetID;
+ }
+
+ public void setTargetID(String targetID) {
+ this.targetID = targetID;
+ }
+
+ public String getObjectID() {
+ return objectID;
+ }
+
+ public void setObjectID(String objectID) {
+ this.objectID = objectID;
+ }
+
+ public void setCommonHeader(CommonHeader commonHeader) {
+ this.commonHeader = commonHeader;
+ }
+
+ public void setPayload(Map<String, Object> payload) {
+ this.payload = new HashMap<>(payload);
+ }
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((Action == null) ? 0 : Action.hashCode());
- result = prime * result + ((CommonHeader == null) ? 0 : CommonHeader.hashCode());
- result = prime * result + ((ObjectID == null) ? 0 : ObjectID.hashCode());
- result = prime * result + ((Payload == null) ? 0 : Payload.hashCode());
- result = prime * result + ((TargetID == null) ? 0 : TargetID.hashCode());
+ result = prime * result + ((action == null) ? 0 : action.hashCode());
+ result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
+ result = prime * result + ((objectID == null) ? 0 : objectID.hashCode());
+ result = prime * result + ((payload == null) ? 0 : payload.hashCode());
+ result = prime * result + ((targetID == null) ? 0 : targetID.hashCode());
return result;
}
@@ -66,39 +97,45 @@ public class Request implements Serializable{
return false;
if (getClass() != obj.getClass())
return false;
+
Request other = (Request) obj;
- if (Action == null) {
- if (other.Action != null)
+ if (action == null) {
+ if (other.action != null)
return false;
- } else if (!Action.equals(other.Action))
+ } else if (!action.equals(other.action))
return false;
- if (CommonHeader == null) {
- if (other.CommonHeader != null)
+
+ if (commonHeader == null) {
+ if (other.commonHeader != null)
return false;
- } else if (!CommonHeader.equals(other.CommonHeader))
+ } else if (!commonHeader.equals(other.commonHeader))
return false;
- if (ObjectID == null) {
- if (other.ObjectID != null)
+
+ if (objectID == null) {
+ if (other.objectID != null)
return false;
- } else if (!ObjectID.equals(other.ObjectID))
+ } else if (!objectID.equals(other.objectID))
return false;
- if (Payload == null) {
- if (other.Payload != null)
+
+ if (payload == null) {
+ if (other.payload != null)
return false;
- } else if (!Payload.equals(other.Payload))
+ } else if (!payload.equals(other.payload))
return false;
- if (TargetID == null) {
- if (other.TargetID != null)
+
+ if (targetID == null) {
+ if (other.targetID != null)
return false;
- } else if (!TargetID.equals(other.TargetID))
+ } else if (!targetID.equals(other.targetID))
return false;
+
return true;
}
@Override
public String toString() {
- return "Request [CommonHeader=" + CommonHeader + ", Action=" + Action + ", TargetID=" + TargetID + ", ObjectID="
- + ObjectID + ", Payload=" + Payload + "]";
+ return "Request [CommonHeader=" + commonHeader + ", Action=" + action + ", TargetID=" + targetID + ", ObjectID="
+ + objectID + ", Payload=" + payload + "]";
}
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
index 0aeb1d483..e00205998 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
@@ -25,59 +25,60 @@ import java.util.HashMap;
import java.util.Map;
public class Response implements Serializable {
-
private static final long serialVersionUID = 434953706339865151L;
- public CommonHeader CommonHeader;
- public ResponseStatus Status = new ResponseStatus();
- public Map<String, Object> Payload = new HashMap<>();
+ private CommonHeader commonHeader;
+ private ResponseStatus status = new ResponseStatus();
+ private HashMap<String, Object> payload = new HashMap<>();
public Response() {
}
public Response(Request request) {
- this.CommonHeader = new CommonHeader(request.CommonHeader);
- if (request.Payload != null) {
- this.Payload.putAll(request.Payload);
+ if (request.getCommonHeader() != null) {
+ this.commonHeader = new CommonHeader(request.getCommonHeader());
+ }
+ if (request.getPayload() != null) {
+ this.payload.putAll(request.getPayload());
}
}
public CommonHeader getCommonHeader() {
- return CommonHeader;
+ return commonHeader;
}
public void setCommonHeader(CommonHeader commonHeader) {
- CommonHeader = commonHeader;
+ this.commonHeader = commonHeader;
}
public ResponseStatus getStatus() {
- return Status;
+ return status;
}
public void setStatus(ResponseStatus status) {
- Status = status;
+ this.status = status;
}
public Map<String, Object> getPayload() {
- return Payload;
+ return payload;
}
public void setPayload(Map<String, Object> payload) {
- Payload = payload;
+ this.payload = new HashMap<>(payload);
}
@Override
public String toString() {
- return "Response [CommonHeader=" + CommonHeader + ", Status=" + Status + ", Payload=" + Payload + "]";
+ return "Response [CommonHeader=" + commonHeader + ", Status=" + status + ", Payload=" + payload + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((CommonHeader == null) ? 0 : CommonHeader.hashCode());
- result = prime * result + ((Payload == null) ? 0 : Payload.hashCode());
- result = prime * result + ((Status == null) ? 0 : Status.hashCode());
+ result = prime * result + ((commonHeader == null) ? 0 : commonHeader.hashCode());
+ result = prime * result + ((payload == null) ? 0 : payload.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
return result;
}
@Override
@@ -89,20 +90,20 @@ public class Response implements Serializable {
if (getClass() != obj.getClass())
return false;
Response other = (Response) obj;
- if (CommonHeader == null) {
- if (other.CommonHeader != null)
+ if (commonHeader == null) {
+ if (other.commonHeader != null)
return false;
- } else if (!CommonHeader.equals(other.CommonHeader))
+ } else if (!commonHeader.equals(other.commonHeader))
return false;
- if (Payload == null) {
- if (other.Payload != null)
+ if (payload == null) {
+ if (other.payload != null)
return false;
- } else if (!Payload.equals(other.Payload))
+ } else if (!payload.equals(other.payload))
return false;
- if (Status == null) {
- if (other.Status != null)
+ if (status == null) {
+ if (other.status != null)
return false;
- } else if (!Status.equals(other.Status))
+ } else if (!status.equals(other.status))
return false;
return true;
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java
index 9bc9bb13e..fa96067c4 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java
@@ -27,9 +27,9 @@ public enum ResponseCode {
SUCCESS(400),
FAILURE(500)
;
-
+
private Integer code;
-
+
private ResponseCode(int code) {
this.code = code;
}
@@ -37,7 +37,8 @@ public enum ResponseCode {
public int getValue() {
return this.code;
}
-
+
+ @Override
public String toString() {
return Integer.toString(this.code);
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
index 6319dd8ad..7cef50127 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
@@ -23,26 +23,51 @@ package org.onap.policy.appc;
import java.io.Serializable;
public class ResponseStatus implements Serializable {
-
private static final long serialVersionUID = 2421770469587860452L;
- public int Code;
- public String Value;
- public String Description;
+ private int code;
+ private String value;
+ private String description;
@Override
public String toString() {
- return "ResponseStatus [Code=" + Code + ", Value=" + Value + ", Description=" + Description + "]";
+ return "ResponseStatus [Code=" + code + ", Value=" + value + ", Description=" + description + "]";
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getValue() {
+ return value;
}
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + Code;
- result = prime * result + ((Description == null) ? 0 : Description.hashCode());
- result = prime * result + ((Value == null) ? 0 : Value.hashCode());
+ result = prime * result + code;
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
+
@Override
public boolean equals(Object obj) {
if (this == obj)
@@ -52,17 +77,17 @@ public class ResponseStatus implements Serializable {
if (getClass() != obj.getClass())
return false;
ResponseStatus other = (ResponseStatus) obj;
- if (Code != other.Code)
+ if (code != other.code)
return false;
- if (Description == null) {
- if (other.Description != null)
+ if (description == null) {
+ if (other.description != null)
return false;
- } else if (!Description.equals(other.Description))
+ } else if (!description.equals(other.description))
return false;
- if (Value == null) {
- if (other.Value != null)
+ if (value == null) {
+ if (other.value != null)
return false;
- } else if (!Value.equals(other.Value))
+ } else if (!value.equals(other.value))
return false;
return true;
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
index 7bd745936..e750b60a6 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
@@ -40,6 +40,10 @@ public enum ResponseValue {
}
public static ResponseValue toResponseValue(String value) {
+ if (value == null) {
+ return null;
+ }
+
if (value.equals(ACCEPT.toString())) {
return ACCEPT;
}
diff --git a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
index 3afde0a06..6e04ee977 100644
--- a/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
@@ -33,24 +33,21 @@ import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
public final class Serialization {
-
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
private Serialization(){
}
- public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
- private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
+ public static class GSONUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(GSONUTCAdapter.class);
@Override
- public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
- throws JsonParseException {
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context) {
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (Exception e) {
@@ -63,11 +60,11 @@ public final class Serialization {
return new JsonPrimitive(datetime.format(format));
}
}
- public static class gsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ public static class GSONInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
@Override
- public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
- throws JsonParseException {
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) {
return Instant.ofEpochMilli(json.getAsLong());
}
@@ -81,8 +78,8 @@ public final class Serialization {
public static final Gson gsonPretty = new GsonBuilder()
.disableHtmlEscaping()
.setPrettyPrinting()
- .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
- .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+ .registerTypeAdapter(ZonedDateTime.class, new GSONUTCAdapter())
+ .registerTypeAdapter(Instant.class, new GSONInstantAdapter())
// .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
// .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
.create();