2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 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.policy.controlloop.actor.so;
23 import java.lang.annotation.Annotation;
25 import java.util.Date;
26 import java.util.Locale;
29 import javax.ws.rs.core.EntityTag;
30 import javax.ws.rs.core.GenericType;
31 import javax.ws.rs.core.Link;
32 import javax.ws.rs.core.Link.Builder;
33 import javax.ws.rs.core.MediaType;
34 import javax.ws.rs.core.MultivaluedMap;
35 import javax.ws.rs.core.NewCookie;
36 import javax.ws.rs.core.Response;
38 import org.onap.policy.common.utils.coder.Coder;
39 import org.onap.policy.common.utils.coder.CoderException;
42 * RestManager Response suitable for use with subclasses of HttpOperation. Only a couple
43 * of methods are implemented; the rest throw {@link UnsupportedOperationException}.
45 public class RestManagerResponse extends Response {
46 // TODO move to actorServices
49 private final int status;
51 private final String body;
52 private final Coder coder;
55 * Constructs the object.
57 * @param status HTTP response status code
58 * @param body response body
59 * @param coder coder to decode the entity body
61 public RestManagerResponse(int status, String body, Coder coder) {
73 public <T> T readEntity(Class<T> entityType) {
74 if (entityType == String.class) {
75 return entityType.cast(body);
79 return coder.decode(body, entityType);
80 } catch (CoderException e) {
81 throw new IllegalArgumentException("cannot decode response", e);
86 public <T> T readEntity(GenericType<T> entityType) {
87 throw new UnsupportedOperationException();
91 public <T> T readEntity(Class<T> entityType, Annotation[] annotations) {
92 throw new UnsupportedOperationException();
96 public <T> T readEntity(GenericType<T> entityType, Annotation[] annotations) {
97 throw new UnsupportedOperationException();
101 public StatusType getStatusInfo() {
102 throw new UnsupportedOperationException();
106 public Object getEntity() {
107 throw new UnsupportedOperationException();
111 public boolean hasEntity() {
112 throw new UnsupportedOperationException();
116 public boolean bufferEntity() {
117 throw new UnsupportedOperationException();
121 public MediaType getMediaType() {
122 throw new UnsupportedOperationException();
126 public Locale getLanguage() {
127 throw new UnsupportedOperationException();
131 public int getLength() {
132 throw new UnsupportedOperationException();
136 public Set<String> getAllowedMethods() {
137 throw new UnsupportedOperationException();
141 public Map<String, NewCookie> getCookies() {
142 throw new UnsupportedOperationException();
146 public EntityTag getEntityTag() {
147 throw new UnsupportedOperationException();
151 public Date getDate() {
152 throw new UnsupportedOperationException();
156 public Date getLastModified() {
157 throw new UnsupportedOperationException();
161 public URI getLocation() {
162 throw new UnsupportedOperationException();
166 public Set<Link> getLinks() {
167 throw new UnsupportedOperationException();
171 public boolean hasLink(String relation) {
172 throw new UnsupportedOperationException();
176 public Link getLink(String relation) {
177 throw new UnsupportedOperationException();
181 public Builder getLinkBuilder(String relation) {
182 throw new UnsupportedOperationException();
186 public MultivaluedMap<String, Object> getMetadata() {
187 throw new UnsupportedOperationException();
191 public MultivaluedMap<String, String> getStringHeaders() {
192 throw new UnsupportedOperationException();
196 public String getHeaderString(String name) {
197 throw new UnsupportedOperationException();