2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017 AT&T Intellectual Property
6 * ===================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=============================================
20 * ====================================================================
22 package org.onap.music.response.jsonobjects;
24 import java.util.HashMap;
27 import org.onap.music.lockingservice.MusicLockState.LockStatus;
28 import org.onap.music.main.ResultType;
29 import org.powermock.core.spi.testresult.Result;
31 import com.datastax.driver.core.ColumnDefinitions;
32 import com.datastax.driver.core.ResultSet;
33 import com.datastax.driver.core.Row;
34 import com.datastax.driver.core.ColumnDefinitions.Definition;
36 import io.swagger.annotations.ApiModel;
37 import io.swagger.annotations.ApiModelProperty;
39 @ApiModel(value = "JsonResponse", description = "General Response JSON")
40 public class JsonResponse {
42 /* Status is required */
43 private ResultType status;
45 /* Standard informational fields */
47 private String message;
50 private String musicVersion;
53 private Map<String, HashMap<String, Object>> dataResult;
57 private LockStatus lockStatus;
58 private String lockHolder;
59 private String lockLease;
63 * Create a JSONLock Response
64 * Use setters to provide more information as in
65 * JsonLockResponse(ResultType.SUCCESS).setMessage("We did it").setLock(mylockname)
68 public JsonResponse(ResultType status) {
76 @ApiModelProperty(value = "Overall status of the response.",
77 allowableValues = "Success,Failure")
78 public ResultType getStatus() {
86 public JsonResponse setStatus(ResultType status) {
95 @ApiModelProperty(value = "Error value")
96 public String getError() {
104 public JsonResponse setError(String error) {
111 * @return the message
113 @ApiModelProperty(value = "Message value")
114 public String getMessage() {
122 public JsonResponse setMessage(String message) {
123 this.message = message;
130 * @return the music version
132 public String getMusicVersion() {
133 return this.musicVersion;
138 * @param version of music
141 public JsonResponse setMusicVersion(String version) {
142 this.musicVersion = version;
146 public Map<String, HashMap<String, Object>> getDataResult() {
147 return this.dataResult;
150 public JsonResponse setDataResult(Map<String, HashMap<String, Object>> map) {
151 this.dataResult = map;
159 public String getLock() {
167 public JsonResponse setLock(String lock) {
174 * @return the lockStatus
176 @ApiModelProperty(value = "Status of the lock")
177 public LockStatus getLockStatus() {
185 public JsonResponse setLockStatus(LockStatus lockStatus) {
186 this.lockStatus = lockStatus;
193 * @return the lockHolder
195 @ApiModelProperty(value = "Holder of the Lock")
196 public String getLockHolder() {
204 public JsonResponse setLockHolder(String lockHolder) {
205 this.lockHolder = lockHolder;
212 * @return the lockLease
214 public String getLockLease() {
219 * @param lockLease the lockLease to set
221 public JsonResponse setLockLease(String lockLease) {
222 this.lockLease = lockLease;
231 public Map<String, Object> toMap() {
232 Map<String, Object> fullMap = new HashMap<>();
233 fullMap.put("status", status);
234 if (error!=null) {fullMap.put("error", error);}
235 if (message!=null) {fullMap.put("message", message);}
237 if (musicVersion!=null) {fullMap.put("version", musicVersion);}
239 if (dataResult!=null) {
240 fullMap.put("result", dataResult);
244 Map<String, Object> lockMap = new HashMap<>();
245 if (lock!=null) {lockMap.put("lock", lock);}
246 if (lockStatus!=null) {lockMap.put("lock-status", lockStatus);}
247 if (lockHolder!=null) {lockMap.put("lock-holder", lockHolder);}
248 if (lockLease!=null) {lockMap.put("lock-lease", lockLease);}
249 fullMap.put("lock", lockMap);
259 public String toString() {
260 return "JsonLockResponse [status=" + status + ", error=" + error + ", message=" + message
261 + ", lock=" + lock + ", lockStatus=" + lockStatus + ", lockHolder="