2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.mso;
23 import com.fasterxml.jackson.annotation.JsonIgnore;
24 import com.fasterxml.jackson.annotation.JsonInclude;
25 import com.fasterxml.jackson.annotation.JsonProperty;
26 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
27 import org.apache.commons.lang.builder.ToStringBuilder;
29 import javax.ws.rs.core.Response;
32 * This wrapper encapsulates the MSO response in the format expected by the pages.
34 @JsonInclude(JsonInclude.Include.NON_NULL)
40 public class MsoResponseWrapper implements MsoResponseWrapperInterface {
43 public MsoResponseWrapper() {
46 public MsoResponseWrapper(Response response) {
47 setEntity(response.readEntity(String.class));
48 setStatus(response.getStatus());
51 public MsoResponseWrapper(int status, String entity) {
57 @JsonProperty("status")
61 @JsonProperty("entity")
62 private String entity;
70 @JsonProperty("entity")
71 public String getEntity() {
81 @JsonProperty("status")
82 public int getStatus() {
89 * @param v the new status
91 @JsonProperty("status")
92 public void setStatus(int v) {
99 * @param v the new entity
101 @JsonProperty("entity")
102 public void setEntity(String v) {
107 * @see java.lang.Object#toString()
110 public String toString() {
111 return ToStringBuilder.reflectionToString(this);
117 * @return the response
120 public String getResponse () {
122 StringBuilder b = new StringBuilder ("{ \"status\": ");
123 b.append(getStatus()).append(", \"entity\": " );
124 if (this.getEntity() == null || this.getEntity().isEmpty()) {
127 b.append(this.getEntity());
130 return (b.toString());