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;
29 import java.util.Collection;
31 import org.json.JSONObject;
32 import org.onap.appc.listener.util.Mapper;
34 import com.fasterxml.jackson.annotation.JsonIgnore;
35 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
36 import com.fasterxml.jackson.annotation.JsonInclude;
37 import com.fasterxml.jackson.annotation.JsonProperty;
41 * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
44 @JsonInclude(JsonInclude.Include.NON_NULL)
46 @JsonIgnoreProperties(ignoreUnknown = true)
47 public class CommonMessage implements Serializable {
49 * { "CommonHeader": { "TimeStamp": "0000-00-00T00:00:00.000Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
50 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }, "Action": "RESTART", "Payload": {
52 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
53 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
54 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
55 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
56 * "is-closed-loop-disabled": "false", "VM_NAME": "basx0001vm034", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" } }
59 private static final long serialVersionUID = 1L;
64 @JsonProperty("CommonHeader")
65 private CommonHeader header;
70 @JsonProperty("Payload")
71 private Payload payload;
74 private long startTime = System.currentTimeMillis();
80 public long getStartTime() {
84 public void setStartTime(long startTime) {
85 this.startTime = startTime;
91 public CommonHeader getHeader() {
99 public void setHeader(CommonHeader header) {
100 this.header = header;
104 * @return the payload
106 public Payload getPayload() {
114 public void setPayload(Payload payload) {
115 this.payload = payload;
119 * Convenience method to return a json representation of this object.
121 * @return The json representation of this object
123 public JSONObject toJson() {
124 return Mapper.toJsonObject(this);
127 @JsonIgnoreProperties(ignoreUnknown = true)
128 public static class CommonHeader {
130 * "CommonHeader": { "TimeStamp": "2016-05-11T13:53:53.146Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
131 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }
135 * The timestamp of the message
137 @JsonProperty("TimeStamp")
138 private String timeStamp;
141 * The API version of the message
143 @JsonProperty("APIver")
144 private String apiVer;
147 * The Originator ID of the message
149 @JsonProperty("OriginatorID")
150 private String originatorId;
153 * The Request Id of the message
155 @JsonProperty("RequestID")
156 private String requestID;
159 * The Subrequest Id of the message
161 @JsonProperty("SubRequestID")
162 private String subRequestId;
165 * @return the timeStamp
167 public String getTimeStamp() {
173 * the timeStamp to set
175 public void setTimeStamp(String timeStamp) {
176 this.timeStamp = timeStamp;
182 public String getApiVer() {
190 public void setApiVer(String apiVer) {
191 this.apiVer = apiVer;
195 * @return the originatorId
197 public String getOriginatorId() {
202 * @param originatorId
203 * the originatorId to set
205 public void setOriginatorId(String originatorId) {
206 this.originatorId = originatorId;
210 * @return the requestID
212 public String getRequestID() {
218 * the requestID to set
220 public void setRequestID(String requestID) {
221 this.requestID = requestID;
225 * @return the subRequestId
227 public String getSubRequestId() {
232 * @param subRequestId
233 * the subRequestId to set
235 public void setSubRequestId(String subRequestId) {
236 this.subRequestId = subRequestId;
240 @JsonIgnoreProperties(ignoreUnknown = true)
241 public static class Payload {
243 * "Payload": { "VServerSelfLink":
244 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
245 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
246 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
247 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
248 * "is-closed-loop-disabled": "false", "VM_NAME": "test", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" }
252 * The TenantID of the message
254 @JsonProperty("generic-vnf.vnf-id")
255 private String genericVnfId;
258 * @return the TenantID
260 public String getGenericVnfId() {
266 * the TenantID to set
268 public void setGenericVnfId(String genericVnfId) {
269 this.genericVnfId = genericVnfId;
272 @JsonProperty("streams")
273 private Streams streams;
276 * @return the TenantID
279 public String getStreams() {
280 String r = "{\\\"streams\\\": {\\\"active-streams\\\": " + streams.getActiveStreams() +
287 * the TenantID to set
289 public void setStreams(Streams streams) {
290 this.streams = streams;
298 @JsonIgnoreProperties(ignoreUnknown = true)
299 public static class Streams {
301 @JsonProperty("active-streams")
302 private int activeStreams;
304 public int getActiveStreams() {
305 return this.activeStreams;
308 public void setActiveStreams(int activeStreams) {
309 this.activeStreams = activeStreams;