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.JsonInclude;
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
26 import org.apache.commons.lang.builder.ToStringBuilder;
28 import javax.ws.rs.core.Response;
31 * This wrapper encapsulates the MSO response in the format expected by the pages.
33 @JsonInclude(JsonInclude.Include.NON_NULL)
39 public class MsoResponseWrapper implements MsoResponseWrapperInterface {
42 public MsoResponseWrapper() {
45 public MsoResponseWrapper(Response response) {
46 setEntity(response.readEntity(String.class));
47 setStatus(response.getStatus());
52 @JsonProperty("status")
56 @JsonProperty("entity")
57 private String entity;
65 @JsonProperty("entity")
66 public String getEntity() {
76 @JsonProperty("status")
77 public int getStatus() {
84 * @param v the new status
86 @JsonProperty("status")
87 public void setStatus(int v) {
94 * @param v the new entity
96 @JsonProperty("entity")
97 public void setEntity(String v) {
102 * @see java.lang.Object#toString()
105 public String toString() {
106 return ToStringBuilder.reflectionToString(this);
112 * @return the response
114 @org.codehaus.jackson.annotate.JsonIgnore
115 @com.fasterxml.jackson.annotation.JsonIgnore
116 public String getResponse () {
118 StringBuilder b = new StringBuilder ("{ \"status\": ");
119 b.append(getStatus()).append(", \"entity\": " );
120 if (this.getEntity() == null || this.getEntity().isEmpty()) {
123 b.append(this.getEntity());
126 return (b.toString());