2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
20 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 package org.openecomp.appc.listener.demo.model;
25 import java.io.Serializable;
26 import java.util.Collection;
28 import org.json.JSONObject;
29 import org.openecomp.appc.listener.util.Mapper;
31 import com.fasterxml.jackson.annotation.JsonIgnore;
32 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
33 import com.fasterxml.jackson.annotation.JsonProperty;
34 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
35 import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
36 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
37 import com.fasterxml.jackson.databind.node.ObjectNode;
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("pg-streams")
271 private pgStreams pgStreams;
274 * @return the TenantID
277 public String getPgStreams() {
278 String r = "{\\\"pg-streams\\\": {\\\"pg-stream\\\":[";
279 boolean first = true;
280 for(pgStream p : this.pgStreams.streams){
281 String n = "{\\\"id\\\":\\\""+p.getId()+"\\\", \\\"is-enabled\\\":\\\""+p.getIsEnabled()+"\\\"}";
294 * the TenantID to set
296 public void setPgStreams(pgStreams pgStreams) {
297 this.pgStreams = pgStreams;
305 @JsonIgnoreProperties(ignoreUnknown = true)
306 public static class pgStreams {
307 @JsonProperty("pg-stream")
308 private Collection<pgStream> streams;
310 public Collection<pgStream> getStreams() {
314 public void setStreams(Collection<pgStream> streams) {
315 this.streams = streams;
320 @JsonIgnoreProperties(ignoreUnknown = true)
321 public static class pgStream{
322 public String getId() {
325 public void setId(String id) {
328 public String getIsEnabled() {
331 public void setIsEnabled(String isEnabled) {
332 this.isEnabled = isEnabled;
336 @JsonProperty("is-enabled")
337 private String isEnabled;