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;
26 import io.swagger.annotations.ApiModel;
27 import io.swagger.annotations.ApiModelProperty;
29 @ApiModel(value = "JsonResponse", description = "General Response JSON")
30 public class JsonLockResponse {
32 private String status = "";
33 private String error = "";
34 private String message = "";
35 private String lock = "";
36 private String lockStatus = "";
37 private String lockHolder = "";
38 private String lockLease = "";
46 public JsonLockResponse(String status, String error, String lock) {
47 this.status = fixStatus(status);
60 public JsonLockResponse(String status, String error, String lock, String lockStatus,
62 this.status = fixStatus(status);
65 this.lockStatus = lockStatus;
66 this.lockHolder = lockHolder;
78 public JsonLockResponse(String status, String error, String lock, String lockStatus,
79 String lockHolder, String lockLease) {
80 this.status = fixStatus(status);
83 this.lockStatus = lockStatus;
84 this.lockHolder = lockHolder;
93 public String getLock() {
101 public void setLock(String lock) {
108 public JsonLockResponse() {
118 private String fixStatus(String statusIn) {
119 if (statusIn.equalsIgnoreCase("false")) {
129 @ApiModelProperty(value = "Overall status of the response.",
130 allowableValues = "Success,Failure")
131 public String getStatus() {
139 public void setStatus(String status) {
140 this.status = fixStatus(status);
147 @ApiModelProperty(value = "Error value")
148 public String getError() {
156 public void setError(String error) {
162 * @return the message
164 @ApiModelProperty(value = "Message if any need to be conveyed about the lock")
165 public String getMessage() {
173 public void setMessage(String message) {
174 this.message = message;
179 * @return the lockStatus
181 @ApiModelProperty(value = "Status of the lock",
182 allowableValues = "UNLOCKED,BEING_LOCKED,LOCKED")
183 public String getLockStatus() {
191 public void setLockStatus(String lockStatus) {
192 this.lockStatus = lockStatus;
198 * @return the lockHolder
200 @ApiModelProperty(value = "Holder of the Lock")
201 public String getLockHolder() {
209 public void setLockHolder(String lockHolder) {
210 this.lockHolder = lockHolder;
216 * @return the lockLease
218 public String getLockLease() {
223 * @param lockLease the lockLease to set
225 public void setLockLease(String lockLease) {
226 this.lockLease = lockLease;
234 public Map<String, Object> toMap() {
235 Map<String, Object> newMap = new HashMap<>();
236 Map<String, Object> lockMap = new HashMap<>();
237 lockMap.put("lock-status", lockStatus);
238 lockMap.put("lock", lock);
239 lockMap.put("message", message);
240 lockMap.put("lock-holder", lockHolder);
241 lockMap.put("lock-lease", lockLease);
242 newMap.put("status", status);
243 newMap.put("error", error);
244 newMap.put("lock", lockMap);
252 public String toString() {
253 return "JsonLockResponse [status=" + status + ", error=" + error + ", message=" + message
254 + ", lock=" + lock + ", lockStatus=" + lockStatus + ", lockHolder="