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.JsonProperty;
36 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
37 import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
40 * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
43 @JsonSerialize(include = Inclusion.NON_NULL)
44 @JsonIgnoreProperties(ignoreUnknown = true)
45 public class CommonMessage implements Serializable {
47 * { "CommonHeader": { "TimeStamp": "0000-00-00T00:00:00.000Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
48 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }, "Action": "RESTART", "Payload": {
50 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
51 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
52 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
53 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
54 * "is-closed-loop-disabled": "false", "VM_NAME": "basx0001vm034", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" } }
57 private static final long serialVersionUID = 1L;
62 @JsonProperty("CommonHeader")
63 private CommonHeader header;
68 @JsonProperty("Payload")
69 private Payload payload;
72 private long startTime = System.currentTimeMillis();
78 public long getStartTime() {
82 public void setStartTime(long startTime) {
83 this.startTime = startTime;
89 public CommonHeader getHeader() {
97 public void setHeader(CommonHeader header) {
102 * @return the payload
104 public Payload getPayload() {
112 public void setPayload(Payload payload) {
113 this.payload = payload;
117 * Convenience method to return a json representation of this object.
119 * @return The json representation of this object
121 public JSONObject toJson() {
122 return Mapper.toJsonObject(this);
125 @JsonIgnoreProperties(ignoreUnknown = true)
126 public static class CommonHeader {
128 * "CommonHeader": { "TimeStamp": "2016-05-11T13:53:53.146Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
129 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }
133 * The timestamp of the message
135 @JsonProperty("TimeStamp")
136 private String timeStamp;
139 * The API version of the message
141 @JsonProperty("APIver")
142 private String apiVer;
145 * The Originator ID of the message
147 @JsonProperty("OriginatorID")
148 private String originatorId;
151 * The Request Id of the message
153 @JsonProperty("RequestID")
154 private String requestID;
157 * The Subrequest Id of the message
159 @JsonProperty("SubRequestID")
160 private String subRequestId;
163 * @return the timeStamp
165 public String getTimeStamp() {
171 * the timeStamp to set
173 public void setTimeStamp(String timeStamp) {
174 this.timeStamp = timeStamp;
180 public String getApiVer() {
188 public void setApiVer(String apiVer) {
189 this.apiVer = apiVer;
193 * @return the originatorId
195 public String getOriginatorId() {
200 * @param originatorId
201 * the originatorId to set
203 public void setOriginatorId(String originatorId) {
204 this.originatorId = originatorId;
208 * @return the requestID
210 public String getRequestID() {
216 * the requestID to set
218 public void setRequestID(String requestID) {
219 this.requestID = requestID;
223 * @return the subRequestId
225 public String getSubRequestId() {
230 * @param subRequestId
231 * the subRequestId to set
233 public void setSubRequestId(String subRequestId) {
234 this.subRequestId = subRequestId;
238 @JsonIgnoreProperties(ignoreUnknown = true)
239 public static class Payload {
241 * "Payload": { "VServerSelfLink":
242 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
243 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
244 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
245 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
246 * "is-closed-loop-disabled": "false", "VM_NAME": "test", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" }
250 * The TenantID of the message
252 @JsonProperty("generic-vnf.vnf-id")
253 private String genericVnfId;
256 * @return the TenantID
258 public String getGenericVnfId() {
264 * the TenantID to set
266 public void setGenericVnfId(String genericVnfId) {
267 this.genericVnfId = genericVnfId;
270 @JsonProperty("streams")
271 private Streams streams;
274 * @return the TenantID
277 public String getStreams() {
278 String r = "{\\\"streams\\\": {\\\"active-streams\\\": " + streams.getActiveStreams() +
285 * the TenantID to set
287 public void setStreams(Streams streams) {
288 this.streams = streams;
296 @JsonIgnoreProperties(ignoreUnknown = true)
297 public static class Streams {
299 @JsonProperty("active-streams")
300 private int activeStreams;
302 public int getActiveStreams() {
303 return this.activeStreams;
306 public void setActiveStreams(int activeStreams) {
307 this.activeStreams = activeStreams;