Add SO VF Module Delete Operation
[policy/models.git] / models-interactions / model-actors / actor.so / src / main / java / org / onap / policy / controlloop / actor / so / RestManagerResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.controlloop.actor.so;
22
23 import java.lang.annotation.Annotation;
24 import java.net.URI;
25 import java.util.Date;
26 import java.util.Locale;
27 import java.util.Map;
28 import java.util.Set;
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;
37 import lombok.Getter;
38 import org.onap.policy.common.utils.coder.Coder;
39 import org.onap.policy.common.utils.coder.CoderException;
40
41 /**
42  * RestManager Response suitable for use with subclasses of HttpOperation. Only a couple
43  * of methods are implemented; the rest throw {@link UnsupportedOperationException}.
44  */
45 public class RestManagerResponse extends Response {
46     // TODO move to actorServices
47
48     @Getter
49     private final int status;
50
51     private final String body;
52     private final Coder coder;
53
54     /**
55      * Constructs the object.
56      *
57      * @param status HTTP response status code
58      * @param body response body
59      * @param coder coder to decode the entity body
60      */
61     public RestManagerResponse(int status, String body, Coder coder) {
62         this.status = status;
63         this.body = body;
64         this.coder = coder;
65     }
66
67     @Override
68     public void close() {
69         // do nothing
70     }
71
72     @Override
73     public <T> T readEntity(Class<T> entityType) {
74         if (entityType == String.class) {
75             return entityType.cast(body);
76         }
77
78         try {
79             return coder.decode(body, entityType);
80         } catch (CoderException e) {
81             throw new IllegalArgumentException("cannot decode response", e);
82         }
83     }
84
85     @Override
86     public <T> T readEntity(GenericType<T> entityType) {
87         throw new UnsupportedOperationException();
88     }
89
90     @Override
91     public <T> T readEntity(Class<T> entityType, Annotation[] annotations) {
92         throw new UnsupportedOperationException();
93     }
94
95     @Override
96     public <T> T readEntity(GenericType<T> entityType, Annotation[] annotations) {
97         throw new UnsupportedOperationException();
98     }
99
100     @Override
101     public StatusType getStatusInfo() {
102         throw new UnsupportedOperationException();
103     }
104
105     @Override
106     public Object getEntity() {
107         throw new UnsupportedOperationException();
108     }
109
110     @Override
111     public boolean hasEntity() {
112         throw new UnsupportedOperationException();
113     }
114
115     @Override
116     public boolean bufferEntity() {
117         throw new UnsupportedOperationException();
118     }
119
120     @Override
121     public MediaType getMediaType() {
122         throw new UnsupportedOperationException();
123     }
124
125     @Override
126     public Locale getLanguage() {
127         throw new UnsupportedOperationException();
128     }
129
130     @Override
131     public int getLength() {
132         throw new UnsupportedOperationException();
133     }
134
135     @Override
136     public Set<String> getAllowedMethods() {
137         throw new UnsupportedOperationException();
138     }
139
140     @Override
141     public Map<String, NewCookie> getCookies() {
142         throw new UnsupportedOperationException();
143     }
144
145     @Override
146     public EntityTag getEntityTag() {
147         throw new UnsupportedOperationException();
148     }
149
150     @Override
151     public Date getDate() {
152         throw new UnsupportedOperationException();
153     }
154
155     @Override
156     public Date getLastModified() {
157         throw new UnsupportedOperationException();
158     }
159
160     @Override
161     public URI getLocation() {
162         throw new UnsupportedOperationException();
163     }
164
165     @Override
166     public Set<Link> getLinks() {
167         throw new UnsupportedOperationException();
168     }
169
170     @Override
171     public boolean hasLink(String relation) {
172         throw new UnsupportedOperationException();
173     }
174
175     @Override
176     public Link getLink(String relation) {
177         throw new UnsupportedOperationException();
178     }
179
180     @Override
181     public Builder getLinkBuilder(String relation) {
182         throw new UnsupportedOperationException();
183     }
184
185     @Override
186     public MultivaluedMap<String, Object> getMetadata() {
187         throw new UnsupportedOperationException();
188     }
189
190     @Override
191     public MultivaluedMap<String, String> getStringHeaders() {
192         throw new UnsupportedOperationException();
193     }
194
195     @Override
196     public String getHeaderString(String name) {
197         throw new UnsupportedOperationException();
198     }
199 }