Updating licenses in all files
[appc.git] / appc-event-listener / appc-event-listener-bundle / src / main / java / org / openecomp / appc / listener / demo / model / CommonMessage.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * APPC
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
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
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.
21  */
22
23 package org.openecomp.appc.listener.demo.model;
24
25 import java.io.Serializable;
26 import java.util.Collection;
27
28 import org.json.JSONObject;
29 import org.openecomp.appc.listener.util.Mapper;
30
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;
38
39 /**
40  * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
41  *
42  */
43 @JsonSerialize(include = Inclusion.NON_NULL)
44 @JsonIgnoreProperties(ignoreUnknown = true)
45 public class CommonMessage implements Serializable {
46     /*
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": {
49      * "VServerSelfLink":
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" } }
55      */
56
57     private static final long serialVersionUID = 1L;
58
59     /*
60      * The common header
61      */
62     @JsonProperty("CommonHeader")
63     private CommonHeader header;
64
65     /*
66      * The payload
67      */
68     @JsonProperty("Payload")    
69     private Payload payload;
70
71     @JsonIgnore
72     private long startTime = System.currentTimeMillis();
73
74     /*
75      * Getters and Setters
76      */
77
78     public long getStartTime() {
79         return startTime;
80     }
81
82     public void setStartTime(long startTime) {
83         this.startTime = startTime;
84     }
85
86     /**
87      * @return the header
88      */
89     public CommonHeader getHeader() {
90         return header;
91     }
92
93     /**
94      * @param header
95      *            the header to set
96      */
97     public void setHeader(CommonHeader header) {
98         this.header = header;
99     }
100
101     /**
102      * @return the payload
103      */
104     public Payload getPayload() {
105         return payload;
106     }
107
108     /**
109      * @param payload
110      *            the payload to set
111      */
112     public void setPayload(Payload payload) {
113         this.payload = payload;
114     }
115
116     /**
117      * Convenience method to return a json representation of this object.
118      * 
119      * @return The json representation of this object
120      */
121     public JSONObject toJson() {
122         return Mapper.toJsonObject(this);
123     }
124
125     @JsonIgnoreProperties(ignoreUnknown = true)
126     public static class CommonHeader {
127         /*
128          * "CommonHeader": { "TimeStamp": "2016-05-11T13:53:53.146Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
129          * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }
130          */
131
132         /*
133          * The timestamp of the message
134          */
135         @JsonProperty("TimeStamp")
136         private String timeStamp;
137
138         /*
139          * The API version of the message
140          */
141         @JsonProperty("APIver")
142         private String apiVer;
143
144         /*
145          * The Originator ID of the message
146          */
147         @JsonProperty("OriginatorID")
148         private String originatorId;
149
150         /*
151          * The Request Id of the message
152          */
153         @JsonProperty("RequestID")
154         private String requestID;
155
156         /*
157          * The Subrequest Id of the message
158          */
159         @JsonProperty("SubrequestID")
160         private String subRequestId;
161
162         /**
163          * @return the timeStamp
164          */
165         public String getTimeStamp() {
166             return timeStamp;
167         }
168
169         /**
170          * @param timeStamp
171          *            the timeStamp to set
172          */
173         public void setTimeStamp(String timeStamp) {
174             this.timeStamp = timeStamp;
175         }
176
177         /**
178          * @return the apiVer
179          */
180         public String getApiVer() {
181             return apiVer;
182         }
183
184         /**
185          * @param apiVer
186          *            the apiVer to set
187          */
188         public void setApiVer(String apiVer) {
189             this.apiVer = apiVer;
190         }
191
192         /**
193          * @return the originatorId
194          */
195         public String getOriginatorId() {
196             return originatorId;
197         }
198
199         /**
200          * @param originatorId
201          *            the originatorId to set
202          */
203         public void setOriginatorId(String originatorId) {
204             this.originatorId = originatorId;
205         }
206
207         /**
208          * @return the requestID
209          */
210         public String getRequestID() {
211             return requestID;
212         }
213
214         /**
215          * @param requestID
216          *            the requestID to set
217          */
218         public void setRequestID(String requestID) {
219             this.requestID = requestID;
220         }
221
222         /**
223          * @return the subRequestId
224          */
225         public String getSubRequestId() {
226             return subRequestId;
227         }
228
229         /**
230          * @param subRequestId
231          *            the subRequestId to set
232          */
233         public void setSubRequestId(String subRequestId) {
234             this.subRequestId = subRequestId;
235         }
236     };
237
238     @JsonIgnoreProperties(ignoreUnknown = true)
239     public static class Payload {
240         /*
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" }
247          */
248
249         /*
250          * The TenantID of the message
251          */
252         @JsonProperty("generic-vnf.vnf-id")
253         private String genericVnfId;
254
255         /**
256          * @return the TenantID
257          */
258         public String getGenericVnfId() {
259             return genericVnfId;
260         }
261
262         /**
263          * @param TenantID
264          *            the TenantID to set
265          */
266         public void setGenericVnfId(String genericVnfId) {
267             this.genericVnfId = genericVnfId;
268         }
269         
270         @JsonProperty("pg-streams")
271         private pgStreams pgStreams;
272
273         /**
274          * @return the TenantID
275          */
276
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()+"\\\"}";
282                 if(!first){
283                         r = r.concat(",");
284                 }
285                 first = false;
286                 r = r.concat(n);
287             }
288            r=  r.concat("]}}");
289             return r;
290         }
291
292         /**
293          * @param TenantID
294          *            the TenantID to set
295          */
296         public void setPgStreams(pgStreams pgStreams) {
297             this.pgStreams = pgStreams;
298         }
299
300
301
302
303
304     };
305     @JsonIgnoreProperties(ignoreUnknown = true)
306     public static class pgStreams {
307         @JsonProperty("pg-stream")
308         private Collection<pgStream> streams;
309         
310         public Collection<pgStream> getStreams() {
311                         return streams;
312                 }
313
314                 public void setStreams(Collection<pgStream> streams) {
315                         this.streams = streams;
316                 }
317
318
319     };
320         @JsonIgnoreProperties(ignoreUnknown = true)
321         public static class pgStream{
322         public String getId() {
323                         return id;
324                 }
325                 public void setId(String id) {
326                         this.id = id;
327                 }
328                 public String getIsEnabled() {
329                         return isEnabled;
330                 }
331                 public void setIsEnabled(String isEnabled) {
332                         this.isEnabled = isEnabled;
333                 }
334                 @JsonProperty("id")
335         private String id;
336         @JsonProperty("is-enabled")
337         private String isEnabled;
338         };
339
340
341 }