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;
31 import io.swagger.annotations.ApiModel;
32 import io.swagger.annotations.ApiModelProperty;
34 @ApiModel(value = "JsonResponse", description = "General Response JSON")
35 public class JsonResponse {
37 /* Status is required */
38 private ResultType status;
40 /* Standard informational fields */
42 private String message;
45 private String musicVersion;
48 private Map<String, HashMap<String, Object>> dataResult;
52 private LockStatus lockStatus;
53 private String lockHolder;
54 private String lockLease;
58 * Create a JSONLock Response
59 * Use setters to provide more information as in
60 * JsonLockResponse(ResultType.SUCCESS).setMessage("We did it").setLock(mylockname)
63 public JsonResponse(ResultType status) {
71 @ApiModelProperty(value = "Overall status of the response.",
72 allowableValues = "Success,Failure")
73 public ResultType getStatus() {
81 public JsonResponse setStatus(ResultType status) {
90 @ApiModelProperty(value = "Error value")
91 public String getError() {
99 public JsonResponse setError(String error) {
106 * @return the message
108 @ApiModelProperty(value = "Message value")
109 public String getMessage() {
117 public JsonResponse setMessage(String message) {
118 this.message = message;
125 * @return the music version
127 public String getMusicVersion() {
128 return this.musicVersion;
133 * @param version of music
136 public JsonResponse setMusicVersion(String version) {
137 this.musicVersion = version;
141 public Map<String, HashMap<String, Object>> getDataResult() {
142 return this.dataResult;
145 public JsonResponse setDataResult(Map<String, HashMap<String, Object>> map) {
146 this.dataResult = map;
154 public String getLock() {
162 public JsonResponse setLock(String lock) {
169 * @return the lockStatus
171 @ApiModelProperty(value = "Status of the lock")
172 public LockStatus getLockStatus() {
180 public JsonResponse setLockStatus(LockStatus lockStatus) {
181 this.lockStatus = lockStatus;
188 * @return the lockHolder
190 @ApiModelProperty(value = "Holder of the Lock")
191 public String getLockHolder() {
199 public JsonResponse setLockHolder(String lockHolder) {
200 this.lockHolder = lockHolder;
207 * @return the lockLease
209 public String getLockLease() {
214 * @param lockLease the lockLease to set
216 public JsonResponse setLockLease(String lockLease) {
217 this.lockLease = lockLease;
226 public Map<String, Object> toMap() {
227 Map<String, Object> fullMap = new HashMap<>();
228 fullMap.put("status", status);
230 fullMap.put("error", error);
233 fullMap.put("message", message);
236 if (musicVersion!=null) {
237 fullMap.put("version", musicVersion);
240 if (dataResult!=null) {
241 fullMap.put("result", dataResult);
245 Map<String, Object> lockMap = new HashMap<>();
247 lockMap.put("lock", lock);
249 if (lockStatus!=null) {
250 lockMap.put("lock-status", lockStatus);
252 if (lockHolder!=null) {
253 lockMap.put("lock-holder", lockHolder);
255 if (lockLease!=null) {
256 lockMap.put("lock-lease", lockLease);
258 fullMap.put("lock", lockMap);
268 public String toString() {
269 return "JsonLockResponse [status=" + status + ", error=" + error + ", message=" + message
270 + ", lock=" + lock + ", lockStatus=" + lockStatus + ", lockHolder="