Moving all files to root directory
[appc.git] / appc-event-listener / appc-event-listener-bundle / src / main / java / org / openecomp / appc / listener / CL / model / IncomingMessage.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
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  */
21
22 package org.openecomp.appc.listener.CL.model;
23
24 import com.fasterxml.jackson.annotation.JsonIgnore;
25 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
26 import com.fasterxml.jackson.annotation.JsonProperty;
27 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
28 import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
29
30 /**
31  * This class reperesnts a message coming in from DCAE.
32  *
33  */
34 @JsonSerialize(include = Inclusion.NON_NULL)
35 @JsonIgnoreProperties(ignoreUnknown = true)
36 public class IncomingMessage extends CommonMessage {
37
38     private static final long serialVersionUID = 1L;
39
40     /*
41      * The action being requested. Its presence signals that it is an incoming message and it is not present on outgoing
42      * messages
43      */
44     @JsonProperty("request")
45     private String request;
46
47     /*
48      * The url for the server used for auth. http://<compute>:<port>/<tenentId>/server/<serverID>
49      */
50     @JsonProperty("VServerSelfLink")
51     private String Url;
52
53     /*
54      * The tenant Id in OpenStack that the server belongs to
55      */
56     @JsonProperty("TenantID")
57     private String TenantId;
58
59     /*
60      * The VM's UUID in 
61      */
62     @JsonProperty("VMID")
63     private String VmId;
64
65     @JsonProperty("Identity")
66     private String identityUrl;
67
68     public String getRequest() {
69         return request;
70     }
71
72     @JsonIgnore
73     public Action getAction() {
74         return Action.toAction(request);
75     }
76
77     public String getUrl() {
78         return Url;
79     }
80
81     public String getTenantId() {
82         return TenantId;
83     }
84
85     public String getVmId() {
86         return VmId;
87     }
88
89     public String getIdentityUrl() {
90         return identityUrl;
91     }
92
93     public void setUrl(String Url) {
94         this.Url = Url;
95     }
96
97     public void setTenantId(String TenantId) {
98         this.TenantId = TenantId;
99     }
100
101     public void setVmId(String VmId) {
102         this.VmId = VmId;
103     }
104
105     public void setRequest(String request) {
106         this.request = request;
107     }
108
109     public void setIdentityUrl(String identityUrl) {
110         this.identityUrl = identityUrl;
111     }
112
113     @Override
114     public String toString() {
115         String time = getRequestTime() != null ? getRequestTime() : "N/A";
116         // String req = request != null ? request : "N/A";
117         return String.format("[%s - %s]", time, getId());
118     }
119
120     public String toOutgoing(Status status) {
121         return toOutgoing(status, getMessage());
122     }
123
124     public String toOutgoing(Status status, String msg) {
125         OutgoingMessage out = new OutgoingMessage(this);
126         out.setResponse(status);
127         out.setMessage(msg);
128         return out.toResponse().toString();
129     }
130
131     /**
132      * Determines if this message should be parsed parsed. Will eventually check that the message is well formed, has
133      * all required fields, and had not exceeded any timing restrictions.
134      *
135      * @return True if the message should be parsed. False otherwise
136      */
137     public boolean isValid() {
138         return true;
139     }
140 }