aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/model-impl/appc
diff options
context:
space:
mode:
authorGao, Chenfei (cg287m) <cgao@research.att.com>2017-06-22 14:48:41 -0400
committerPamela Dragosh <pdragosh@research.att.com>2017-06-29 12:50:23 -0400
commit68377161605e39c8c74ea77d0b504177480788f3 (patch)
treefb0fb8a27178da607866e1850f73ac056e046ee8 /controlloop/common/model-impl/appc
parentf0c29b57e132e6335f0fa7bbad885d403e4c85df (diff)
[POLICY-22] Reorganizing drools-apps
Change-Id: I5f9bb3908f8d55c466dd847ae5e01a424e9ba364 Signed-off-by: Gao, Chenfei (cg287m) <chenfei.gao11@gmail.com> Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'controlloop/common/model-impl/appc')
-rw-r--r--controlloop/common/model-impl/appc/pom.xml45
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java124
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java104
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java112
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java63
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java70
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java61
-rw-r--r--controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java82
-rw-r--r--controlloop/common/model-impl/appc/src/main/resources/definitions.yaml118
9 files changed, 779 insertions, 0 deletions
diff --git a/controlloop/common/model-impl/appc/pom.xml b/controlloop/common/model-impl/appc/pom.xml
new file mode 100644
index 000000000..ae6ff0f5f
--- /dev/null
+++ b/controlloop/common/model-impl/appc/pom.xml
@@ -0,0 +1,45 @@
+<!--
+ ============LICENSE_START=======================================================
+ Drools PDP Application Models
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>appc</artifactId>
+
+ <parent>
+ <groupId>org.onap.policy.drools-applications</groupId>
+ <artifactId>model-impl</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
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
new file mode 100644
index 000000000..4df25ecc5
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/CommonHeader.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appc;
+
+import java.io.Serializable;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collection;
+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<String>();
+ public Collection<Map<String, String>> Flags = new ArrayList<Map<String, String>>();
+
+ 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);
+ }
+ if (commonHeader.Flags != null) {
+ this.Flags.addAll(commonHeader.Flags);
+ }
+ }
+
+ @Override
+ public String toString() {
+ 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());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CommonHeader other = (CommonHeader) obj;
+ if (APIver == null) {
+ if (other.APIver != null)
+ return false;
+ } else if (!APIver.equals(other.APIver))
+ return false;
+ if (Flags == null) {
+ if (other.Flags != null)
+ return false;
+ } else if (!Flags.equals(other.Flags))
+ return false;
+ if (OriginatorID == null) {
+ if (other.OriginatorID != null)
+ return false;
+ } else if (!OriginatorID.equals(other.OriginatorID))
+ return false;
+ if (RequestID == null) {
+ if (other.RequestID != null)
+ return false;
+ } else if (!RequestID.equals(other.RequestID))
+ return false;
+ if (RequestTrack == null) {
+ if (other.RequestTrack != null)
+ return false;
+ } else if (!RequestTrack.equals(other.RequestTrack))
+ return false;
+ if (SubRequestID == null) {
+ if (other.SubRequestID != null)
+ return false;
+ } else if (!SubRequestID.equals(other.SubRequestID))
+ return false;
+ if (TimeStamp == null) {
+ if (other.TimeStamp != null)
+ return false;
+ } 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
new file mode 100644
index 000000000..fbf0d8ee5
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Request.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appc;
+
+import java.io.Serializable;
+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<String, Object>();
+
+ public Request() {
+
+ }
+
+ public CommonHeader getCommonHeader() {
+ return CommonHeader;
+ }
+
+ public Map<String, Object> getPayload() {
+ return 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());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Request other = (Request) obj;
+ if (Action == null) {
+ if (other.Action != null)
+ return false;
+ } else if (!Action.equals(other.Action))
+ return false;
+ if (CommonHeader == null) {
+ if (other.CommonHeader != null)
+ return false;
+ } else if (!CommonHeader.equals(other.CommonHeader))
+ return false;
+ if (ObjectID == null) {
+ if (other.ObjectID != null)
+ return false;
+ } else if (!ObjectID.equals(other.ObjectID))
+ return false;
+ if (Payload == null) {
+ if (other.Payload != null)
+ return false;
+ } else if (!Payload.equals(other.Payload))
+ return false;
+ if (TargetID == null) {
+ if (other.TargetID != null)
+ return false;
+ } 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 + "]";
+ }
+
+}
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
new file mode 100644
index 000000000..f9f494625
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/Response.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appc;
+
+import java.io.Serializable;
+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<String, Object>();
+
+ public Response() {
+
+ }
+
+ public Response(Request request) {
+ this.CommonHeader = new CommonHeader(request.CommonHeader);
+ if (request.Payload != null) {
+ this.Payload.putAll(request.Payload);
+ }
+ }
+
+ public CommonHeader getCommonHeader() {
+ return CommonHeader;
+ }
+
+ public void setCommonHeader(CommonHeader commonHeader) {
+ CommonHeader = commonHeader;
+ }
+
+ public ResponseStatus getStatus() {
+ return Status;
+ }
+
+ public void setStatus(ResponseStatus status) {
+ Status = status;
+ }
+
+ public Map<String, Object> getPayload() {
+ return Payload;
+ }
+
+ public void setPayload(Map<String, Object> payload) {
+ Payload = payload;
+ }
+
+ @Override
+ public String toString() {
+ 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());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Response other = (Response) obj;
+ if (CommonHeader == null) {
+ if (other.CommonHeader != null)
+ return false;
+ } else if (!CommonHeader.equals(other.CommonHeader))
+ return false;
+ if (Payload == null) {
+ if (other.Payload != null)
+ return false;
+ } else if (!Payload.equals(other.Payload))
+ return false;
+ if (Status == null) {
+ if (other.Status != null)
+ return false;
+ } 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
new file mode 100644
index 000000000..9bc9bb13e
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseCode.java
@@ -0,0 +1,63 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appc;
+
+public enum ResponseCode {
+ ACCEPT(100),
+ ERROR(200),
+ REJECT(300),
+ SUCCESS(400),
+ FAILURE(500)
+ ;
+
+ private Integer code;
+
+ private ResponseCode(int code) {
+ this.code = code;
+ }
+
+ public int getValue() {
+ return this.code;
+ }
+
+ public String toString() {
+ return Integer.toString(this.code);
+ }
+
+ public static ResponseCode toResponseCode(int code) {
+ if (code == ACCEPT.code) {
+ return ACCEPT;
+ }
+ if (code == ERROR.code) {
+ return ERROR;
+ }
+ if (code == REJECT.code) {
+ return REJECT;
+ }
+ if (code == SUCCESS.code) {
+ return SUCCESS;
+ }
+ if (code == FAILURE.code) {
+ return FAILURE;
+ }
+ return null;
+ }
+}
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
new file mode 100644
index 000000000..6319dd8ad
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseStatus.java
@@ -0,0 +1,70 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+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;
+
+ @Override
+ public String toString() {
+ return "ResponseStatus [Code=" + Code + ", Value=" + Value + ", 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());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ResponseStatus other = (ResponseStatus) obj;
+ if (Code != other.Code)
+ return false;
+ if (Description == null) {
+ if (other.Description != null)
+ return false;
+ } else if (!Description.equals(other.Description))
+ return false;
+ if (Value == null) {
+ if (other.Value != null)
+ return false;
+ } 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
new file mode 100644
index 000000000..4de0f81f9
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/ResponseValue.java
@@ -0,0 +1,61 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appc;
+
+public enum ResponseValue {
+ ACCEPT("ACCEPT"),
+ ERROR("ERROR"),
+ REJECT("REJECT"),
+ SUCCESS("SUCCESS"),
+ FAILURE("FAILURE")
+ ;
+
+ private String value;
+
+ private ResponseValue(String value) {
+ this.value = value;
+ }
+
+ public String toString() {
+ return this.value;
+ }
+
+ public static ResponseValue toResponseValue(String value) {
+ if (value.toString().equals(ACCEPT.toString())) {
+ return ACCEPT;
+ }
+ if (value.toString().equals(ERROR.toString())) {
+ return ERROR;
+ }
+ if (value.toString().equals(REJECT.toString())) {
+ return REJECT;
+ }
+ if (value.toString().equals(SUCCESS.toString())) {
+ return SUCCESS;
+ }
+ if (value.toString().equals(FAILURE.toString())) {
+ return FAILURE;
+ }
+
+ return null;
+ }
+
+}
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
new file mode 100644
index 000000000..8a801c32b
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/java/org/onap/policy/appc/util/Serialization.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * appc
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.appc.util;
+
+import java.lang.reflect.Type;
+import java.time.Instant;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+
+import com.google.gson.Gson;
+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 DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
+
+ public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+
+ public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ try {
+ return ZonedDateTime.parse(element.getAsString(), format);
+ } catch (Exception e) {
+ System.err.println(e);
+ }
+ return null;
+ }
+
+ public JsonElement serialize(ZonedDateTime datetime, Type type, JsonSerializationContext context) {
+ return new JsonPrimitive(datetime.format(format));
+ }
+ }
+ public static class gsonInstantAdapter implements JsonSerializer<Instant>, JsonDeserializer<Instant> {
+
+ @Override
+ public Instant deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ return Instant.ofEpochMilli(json.getAsLong());
+ }
+
+ @Override
+ public JsonElement serialize(Instant src, Type typeOfSrc, JsonSerializationContext context) {
+ return new JsonPrimitive(src.toEpochMilli());
+ }
+
+ }
+
+ public static final Gson gsonPretty = new GsonBuilder()
+ .disableHtmlEscaping()
+ .setPrettyPrinting()
+ .registerTypeAdapter(ZonedDateTime.class, new gsonUTCAdapter())
+ .registerTypeAdapter(Instant.class, new gsonInstantAdapter())
+// .registerTypeAdapter(CommonHeader1607.class, new gsonCommonHeaderInstance())
+// .registerTypeAdapter(ResponseStatus1607.class, new gsonResponseStatus())
+ .create();
+
+}
diff --git a/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml b/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml
new file mode 100644
index 000000000..680a9929c
--- /dev/null
+++ b/controlloop/common/model-impl/appc/src/main/resources/definitions.yaml
@@ -0,0 +1,118 @@
+###
+# ============LICENSE_START=======================================================
+# appc
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+###
+
+Request:
+ type: object
+ properties:
+ CommonHeader:
+ type: object
+ properties:
+ TimeStamp:
+ type: string
+ APIver:
+ type: string
+ value: '1.01'
+ OriginatorID:
+ type: string
+ RequestID:
+ type: string
+ pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
+ SubRequestID:
+ type: string
+ Flags:
+ type: object
+ required:
+ - TimeStamp
+ - APIver
+ - OriginatorID
+ - RequestID
+ Action:
+ type: string
+ enum:
+ - Audit
+ - ActionStatus
+ - BlockAudits
+ - Configure
+ - HealthCheck
+ - Install
+ - LiveUpgrade
+ - Migrate
+ - ModifyConfig
+ - Query
+ - Rebuild
+ - Reconfigure
+ - Restart
+ - Rollback
+ - Scale
+ - Start
+ - Stop
+ - Sync
+ - Terminate
+ - Test
+ - Upgrade
+ TargetID:
+ type: string
+ ObjectID:
+ type: string
+ Payload:
+ type: object
+ required:
+ - CommonHeader
+ - Action
+ - TargetID
+Response:
+ type: object
+ properties:
+ CommonHeader:
+ type: object
+ properties:
+ TimeStamp:
+ type: string
+ APIver:
+ type: string
+ OriginatorID:
+ type: string
+ RequestID:
+ type: string
+ SubRequestID:
+ type: string
+ Flags:
+ type: object
+ required:
+ - TimeStamp
+ - APIver
+ - OriginatorID
+ - RequestID
+ Status:
+ type: object
+ properties:
+ Code:
+ type: integer
+ Value:
+ type: string
+ required:
+ - Code
+ - Value
+ Payload:
+ type: object
+ required:
+ - CommonHeader
+ - Status
+