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 io.swagger.annotations.ApiModel;
32 import io.swagger.annotations.ApiModelProperty;
34 @ApiModel(value = "JsonResponse", description = "General Response JSON")
35 public class JsonLockResponse {
37 private ResultType status;
39 private String message;
41 private LockStatus lockStatus;
42 private String lockHolder;
43 private String lockLease;
47 * Create a JSONLock Response
48 * Use setters to provide more information as in
49 * JsonLockResponse(ResultType.SUCCESS).setMessage("We did it").setLock(mylockname)
52 public JsonLockResponse(ResultType status) {
62 public String getLock() {
70 public JsonLockResponse setLock(String lock) {
79 @ApiModelProperty(value = "Overall status of the response.",
80 allowableValues = "Success,Failure")
81 public ResultType getStatus() {
89 public JsonLockResponse setStatus(ResultType status) {
98 @ApiModelProperty(value = "Error value")
99 public String getError() {
107 public JsonLockResponse setError(String error) {
114 * @return the message
116 @ApiModelProperty(value = "Message if any need to be conveyed about the lock")
117 public String getMessage() {
125 public JsonLockResponse setMessage(String message) {
126 this.message = message;
132 * @return the lockStatus
134 @ApiModelProperty(value = "Status of the lock")
135 public LockStatus getLockStatus() {
143 public JsonLockResponse setLockStatus(LockStatus lockStatus) {
144 this.lockStatus = lockStatus;
151 * @return the lockHolder
153 @ApiModelProperty(value = "Holder of the Lock")
154 public String getLockHolder() {
162 public JsonLockResponse setLockHolder(String lockHolder) {
163 this.lockHolder = lockHolder;
170 * @return the lockLease
172 public String getLockLease() {
177 * @param lockLease the lockLease to set
179 public JsonLockResponse setLockLease(String lockLease) {
180 this.lockLease = lockLease;
189 public Map<String, Object> toMap() {
190 Map<String, Object> fullMap = new HashMap<>();
191 Map<String, Object> lockMap = new HashMap<>();
192 if (lockStatus!=null) {lockMap.put("lock-status", lockStatus); }
193 if (lock!=null) {lockMap.put("lock", lock);}
194 if (message!=null) {lockMap.put("message", message);}
195 if (lockHolder!=null) {lockMap.put("lock-holder", lockHolder);}
196 if (lockLease!=null) {lockMap.put("lock-lease", lockLease);}
198 fullMap.put("status", status);
199 fullMap.put("lock", lockMap);
200 if (error!=null) {fullMap.put("error", error);}
208 public String toString() {
209 return "JsonLockResponse [status=" + status + ", error=" + error + ", message=" + message
210 + ", lock=" + lock + ", lockStatus=" + lockStatus + ", lockHolder="