Initial commit for AAI-UI(sparky-backend)
[aai/sparky-be.git] / src / main / java / org / openecomp / sparky / dal / rest / OperationResult.java
1 /**
2  * ============LICENSE_START===================================================
3  * SPARKY (AAI UI service)
4  * ============================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
8  * ============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=====================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25
26 package org.openecomp.sparky.dal.rest;
27
28 /**
29  * The Class OperationResult.
30  */
31 public class OperationResult {
32
33   private String result;
34
35   private String objectId;
36   private String requestLink;
37   private String requestPayload;
38
39   private int resultCode;
40
41   private boolean resolvedLinkFromCache;
42
43   private boolean resolvedLinkFromServer;
44
45   private boolean resolvedLinkFailure;
46
47   private int numRequestRetries;
48
49   private long responseTimeInMs;
50
51   /**
52    * Reset.
53    */
54   public void reset() {
55     this.objectId = null;
56     this.result = null;
57     this.requestLink = null;
58     this.requestPayload = null;
59     this.resultCode = -1;
60     this.resolvedLinkFailure = false;
61     this.resolvedLinkFromServer = false;
62     this.resolvedLinkFromCache = false;
63     this.responseTimeInMs = 0;
64     this.numRequestRetries = 0;
65   }
66
67   public String getObjectId() {
68     return objectId;
69   }
70
71   public void setObjectId(String objectId) {
72     this.objectId = objectId;
73   }
74
75   public boolean isResolvedLinkFromCache() {
76     return resolvedLinkFromCache;
77   }
78
79   /**
80    * Was successful.
81    *
82    * @return true, if successful
83    */
84   public boolean wasSuccessful() {
85     return (resultCode > 199 && resultCode < 300);
86   }
87
88   public String getRequestLink() {
89     return requestLink;
90   }
91
92   public void setRequestLink(String requestLink) {
93     this.requestLink = requestLink;
94   }
95
96   public String getRequestPayload() {
97     return requestPayload;
98   }
99
100   public void setRequestPayload(String requestPayload) {
101     this.requestPayload = requestPayload;
102   }
103
104   public void setResolvedLinkFromCache(boolean resolvedLinkFromCache) {
105     this.resolvedLinkFromCache = resolvedLinkFromCache;
106   }
107
108   public boolean isResolvedLinkFromServer() {
109     return resolvedLinkFromServer;
110   }
111
112   public void setResolvedLinkFromServer(boolean resolvedLinkFromServer) {
113     this.resolvedLinkFromServer = resolvedLinkFromServer;
114   }
115
116   public boolean isResolvedLinkFailure() {
117     return resolvedLinkFailure;
118   }
119
120   public void setResolvedLinkFailure(boolean resolvedLinkFailure) {
121     this.resolvedLinkFailure = resolvedLinkFailure;
122   }
123
124   public String getResult() {
125     return result;
126   }
127
128   public int getResultCode() {
129     return resultCode;
130   }
131
132   public void setResultCode(int resultCode) {
133     this.resultCode = resultCode;
134   }
135
136   public void setResult(String result) {
137     this.result = result;
138   }
139   
140   /**
141    * Sets the result.
142    *
143    * @param resultCode the result code
144    * @param result the result
145    */
146   public void setResult(int resultCode, String result) {
147     this.resultCode = resultCode;
148     this.result = result;
149   }
150
151   /**
152    * Instantiates a new operation result.
153    */
154   public OperationResult() {
155     super();
156   }
157
158   /**
159    * Instantiates a new operation result.
160    *
161    * @param resultCode the result code
162    * @param result the result
163    */
164   public OperationResult(int resultCode, String result) {
165     super();
166     this.resultCode = resultCode;
167     this.result = result;
168   }
169
170   public long getResponseTimeInMs() {
171     return responseTimeInMs;
172   }
173
174   public void setResponseTimeInMs(long responseTimeInMs) {
175     this.responseTimeInMs = responseTimeInMs;
176   }
177
178   public int getNumRequestRetries() {
179     return numRequestRetries;
180   }
181
182   public void setNumRequestRetries(int numRequestRetries) {
183     this.numRequestRetries = numRequestRetries;
184   }
185
186   /* (non-Javadoc)
187    * @see java.lang.Object#toString()
188    */
189   @Override
190   public String toString() {
191     return "OperationResult [result=" + result + ", resultCode=" + resultCode
192         + ", resolvedLinkFromCache=" + resolvedLinkFromCache + ", resolvedLinkFromServer="
193         + resolvedLinkFromServer + ", resolvedLinkFailure=" + resolvedLinkFailure
194         + ", numRequestRetries=" + numRequestRetries + ", responseTimeInMs=" + responseTimeInMs
195         + "]";
196   }
197
198 }