2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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=========================================================
22 package org.openecomp.appc.listener.CL1607.model;
24 import java.io.Serializable;
25 import java.util.Collection;
27 import org.json.JSONObject;
28 import org.openecomp.appc.listener.util.Mapper;
30 import com.fasterxml.jackson.annotation.JsonIgnore;
31 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
32 import com.fasterxml.jackson.annotation.JsonProperty;
33 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
34 import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
35 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
36 import com.fasterxml.jackson.databind.node.ObjectNode;
39 * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
42 @JsonSerialize(include = Inclusion.NON_NULL)
43 @JsonIgnoreProperties(ignoreUnknown = true)
44 public class CommonMessage implements Serializable {
46 * { "CommonHeader": { "TimeStamp": "0000-00-00T00:00:00.000Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
47 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }, "Action": "RESTART", "Payload": {
49 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
50 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
51 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
52 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
53 * "is-closed-loop-disabled": "false", "VM_NAME": "basx0001vm034", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" } }
56 private static final long serialVersionUID = 1L;
61 @JsonProperty("CommonHeader")
62 private CommonHeader header;
67 @JsonProperty("Payload")
68 private Payload payload;
71 private long startTime = System.currentTimeMillis();
77 public long getStartTime() {
81 public void setStartTime(long startTime) {
82 this.startTime = startTime;
88 public CommonHeader getHeader() {
96 public void setHeader(CommonHeader header) {
101 * @return the payload
103 public Payload getPayload() {
111 public void setPayload(Payload payload) {
112 this.payload = payload;
116 * Convenience method to return a json representation of this object.
118 * @return The json representation of this object
120 public JSONObject toJson() {
121 return Mapper.toJsonObject(this);
124 @JsonIgnoreProperties(ignoreUnknown = true)
125 public static class CommonHeader {
127 * "CommonHeader": { "TimeStamp": "2016-05-11T13:53:53.146Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
128 * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }
132 * The timestamp of the message
134 @JsonProperty("TimeStamp")
135 private String timeStamp;
138 * The API version of the message
140 @JsonProperty("APIver")
141 private String apiVer;
144 * The Originator ID of the message
146 @JsonProperty("OriginatorID")
147 private String originatorId;
150 * The Request Id of the message
152 @JsonProperty("RequestID")
153 private String requestID;
156 * The Subrequest Id of the message
158 @JsonProperty("SubrequestID")
159 private String subRequestId;
162 * @return the timeStamp
164 public String getTimeStamp() {
170 * the timeStamp to set
172 public void setTimeStamp(String timeStamp) {
173 this.timeStamp = timeStamp;
179 public String getApiVer() {
187 public void setApiVer(String apiVer) {
188 this.apiVer = apiVer;
192 * @return the originatorId
194 public String getOriginatorId() {
199 * @param originatorId
200 * the originatorId to set
202 public void setOriginatorId(String originatorId) {
203 this.originatorId = originatorId;
207 * @return the requestID
209 public String getRequestID() {
215 * the requestID to set
217 public void setRequestID(String requestID) {
218 this.requestID = requestID;
222 * @return the subRequestId
224 public String getSubRequestId() {
229 * @param subRequestId
230 * the subRequestId to set
232 public void setSubRequestId(String subRequestId) {
233 this.subRequestId = subRequestId;
237 @JsonIgnoreProperties(ignoreUnknown = true)
238 public static class Payload {
240 * "Payload": { "VServerSelfLink":
241 * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
242 * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
243 * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
244 * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
245 * "is-closed-loop-disabled": "false", "VM_NAME": "test", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" }
249 * The TenantID of the message
251 @JsonProperty("generic-vnf.vnf-id")
252 private String genericVnfId;
255 * @return the TenantID
257 public String getGenericVnfId() {
263 * the TenantID to set
265 public void setGenericVnfId(String genericVnfId) {
266 this.genericVnfId = genericVnfId;
269 @JsonProperty("pg-streams")
270 private pgStreams pgStreams;
273 * @return the TenantID
276 public String getPgStreams() {
277 String r = "{\\\"pg-streams\\\": {\\\"pg-stream\\\":[";
278 boolean first = true;
279 for(pgStream p : this.pgStreams.streams){
280 String n = "{\\\"id\\\":\\\""+p.getId()+"\\\", \\\"is-enabled\\\":\\\""+p.getIsEnabled()+"\\\"}";
293 * the TenantID to set
295 public void setPgStreams(pgStreams pgStreams) {
296 this.pgStreams = pgStreams;
304 @JsonIgnoreProperties(ignoreUnknown = true)
305 public static class pgStreams {
306 @JsonProperty("pg-stream")
307 private Collection<pgStream> streams;
309 public Collection<pgStream> getStreams() {
313 public void setStreams(Collection<pgStream> streams) {
314 this.streams = streams;
319 @JsonIgnoreProperties(ignoreUnknown = true)
320 public static class pgStream{
321 public String getId() {
324 public void setId(String id) {
327 public String getIsEnabled() {
330 public void setIsEnabled(String isEnabled) {
331 this.isEnabled = isEnabled;
335 @JsonProperty("is-enabled")
336 private String isEnabled;