2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * ================================================================================
9 * Modifications Copyright (C) 2019 Ericsson
10 * =============================================================================
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
23 * ============LICENSE_END=========================================================
26 package org.onap.appc.listener.demo.model;
28 import java.io.Serializable;
30 import org.json.JSONObject;
31 import org.onap.appc.listener.util.Mapper;
33 import com.fasterxml.jackson.annotation.JsonIgnore;
34 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
35 import com.fasterxml.jackson.annotation.JsonInclude;
36 import com.fasterxml.jackson.annotation.JsonProperty;
40 * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
43 @JsonInclude(JsonInclude.Include.NON_NULL)
45 @JsonIgnoreProperties(ignoreUnknown = true)
46 public class CommonMessage implements Serializable {
48 * { "CommonHeader": { "TimeStamp": "0000-00-00T00:00:00.000Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
49 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }, "Action": "RESTART", "Payload": {
51 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
52 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
53 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
54 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
55 * "is-closed-loop-disabled": "false", "VM_NAME": "basx0001vm034", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" } }
58 private static final long serialVersionUID = 1L;
63 @JsonProperty("CommonHeader")
64 private CommonHeader header;
69 @JsonProperty("Payload")
70 private Payload payload;
73 private long startTime = System.currentTimeMillis();
79 public long getStartTime() {
83 public void setStartTime(long startTime) {
84 this.startTime = startTime;
90 public CommonHeader getHeader() {
98 public void setHeader(CommonHeader header) {
103 * @return the payload
105 public Payload getPayload() {
113 public void setPayload(Payload payload) {
114 this.payload = payload;
118 * Convenience method to return a json representation of this object.
120 * @return The json representation of this object
122 public JSONObject toJson() {
123 return Mapper.toJsonObject(this);
126 @JsonIgnoreProperties(ignoreUnknown = true)
127 public static class CommonHeader {
129 * "CommonHeader": { "TimeStamp": "2016-05-11T13:53:53.146Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
130 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }
134 * The timestamp of the message
136 @JsonProperty("TimeStamp")
137 private String timeStamp;
140 * The API version of the message
142 @JsonProperty("APIver")
143 private String apiVer;
146 * The Originator ID of the message
148 @JsonProperty("OriginatorID")
149 private String originatorId;
152 * The Request Id of the message
154 @JsonProperty("RequestID")
155 private String requestID;
158 * The Subrequest Id of the message
160 @JsonProperty("SubRequestID")
161 private String subRequestId;
164 * @return the timeStamp
166 public String getTimeStamp() {
172 * the timeStamp to set
174 public void setTimeStamp(String timeStamp) {
175 this.timeStamp = timeStamp;
181 public String getApiVer() {
189 public void setApiVer(String apiVer) {
190 this.apiVer = apiVer;
194 * @return the originatorId
196 public String getOriginatorId() {
201 * @param originatorId
202 * the originatorId to set
204 public void setOriginatorId(String originatorId) {
205 this.originatorId = originatorId;
209 * @return the requestID
211 public String getRequestID() {
217 * the requestID to set
219 public void setRequestID(String requestID) {
220 this.requestID = requestID;
224 * @return the subRequestId
226 public String getSubRequestId() {
231 * @param subRequestId
232 * the subRequestId to set
234 public void setSubRequestId(String subRequestId) {
235 this.subRequestId = subRequestId;
239 @JsonIgnoreProperties(ignoreUnknown = true)
240 public static class Payload {
242 * "Payload": { "VServerSelfLink":
243 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
244 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
245 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
246 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
247 * "is-closed-loop-disabled": "false", "VM_NAME": "test", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" }
251 * The TenantID of the message
253 @JsonProperty("generic-vnf.vnf-id")
254 private String genericVnfId;
257 * @return the TenantID
259 public String getGenericVnfId() {
265 * the TenantID to set
267 public void setGenericVnfId(String genericVnfId) {
268 this.genericVnfId = genericVnfId;
271 @JsonProperty("streams")
272 private Streams streams;
275 * @return the TenantID
278 public String getStreams() {
279 String r = "{\\\"streams\\\": {\\\"active-streams\\\": " + streams.getActiveStreams() +
286 * the TenantID to set
288 public void setStreams(Streams streams) {
289 this.streams = streams;
297 @JsonIgnoreProperties(ignoreUnknown = true)
298 public static class Streams {
300 @JsonProperty("active-streams")
301 private int activeStreams;
303 public int getActiveStreams() {
304 return this.activeStreams;
307 public void setActiveStreams(int activeStreams) {
308 this.activeStreams = activeStreams;