summaryrefslogtreecommitdiffstats
path: root/openstack-client-connectors/resteasy-connector/src
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-09-12 11:57:43 -0400
committerRob Daugherty <rd472p@att.com>2018-09-12 14:47:22 -0400
commite38ab31eecbcdbc3b3ea4b6001770e7100ef9240 (patch)
tree25ff5751ca2eda57c1f9179b94e165b81be2cecf /openstack-client-connectors/resteasy-connector/src
parent69135296d0c23ad73efb813e56da65cf309c5986 (diff)
Remove unused connectors and modules
NexusIQ issue: org.codehaus.jackson Jersey 2.6 uses codehaus.jackson which has security vulnerabilities. Rather than upgrading the Jersey version, I'm totally removing the Jersey, Jersey2, and RESTEasy connectors. We don't use them. I'm also removing the console and examples modules. They haven't even been compiled in a long time. Unit test coverage will go up to 74%. Change-Id: Ie0145e56718adfe5ea7a677439564e7a25c73fe6 Issue-ID: SO-864 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'openstack-client-connectors/resteasy-connector/src')
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java145
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java53
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java75
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector1
4 files changed, 0 insertions, 274 deletions
diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java
deleted file mode 100644
index b804e69..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.ext.ContextResolver;
-
-// bwj: changed the HttpStatus package
-//import org.apache.commons.httpclient.HttpStatus;
-import org.apache.http.HttpStatus;
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.InputStreamProvider;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-import com.woorea.openstack.base.client.OpenStackClientConnector;
-import com.woorea.openstack.base.client.OpenStackRequest;
-import com.woorea.openstack.base.client.OpenStackResponse;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-
-public class RESTEasyConnector implements OpenStackClientConnector {
-
- public static ObjectMapper DEFAULT_MAPPER;
-
- public static ObjectMapper WRAPPED_MAPPER;
-
- static class OpenStackProviderFactory extends ResteasyProviderFactory {
-
- private JacksonJsonProvider jsonProvider;
- private InputStreamProvider streamProvider;
-
- public OpenStackProviderFactory() {
- super();
-
- addContextResolver(new ContextResolver<ObjectMapper>() {
- @Override
- public ObjectMapper getContext(Class<?> type) {
- return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER;
- }
- });
-
- jsonProvider = new JacksonJsonProvider();
- addMessageBodyReader(jsonProvider);
- addMessageBodyWriter(jsonProvider);
-
- streamProvider = new InputStreamProvider();
- addMessageBodyReader(streamProvider);
- addMessageBodyWriter(streamProvider);
- }
-
- }
-
- private static OpenStackProviderFactory providerFactory;
-
- static {
- DEFAULT_MAPPER = new ObjectMapper();
-
- DEFAULT_MAPPER.setSerializationInclusion(Include.NON_NULL);
- DEFAULT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-
- WRAPPED_MAPPER = new ObjectMapper();
-
- WRAPPED_MAPPER.setSerializationInclusion(Include.NON_NULL);
- WRAPPED_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-
- providerFactory = new OpenStackProviderFactory();
- }
-
- @Override
- public <T> OpenStackResponse request(OpenStackRequest<T> request) {
- ClientRequest client = new ClientRequest(UriBuilder.fromUri(request.endpoint() + "/" + request.path()),
- ClientRequest.getDefaultExecutor(), providerFactory);
-
- for(Map.Entry<String, List<Object> > entry : request.queryParams().entrySet()) {
- for (Object o : entry.getValue()) {
- client = client.queryParameter(entry.getKey(), String.valueOf(o));
- }
- }
-
- for (Entry<String, List<Object>> h : request.headers().entrySet()) {
- StringBuilder sb = new StringBuilder();
- for (Object v : h.getValue()) {
- sb.append(String.valueOf(v));
- }
- client.header(h.getKey(), sb);
- }
-
- if (request.entity() != null) {
- client.body(request.entity().getContentType(), request.entity().getEntity());
- }
-
- ClientResponse<T> response;
-
- try {
- response = client.httpMethod(request.method().name(), request.returnType());
- } catch (Exception e) {
- throw new RuntimeException("Unexpected client exception", e);
- }
-
- if (response.getStatus() == HttpStatus.SC_OK
- || response.getStatus() == HttpStatus.SC_CREATED
- || response.getStatus() == HttpStatus.SC_NO_CONTENT
- || response.getStatus() == HttpStatus.SC_ACCEPTED) {
- return new RESTEasyResponse(client, response);
- }
-
- response.releaseConnection();
-
- throw new OpenStackResponseException(response.getResponseStatus()
- .getReasonPhrase(), response.getStatus());
- }
-
-}
diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java
deleted file mode 100644
index 0e1e9e9..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.SocketException;
-
-import org.jboss.resteasy.client.ClientExecutor;
-
-
-public class RESTEasyInputStream extends FilterInputStream {
-
- protected ClientExecutor clientExecutor;
-
- public RESTEasyInputStream(InputStream inputStream, ClientExecutor clientExecutor) {
- super(inputStream);
- this.clientExecutor = clientExecutor;
- }
-
- @Override
- public void close() throws IOException {
- try {
- clientExecutor.close();
- } catch (Exception e) {
- // Silently skip errors in the socket close errors
- }
-
- try {
- super.close();
- } catch (SocketException e) {
- // We expect this exception because the socket is closed
- } catch (IllegalStateException e) {
- // We expect this exception because the socket is closed (httpclient 4.2)
- }
- }
-
-}
diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java
deleted file mode 100644
index ced748e..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-/*
- * Modifications copyright (c) 2017 AT&T Intellectual Property
- */
-
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.client.ClientResponse;
-import com.woorea.openstack.base.client.OpenStackResponse;
-
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-public class RESTEasyResponse implements OpenStackResponse {
-
- private ClientRequest client;
-
- private ClientResponse response;
-
- public RESTEasyResponse(ClientRequest client, ClientResponse response) {
- this.client = client;
- this.response = response;
- }
-
- @Override
- public <T> T getEntity(Class<T> returnType) {
- return (T) response.getEntity(returnType);
- }
-
- @Override
- public <T> T getErrorEntity(Class<T> returnType) {
- return (T) response.getEntity(returnType);
- }
-
- @Override
- public InputStream getInputStream() {
- return new RESTEasyInputStream((InputStream) response.getEntity(InputStream.class), client.getExecutor());
- }
-
- @Override
- public String header(String name) {
- return response.getHeaders().getFirst(name).toString();
- }
-
- @Override
- public Map<String, String> headers() {
- Map<String, String> headers = new HashMap<>();
- MultivaluedMap<String, Object> responseHeaders = response.getHeaders();
-
- for (String key : responseHeaders.keySet()) {
- headers.put(key, responseHeaders.getFirst(key).toString());
- }
-
- return headers;
- }
-
-}
diff --git a/openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
deleted file mode 100644
index dbb991d..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
+++ /dev/null
@@ -1 +0,0 @@
-com.woorea.openstack.connector.RESTEasyConnector \ No newline at end of file