Merge "Fix Blocker/Critical sonar issues"
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / dal / rest / OperationResult.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 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  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.onap.aai.sparky.dal.rest;
24
25 /**
26  * The Class OperationResult.
27  */
28 public class OperationResult {
29
30   private String result;
31
32   private String objectId;
33   private String requestLink;
34   private String requestPayload;
35
36   private int resultCode;
37
38   private boolean resolvedLinkFromCache;
39
40   private boolean resolvedLinkFromServer;
41
42   private boolean resolvedLinkFailure;
43
44   private int numRequestRetries;
45
46   private long responseTimeInMs;
47
48   /**
49    * Reset.
50    */
51   public void reset() {
52     this.objectId = null;
53     this.result = null;
54     this.requestLink = null;
55     this.requestPayload = null;
56     this.resultCode = -1;
57     this.resolvedLinkFailure = false;
58     this.resolvedLinkFromServer = false;
59     this.resolvedLinkFromCache = false;
60     this.responseTimeInMs = 0;
61     this.numRequestRetries = 0;
62   }
63
64   public String getObjectId() {
65     return objectId;
66   }
67
68   public void setObjectId(String objectId) {
69     this.objectId = objectId;
70   }
71
72   public boolean isResolvedLinkFromCache() {
73     return resolvedLinkFromCache;
74   }
75
76   /**
77    * Was successful.
78    *
79    * @return true, if successful
80    */
81   public boolean wasSuccessful() {
82     return (resultCode > 199 && resultCode < 300);
83   }
84
85   public String getRequestLink() {
86     return requestLink;
87   }
88
89   public void setRequestLink(String requestLink) {
90     this.requestLink = requestLink;
91   }
92
93   public String getRequestPayload() {
94     return requestPayload;
95   }
96
97   public void setRequestPayload(String requestPayload) {
98     this.requestPayload = requestPayload;
99   }
100
101   public void setResolvedLinkFromCache(boolean resolvedLinkFromCache) {
102     this.resolvedLinkFromCache = resolvedLinkFromCache;
103   }
104
105   public boolean isResolvedLinkFromServer() {
106     return resolvedLinkFromServer;
107   }
108
109   public void setResolvedLinkFromServer(boolean resolvedLinkFromServer) {
110     this.resolvedLinkFromServer = resolvedLinkFromServer;
111   }
112
113   public boolean isResolvedLinkFailure() {
114     return resolvedLinkFailure;
115   }
116
117   public void setResolvedLinkFailure(boolean resolvedLinkFailure) {
118     this.resolvedLinkFailure = resolvedLinkFailure;
119   }
120
121   public String getResult() {
122     return result;
123   }
124
125   public int getResultCode() {
126     return resultCode;
127   }
128
129   public void setResultCode(int resultCode) {
130     this.resultCode = resultCode;
131   }
132
133   public void setResult(String result) {
134     this.result = result;
135   }
136   
137   /**
138    * Sets the result.
139    *
140    * @param resultCode the result code
141    * @param result the result
142    */
143   public void setResult(int resultCode, String result) {
144     this.resultCode = resultCode;
145     this.result = result;
146   }
147
148   /**
149    * Instantiates a new operation result.
150    */
151   public OperationResult() {
152     super();
153   }
154
155   /**
156    * Instantiates a new operation result.
157    *
158    * @param resultCode the result code
159    * @param result the result
160    */
161   public OperationResult(int resultCode, String result) {
162     super();
163     this.resultCode = resultCode;
164     this.result = result;
165   }
166
167   public long getResponseTimeInMs() {
168     return responseTimeInMs;
169   }
170
171   public void setResponseTimeInMs(long responseTimeInMs) {
172     this.responseTimeInMs = responseTimeInMs;
173   }
174
175   public int getNumRequestRetries() {
176     return numRequestRetries;
177   }
178
179   public void setNumRequestRetries(int numRequestRetries) {
180     this.numRequestRetries = numRequestRetries;
181   }
182
183   /* (non-Javadoc)
184    * @see java.lang.Object#toString()
185    */
186   @Override
187   public String toString() {
188     return "OperationResult [result=" + result + ", resultCode=" + resultCode
189         + ", resolvedLinkFromCache=" + resolvedLinkFromCache + ", resolvedLinkFromServer="
190         + resolvedLinkFromServer + ", resolvedLinkFailure=" + resolvedLinkFailure
191         + ", numRequestRetries=" + numRequestRetries + ", responseTimeInMs=" + responseTimeInMs
192         + "]";
193   }
194
195 }