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.CL.model;
 
  24 import java.io.Serializable;
 
  26 import org.json.JSONObject;
 
  27 import org.openecomp.appc.listener.util.Mapper;
 
  29 import com.fasterxml.jackson.annotation.JsonIgnore;
 
  30 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 
  31 import com.fasterxml.jackson.annotation.JsonProperty;
 
  32 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 
  33 import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
 
  36  * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
 
  39 @JsonSerialize(include = Inclusion.NON_NULL)
 
  40 @JsonIgnoreProperties(ignoreUnknown = true)
 
  41 public class CommonMessage implements Serializable {
 
  43     private static final long serialVersionUID = 1L;
 
  46      * The unique id of the event as of 1602
 
  48     @JsonProperty("eventID")
 
  52      * The time that the request was sent out.
 
  54     @JsonProperty("requestTime")
 
  55     private String requestTime;
 
  58      * The originator of the event
 
  60     @JsonProperty("requestClient")
 
  61     private String requestClient;
 
  64      * The system that sent the message
 
  67     private String fromSystem;
 
  70      * The actual trap message
 
  72     @JsonProperty("message")
 
  73     private String message;
 
  76      * The vm name associated with the event
 
  78     @JsonProperty("VMName")
 
  79     private String vmName;
 
  82      * The policy name on the incoming event
 
  84     @JsonProperty("policyName")
 
  85     private String policyName;
 
  88      * The policy version on the incoming event
 
  90     @JsonProperty("policyVersion")
 
  91     private String policyVersion;
 
  94     private long startTime = System.currentTimeMillis();
 
 100     public String getId() {
 
 104     public String getRequestTime() {
 
 108     public String getRequestClient() {
 
 109         return requestClient;
 
 112     public String getFromSystem() {
 
 116     public String getMessage() {
 
 120     public String getPolicyName() {
 
 124     public String getPolicyVersion() {
 
 125         return policyVersion;
 
 128     public String getVmName() {
 
 132     public long getStartTime() {
 
 136     public void setId(String eventId) {
 
 140     public void setRequestTime(String requestTime) {
 
 141         this.requestTime = requestTime;
 
 144     public void setRequestClient(String requestClient) {
 
 145         this.requestClient = requestClient;
 
 148     public void setFromSystem(String fromSystem) {
 
 149         this.fromSystem = fromSystem;
 
 152     public void setMessage(String message) {
 
 153         this.message = message;
 
 156     public void setPolicyName(String name) {
 
 160     public void setPolicyVersion(String version) {
 
 161         policyVersion = version;
 
 164     public void setVmName(String vmName) {
 
 165         this.vmName = vmName;
 
 168     public void setStartTime(long startTime) {
 
 169         this.startTime = startTime;
 
 173      * Convenience method to return a json representation of this object.
 
 175      * @return The json representation of this object
 
 177     public JSONObject toJson() {
 
 178         return Mapper.toJsonObject(this);