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 * ====================================================================
23 package org.onap.music.response.jsonobjects;
25 import java.util.HashMap;
28 import org.onap.music.lockingservice.MusicLockState.LockStatus;
29 import org.onap.music.main.ResultType;
30 import org.powermock.core.spi.testresult.Result;
32 import com.datastax.driver.core.ColumnDefinitions;
33 import com.datastax.driver.core.ResultSet;
34 import com.datastax.driver.core.Row;
35 import com.datastax.driver.core.ColumnDefinitions.Definition;
37 import io.swagger.annotations.ApiModel;
38 import io.swagger.annotations.ApiModelProperty;
40 @ApiModel(value = "JsonResponse", description = "General Response JSON")
41 public class JsonResponse {
43 /* Status is required */
44 private ResultType status;
46 /* Standard informational fields */
48 private String message;
51 private String musicVersion;
54 private Map<String, HashMap<String, Object>> dataResult;
58 private LockStatus lockStatus;
59 private String lockHolder;
60 private String lockLease;
64 * Create a JSONLock Response
65 * Use setters to provide more information as in
66 * JsonLockResponse(ResultType.SUCCESS).setMessage("We did it").setLock(mylockname)
69 public JsonResponse(ResultType status) {
77 @ApiModelProperty(value = "Overall status of the response.",
78 allowableValues = "Success,Failure")
79 public ResultType getStatus() {
87 public JsonResponse setStatus(ResultType status) {
96 @ApiModelProperty(value = "Error value")
97 public String getError() {
105 public JsonResponse setError(String error) {
112 * @return the message
114 @ApiModelProperty(value = "Message value")
115 public String getMessage() {
123 public JsonResponse setMessage(String message) {
124 this.message = message;
131 * @return the music version
133 public String getMusicVersion() {
134 return this.musicVersion;
139 * @param version of music
142 public JsonResponse setMusicVersion(String version) {
143 this.musicVersion = version;
147 public Map<String, HashMap<String, Object>> getDataResult() {
148 return this.dataResult;
151 public JsonResponse setDataResult(Map<String, HashMap<String, Object>> map) {
152 this.dataResult = map;
160 public String getLock() {
168 public JsonResponse setLock(String lock) {
175 * @return the lockStatus
177 @ApiModelProperty(value = "Status of the lock")
178 public LockStatus getLockStatus() {
186 public JsonResponse setLockStatus(LockStatus lockStatus) {
187 this.lockStatus = lockStatus;
194 * @return the lockHolder
196 @ApiModelProperty(value = "Holder of the Lock")
197 public String getLockHolder() {
205 public JsonResponse setLockHolder(String lockHolder) {
206 this.lockHolder = lockHolder;
213 * @return the lockLease
215 public String getLockLease() {
220 * @param lockLease the lockLease to set
222 public JsonResponse setLockLease(String lockLease) {
223 this.lockLease = lockLease;
232 public Map<String, Object> toMap() {
233 Map<String, Object> fullMap = new HashMap<>();
234 fullMap.put("status", status);
235 if (error!=null) {fullMap.put("error", error);}
236 if (message!=null) {fullMap.put("message", message);}
238 if (musicVersion!=null) {fullMap.put("version", musicVersion);}
240 if (dataResult!=null) {
241 fullMap.put("result", dataResult);
245 Map<String, Object> lockMap = new HashMap<>();
246 if (lock!=null) {lockMap.put("lock", lock);}
247 if (lockStatus!=null) {lockMap.put("lock-status", lockStatus);}
248 if (lockHolder!=null) {lockMap.put("lock-holder", lockHolder);}
249 if (lockLease!=null) {lockMap.put("lock-lease", lockLease);}
250 fullMap.put("lock", lockMap);
260 public String toString() {
261 return "JsonLockResponse [status=" + status + ", error=" + error + ", message=" + message
262 + ", lock=" + lock + ", lockStatus=" + lockStatus + ", lockHolder="