diff options
author | Roberto E. Escobar | 2014-06-10 18:47:10 +0000 |
---|---|---|
committer | Roberto E. Escobar | 2014-08-28 23:58:30 +0000 |
commit | 2cba21dbf75f6e7bed63a267036ddd7192eb4b77 (patch) | |
tree | 65fb5b5ebd623c6a769f22b8ba8ead02d59720c8 | |
parent | fc1724d32fd8d2e3e5c8c1e004c7a2b249a99c24 (diff) | |
download | org.eclipse.osee-2cba21dbf75f6e7bed63a267036ddd7192eb4b77.tar.gz org.eclipse.osee-2cba21dbf75f6e7bed63a267036ddd7192eb4b77.tar.xz org.eclipse.osee-2cba21dbf75f6e7bed63a267036ddd7192eb4b77.zip |
refactor[ats_ATS64244]: Update OTE to use JAX-RS Client
Change-Id: I15c6b492f124b30acc5c991e2416e5d050d430ae
24 files changed, 172 insertions, 443 deletions
diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF index 320dc4ad541..eb830fe1d77 100644 --- a/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ote.master.rest.client/META-INF/MANIFEST.MF @@ -11,6 +11,8 @@ Import-Package: com.sun.jersey.api.client, com.sun.jersey.client.apache, com.sun.jersey.client.apache.config, javax.ws.rs.core, + org.eclipse.osee.framework.jdk.core.type, + org.eclipse.osee.jaxrs.client, org.eclipse.osee.ote.master.rest.model Export-Package: org.eclipse.osee.ote.master.rest.client Service-Component: OSGI-INF/*.xml diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.webclientprovider.xml b/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.webclientprovider.xml deleted file mode 100644 index 63e9df3ff6d..00000000000 --- a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.webclientprovider.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osee.ote.master.rest.client..webclientprovider"> - <implementation class="org.eclipse.osee.ote.master.rest.client.internal.WebClientProviderImpl"/> - <service> - <provide interface="org.eclipse.osee.ote.master.rest.client.internal.WebClientProvider"/> - </service> -</scr:component> diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml b/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml index 0bfaa47b1de..10ff996630e 100644 --- a/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml +++ b/plugins/org.eclipse.osee.ote.master.rest.client/OSGI-INF/ote.master.rest.client.xml @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.ote.master.rest.client"> +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop"> <implementation class="org.eclipse.osee.ote.master.rest.client.internal.OTEMasterServerImpl"/> - <reference bind="bindWebClientProvider" cardinality="1..1" interface="org.eclipse.osee.ote.master.rest.client.internal.WebClientProvider" name="WebClientProvider" policy="static" unbind="unbindWebClientProvider"/> <service> <provide interface="org.eclipse.osee.ote.master.rest.client.OTEMasterServer"/> </service> + <reference bind="setWebClientProvider" cardinality="1..1" interface="org.eclipse.osee.jaxrs.client.WebClientProvider" name="WebClientProvider" policy="static"/> </scr:component> diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java index 6450e618375..9aab0fbb8f4 100644 --- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java +++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java @@ -2,19 +2,17 @@ package org.eclipse.osee.ote.master.rest.client.internal; import java.net.URI; import java.util.concurrent.Callable; - import javax.ws.rs.core.MediaType; - +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult; import org.eclipse.osee.ote.master.rest.model.OTEServer; - import com.sun.jersey.api.client.WebResource; public class AddServer implements Callable<OTEMasterServerResult> { - private WebClientProvider webClientProvider; - private OTEServer server; - private URI uri; + private final WebClientProvider webClientProvider; + private final OTEServer server; + private final URI uri; public AddServer(WebClientProvider webClientProvider, URI uri, OTEServer server) { this.webClientProvider = webClientProvider; @@ -25,10 +23,12 @@ public class AddServer implements Callable<OTEMasterServerResult> { @Override public OTEMasterServerResult call() throws Exception { OTEMasterServerResult result = new OTEMasterServerResult(); - try{ + try { WebResource resource = webClientProvider.createResource(uri); - resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(MediaType.APPLICATION_XML).post(server); - } catch (Throwable th){ + resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept( + MediaType.APPLICATION_XML).post(server); + + } catch (Throwable th) { result.setSuccess(false); result.setThrowable(th); } diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java index 0ef39942cab..7449c0f7953 100644 --- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java +++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java @@ -2,18 +2,16 @@ package org.eclipse.osee.ote.master.rest.client.internal; import java.net.URI; import java.util.concurrent.Callable; - import javax.ws.rs.core.MediaType; - +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.master.rest.client.OTEMasterServerAvailableNodes; import org.eclipse.osee.ote.master.rest.model.OTEServer; - import com.sun.jersey.api.client.WebResource; public class GetAvailableServers implements Callable<OTEMasterServerAvailableNodes> { - private WebClientProvider webClientProvider; - private URI uri; + private final WebClientProvider webClientProvider; + private final URI uri; public GetAvailableServers(WebClientProvider webClientProvider, URI uri) { this.webClientProvider = webClientProvider; @@ -23,12 +21,14 @@ public class GetAvailableServers implements Callable<OTEMasterServerAvailableNod @Override public OTEMasterServerAvailableNodes call() throws Exception { OTEMasterServerAvailableNodes result = new OTEMasterServerAvailableNodes(); - try{ + try { WebResource resource = webClientProvider.createResource(uri); - OTEServer[] servers = resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(MediaType.APPLICATION_XML).get(OTEServer[].class); + OTEServer[] servers = + resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept( + MediaType.APPLICATION_XML).get(OTEServer[].class); result.setServers(servers); result.setSuccess(true); - } catch (Throwable th){ + } catch (Throwable th) { result.setSuccess(false); result.setThrowable(th); } diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/MasterServerCallable.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/MasterServerCallable.java deleted file mode 100644 index 49a65bb364a..00000000000 --- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/MasterServerCallable.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.eclipse.osee.ote.master.rest.client.internal; - -import java.util.concurrent.Callable; - -public abstract class MasterServerCallable<V> implements Callable<V> { - - - -} diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java index 533201e202a..c7993e93ed4 100644 --- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java +++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/OTEMasterServerImpl.java @@ -5,7 +5,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; - +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.master.rest.client.OTEMasterServer; import org.eclipse.osee.ote.master.rest.client.OTEMasterServerAvailableNodes; import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult; @@ -15,12 +15,16 @@ public class OTEMasterServerImpl implements OTEMasterServer { static final String CONTEXT_NAME = "otemaster"; static final String CONTEXT_SERVERS = "servers"; - + private WebClientProvider webClientProvider; private ExecutorService executor; - - public OTEMasterServerImpl(){ - executor = Executors.newCachedThreadPool(new ThreadFactory(){ + + public void setWebClientProvider(WebClientProvider webClientProvider) { + this.webClientProvider = webClientProvider; + } + + public void start() { + executor = Executors.newCachedThreadPool(new ThreadFactory() { @Override public Thread newThread(Runnable arg0) { Thread th = new Thread(arg0); @@ -30,23 +34,13 @@ public class OTEMasterServerImpl implements OTEMasterServer { } }); } - - public void start(){ - - } - - public void stop(){ - - } - - public void bindWebClientProvider(WebClientProvider webClientProvider){ - this.webClientProvider = webClientProvider; - } - - public void unbindWebClientProvider(WebClientProvider webClientProvider){ - this.webClientProvider = null; + + public void stop() { + if (executor != null) { + executor.shutdown(); + } } - + @Override public Future<OTEMasterServerAvailableNodes> getAvailableServers(URI uri) { return executor.submit(new GetAvailableServers(webClientProvider, uri)); diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java index f087640a594..6f8b2d2fcfe 100644 --- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java +++ b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java @@ -2,19 +2,17 @@ package org.eclipse.osee.ote.master.rest.client.internal; import java.net.URI; import java.util.concurrent.Callable; - import javax.ws.rs.core.MediaType; - +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult; import org.eclipse.osee.ote.master.rest.model.OTEServer; - import com.sun.jersey.api.client.WebResource; public class RemoveServer implements Callable<OTEMasterServerResult> { - private WebClientProvider webClientProvider; - private OTEServer server; - private URI uri; + private final WebClientProvider webClientProvider; + private final OTEServer server; + private final URI uri; public RemoveServer(WebClientProvider webClientProvider, URI uri, OTEServer server) { this.webClientProvider = webClientProvider; @@ -25,14 +23,15 @@ public class RemoveServer implements Callable<OTEMasterServerResult> { @Override public OTEMasterServerResult call() throws Exception { OTEMasterServerResult result = new OTEMasterServerResult(); - try{ + try { WebResource resource = webClientProvider.createResource(uri); - resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept(MediaType.APPLICATION_XML).delete(server); - } catch (Throwable th){ + resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).accept( + MediaType.APPLICATION_XML).delete(server); + } catch (Throwable th) { result.setSuccess(false); result.setThrowable(th); } return result; } - + } diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProvider.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProvider.java deleted file mode 100644 index 65c40e8475b..00000000000 --- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProvider.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Boeing. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.ote.master.rest.client.internal; - -import java.net.URI; - -import com.sun.jersey.api.client.AsyncWebResource; -import com.sun.jersey.api.client.WebResource; - -public interface WebClientProvider { - - WebResource createResource(URI uri) throws Exception; - - AsyncWebResource createAsyncResource(URI uri) throws Exception; - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProviderImpl.java b/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProviderImpl.java deleted file mode 100644 index 8f7fbf77c99..00000000000 --- a/plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/WebClientProviderImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Boeing. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.ote.master.rest.client.internal; - -import java.net.URI; -import java.util.Map; - -import com.sun.jersey.api.client.AsyncWebResource; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.client.apache.ApacheHttpClient; -import com.sun.jersey.client.apache.config.DefaultApacheHttpClientConfig; - -public class WebClientProviderImpl implements WebClientProvider { - - private Client client; - - public void start() { - - } - - public void stop() { - } - - @Override - public WebResource createResource(URI uri) { - Client client = createClient(uri); - return client.resource(uri); - } - - @Override - public AsyncWebResource createAsyncResource(URI uri) { - Client client = createClient(uri); - return client.asyncResource(uri); - } - - private Client createClient(URI uri) { - if (client == null) { - DefaultApacheHttpClientConfig clientConfig = new DefaultApacheHttpClientConfig(); - Map<String, Object> properties = clientConfig.getProperties(); - - properties.put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true); - - client = ApacheHttpClient.create(clientConfig); - } - return client; - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java index 26f4b6030f2..724d0f34135 100644 --- a/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java +++ b/plugins/org.eclipse.osee.ote.master.rest/src/org/eclipse/osee/ote/master/rest/internal/OTEAvailableServersResource.java @@ -1,13 +1,9 @@ package org.eclipse.osee.ote.master.rest.internal; -import java.io.IOException; import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.text.ParseException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; - import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -19,14 +15,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Request; import javax.ws.rs.core.UriBuilderException; import javax.ws.rs.core.UriInfo; - import org.eclipse.osee.ote.master.OTELookup; import org.eclipse.osee.ote.master.OTELookupServerEntry; import org.eclipse.osee.ote.master.rest.model.OTEServer; @Path("servers") public class OTEAvailableServersResource { - + // Allows to insert contextual objects into the class, // e.g. ServletContext, Request, Response, UriInfo @Context @@ -40,22 +35,22 @@ public class OTEAvailableServersResource { OTELookup oteLookup = OTERestApplication.getOTELookup(); List<OTELookupServerEntry> availableServers = oteLookup.getAvailableServers(); List<OTEServer> servers = new ArrayList<OTEServer>(); - for(OTELookupServerEntry entry:availableServers){ + for (OTELookupServerEntry entry : availableServers) { servers.add(Util.convert(entry)); } return servers; } - + @GET @Produces(MediaType.TEXT_HTML) public String getAsHtml() { OTELookup oteLookup = OTERestApplication.getOTELookup(); List<OTELookupServerEntry> availableServers = oteLookup.getAvailableServers(); - + StringBuilder builder = new StringBuilder(); builder.append("<html><body>"); builder.append("<table border=\"1\">"); - + builder.append("<tr>\n"); builder.append("<th>"); builder.append("Station"); @@ -70,7 +65,7 @@ public class OTEAvailableServersResource { builder.append("StartTime"); builder.append("</th>"); builder.append("</tr>\n"); - + for (OTELookupServerEntry entry : availableServers) { builder.append("<tr>\n"); builder.append("<td>"); @@ -92,19 +87,19 @@ public class OTEAvailableServersResource { builder.append("</body></html>"); return builder.toString(); } - + @POST @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public void updateServer(OTEServer server) throws IOException, InterruptedException, ExecutionException, ParseException, URISyntaxException { + public void updateServer(OTEServer server) throws Exception { OTELookup oteLookup = OTERestApplication.getOTELookup(); oteLookup.addServer(Util.convert(server)); } - + @DELETE @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public void removeServer(OTEServer server) throws IOException, InterruptedException, ExecutionException, ParseException, URISyntaxException { + public void removeServer(OTEServer server) throws Exception { OTELookup oteLookup = OTERestApplication.getOTELookup(); oteLookup.removeServer(Util.convert(server)); } - + } diff --git a/plugins/org.eclipse.osee.ote.rest.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ote.rest.client/META-INF/MANIFEST.MF index 1f2cd6a81d6..f92576cbd3d 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.ote.rest.client/META-INF/MANIFEST.MF @@ -20,6 +20,7 @@ Import-Package: javax.ws.rs, org.eclipse.osee.framework.jdk.core.util.network, org.eclipse.osee.framework.logging, org.eclipse.osee.framework.plugin.core.server, + org.eclipse.osee.jaxrs.client, org.eclipse.osee.ote.core Export-Package: org.eclipse.osee.ote.rest.client Bundle-ActivationPolicy: lazy diff --git a/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml b/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml index 35d328b4059..0f7cffa4690 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml +++ b/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/ote.client.xml @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.ote.rest.client.OteClient"> +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop"> <implementation class="org.eclipse.osee.ote.rest.client.internal.OteClientImpl"/> <service> <provide interface="org.eclipse.osee.ote.rest.client.OteClient"/> </service> + <reference bind="setWebClientProvider" cardinality="1..1" interface="org.eclipse.osee.jaxrs.client.WebClientProvider" name="WebClientProvider" policy="static"/> </scr:component> diff --git a/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/web.client.provider.xml b/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/web.client.provider.xml deleted file mode 100644 index bd52d64fad1..00000000000 --- a/plugins/org.eclipse.osee.ote.rest.client/OSGI-INF/web.client.provider.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="start" deactivate="stop" name="org.eclipse.osee.ote.rest.client.internal.WebClientProviderImpl"> - <implementation class="org.eclipse.osee.ote.rest.client.internal.WebClientProviderImpl"/> - <reference bind="setProxyService" cardinality="1..1" interface="org.eclipse.core.net.proxy.IProxyService" name="IProxyService" policy="static"/> - <service> - <provide interface="org.eclipse.osee.ote.rest.client.internal.WebClientProvider"/> - </service> -</scr:component> diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/BaseClientCallable.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/BaseClientCallable.java index baaa2728fa2..7ed3ffa79f5 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/BaseClientCallable.java +++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/BaseClientCallable.java @@ -1,7 +1,6 @@ package org.eclipse.osee.ote.rest.client.internal; import java.util.concurrent.Callable; - import org.eclipse.osee.ote.rest.client.Progress; public abstract class BaseClientCallable<T extends Progress> implements Callable<T>{ diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/ConfigureOteServer.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/ConfigureOteServer.java index fab6836fc38..99bfd102b5e 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/ConfigureOteServer.java +++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/ConfigureOteServer.java @@ -4,10 +4,9 @@ import java.io.File; import java.net.InetAddress; import java.net.URI; import java.util.List; - import javax.ws.rs.core.MediaType; - import org.eclipse.osee.framework.jdk.core.util.network.PortUtil; +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.core.BundleInfo; import org.eclipse.osee.ote.rest.client.Progress; import org.eclipse.osee.ote.rest.client.internal.jarserver.HeadlessClassServer; @@ -15,29 +14,28 @@ import org.eclipse.osee.ote.rest.model.OTEConfiguration; import org.eclipse.osee.ote.rest.model.OTEConfigurationIdentity; import org.eclipse.osee.ote.rest.model.OTEConfigurationItem; import org.eclipse.osee.ote.rest.model.OTEJobStatus; - import com.sun.jersey.api.client.WebResource; public class ConfigureOteServer extends BaseClientCallable<Progress> { private static final long POLLING_RATE = 1000; - private URI uri; + private final URI uri; private List<File> jars; - private Progress progress; - private WebResourceFactory factory; + private final Progress progress; + private final WebClientProvider factory; private OTEJobStatus status; private HeadlessClassServer classServer; private OTEConfiguration configuration; - public ConfigureOteServer(URI uri, List<File> jars, Progress progress, WebResourceFactory factory) { + public ConfigureOteServer(URI uri, List<File> jars, Progress progress, WebClientProvider factory) { super(progress); this.uri = uri; this.jars = jars; this.progress = progress; this.factory = factory; } - - public ConfigureOteServer(URI uri, OTEConfiguration configuration, Progress progress, WebResourceFactory factory) { + + public ConfigureOteServer(URI uri, OTEConfiguration configuration, Progress progress, WebClientProvider factory) { super(progress); this.uri = uri; this.configuration = configuration; @@ -47,38 +45,38 @@ public class ConfigureOteServer extends BaseClientCallable<Progress> { @Override public void doWork() throws Exception { - try{ + try { status = sendBundleConfiguration(); - if(!status.isJobComplete()){ + if (!status.isJobComplete()) { waitForJobComplete(); - } + } - if(!status.isSuccess()){ + if (!status.isSuccess()) { throw new Exception("Failed to configure the environment: " + status.getErrorLog()); } } finally { - if(classServer != null){ + if (classServer != null) { classServer.stop(); } } } private void waitForJobComplete() throws Exception { - + URI jobUri = status.getUpdatedJobStatus().toURI(); final WebResource service = factory.createResource(jobUri); - while(!status.isJobComplete()){ + while (!status.isJobComplete()) { Thread.sleep(POLLING_RATE); status = service.accept(MediaType.APPLICATION_XML).get(OTEJobStatus.class); progress.setUnitsOfWork(status.getTotalUnitsOfWork()); progress.setUnitsWorked(status.getUnitsWorked()); } } - + private OTEJobStatus sendBundleConfiguration() throws Exception { WebResource baseService = factory.createResource(uri); - if(configuration == null){ + if (configuration == null) { OTEConfiguration localConfiguration = new OTEConfiguration(); OTEConfigurationIdentity identity = new OTEConfigurationIdentity(); identity.setName("test"); @@ -92,17 +90,20 @@ public class ConfigureOteServer extends BaseClientCallable<Progress> { item.setMd5Digest(bundleInfo.getMd5Digest()); localConfiguration.addItem(item); } - OTEConfiguration currentConfig = baseService.path("ote").path("config").accept(MediaType.APPLICATION_XML).get(OTEConfiguration.class); - if(currentConfig.equals(localConfiguration)){ + OTEConfiguration currentConfig = + baseService.path("ote").path("config").accept(MediaType.APPLICATION_XML).get(OTEConfiguration.class); + if (currentConfig.equals(localConfiguration)) { OTEJobStatus status = new OTEJobStatus(); status.setSuccess(true); status.setJobComplete(true); return status; } else { - return baseService.path("ote").path("config").accept(MediaType.APPLICATION_XML).post(OTEJobStatus.class, localConfiguration); + return baseService.path("ote").path("config").accept(MediaType.APPLICATION_XML).post(OTEJobStatus.class, + localConfiguration); } } else { - return baseService.path("ote").path("config").accept(MediaType.APPLICATION_XML).post(OTEJobStatus.class, this.configuration); + return baseService.path("ote").path("config").accept(MediaType.APPLICATION_XML).post(OTEJobStatus.class, + this.configuration); } } diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/GetOteServerFile.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/GetOteServerFile.java index 6e3325a799d..fc14831b00c 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/GetOteServerFile.java +++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/GetOteServerFile.java @@ -4,24 +4,23 @@ import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.URI; - import javax.ws.rs.core.MediaType; - +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.rest.client.Progress; - import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; public class GetOteServerFile extends BaseClientCallable<Progress> { - private URI uri; - private String filePath; + private final URI uri; + private final String filePath; @SuppressWarnings("unused") - private Progress progress; - private WebResourceFactory factory; - private File destination; - - public GetOteServerFile(URI uri, File destination, String filePath, Progress progress, WebResourceFactory factory) { + private final Progress progress; + private final WebClientProvider factory; + private final File destination; + + public GetOteServerFile(URI uri, File destination, String filePath, Progress progress, WebClientProvider factory) { super(progress); this.uri = uri; this.filePath = filePath; @@ -33,17 +32,22 @@ public class GetOteServerFile extends BaseClientCallable<Progress> { @Override public void doWork() throws Exception { WebResource client = factory.createResource(uri); - ClientResponse response = client.queryParam("path", filePath).path("ote").path("file").accept(MediaType.APPLICATION_XML).get(ClientResponse.class); - if(response.getStatus() == ClientResponse.Status.OK.getStatusCode()){ + ClientResponse response = + client.queryParam("path", filePath).path("ote").path("file").accept(MediaType.APPLICATION_XML).get( + ClientResponse.class); + if (response.getStatus() == ClientResponse.Status.OK.getStatusCode()) { InputStream is = response.getEntityInputStream(); FileOutputStream fos = new FileOutputStream(destination); - byte[] data = new byte[2048]; - int numRead = 0; - while((numRead = is.read(data)) != -1){ - fos.write(data, 0, numRead); + try { + byte[] data = new byte[2048]; + int numRead = 0; + while ((numRead = is.read(data)) != -1) { + fos.write(data, 0, numRead); + } + fos.flush(); + } finally { + Lib.close(fos); } - fos.flush(); - fos.close(); } else { throw new Exception(response.toString()); } diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java index ecc7ba96902..0fc34e0fcb1 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java +++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/OteClientImpl.java @@ -17,7 +17,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; - +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.rest.client.OTECacheItem; import org.eclipse.osee.ote.rest.client.OteClient; import org.eclipse.osee.ote.rest.client.Progress; @@ -25,20 +25,20 @@ import org.eclipse.osee.ote.rest.client.ProgressWithCancel; import org.eclipse.osee.ote.rest.model.OTEConfiguration; import org.eclipse.osee.ote.rest.model.OTETestRun; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; - /** * @author Andrew M. Finkbeiner */ -public class OteClientImpl implements OteClient, WebResourceFactory { +public class OteClientImpl implements OteClient { private ExecutorService executor; - - public OteClientImpl(){ - executor = Executors.newCachedThreadPool(new ThreadFactory(){ + private WebClientProvider provider; + + public void setWebClientProvider(WebClientProvider provider) { + this.provider = provider; + } + + public void start() { + executor = Executors.newCachedThreadPool(new ThreadFactory() { @Override public Thread newThread(Runnable arg0) { Thread th = new Thread(arg0); @@ -49,44 +49,35 @@ public class OteClientImpl implements OteClient, WebResourceFactory { }); } - public void start() { - - } - public void stop() { + if (executor != null) { + executor.shutdown(); + } } @Override - public WebResource createResource(URI uri) throws Exception { - ClientConfig config = new DefaultClientConfig(); - Client client = Client.create(config); - WebResource service = client.resource(uri); - return service; + public Future<Progress> getFile(URI uri, File destination, String filePath, final Progress progress) { + return executor.submit(new GetOteServerFile(uri, destination, filePath, progress, provider)); } @Override - public Future<Progress> getFile(URI uri, File destination, String filePath, final Progress progress){ - return executor.submit(new GetOteServerFile(uri, destination, filePath, progress, this)); - } - - @Override - public Future<Progress> configureServerEnvironment(URI uri, List<File> jars, final Progress progress){ - return executor.submit(new ConfigureOteServer(uri, jars, progress, this)); + public Future<Progress> configureServerEnvironment(URI uri, List<File> jars, final Progress progress) { + return executor.submit(new ConfigureOteServer(uri, jars, progress, provider)); } @Override public Future<Progress> updateServerJarCache(URI uri, String baseJarURL, List<OTECacheItem> jars, Progress progress) { - return executor.submit(new PrepareOteServerFile(uri, baseJarURL, jars, progress, this)); + return executor.submit(new PrepareOteServerFile(uri, baseJarURL, jars, progress, provider)); } @Override public Future<ProgressWithCancel> runTest(URI uri, OTETestRun tests, Progress progress) { - return executor.submit(new RunTests(uri, tests, progress, this)); + return executor.submit(new RunTests(uri, tests, progress, provider)); } @Override public Future<Progress> configureServerEnvironment(URI uri, OTEConfiguration configuration, Progress progress) { - return executor.submit(new ConfigureOteServer(uri, configuration, progress, this)); + return executor.submit(new ConfigureOteServer(uri, configuration, progress, provider)); } } diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/PrepareOteServerFile.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/PrepareOteServerFile.java index 70729e717b4..1a5d2ed27ea 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/PrepareOteServerFile.java +++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/PrepareOteServerFile.java @@ -2,29 +2,27 @@ package org.eclipse.osee.ote.rest.client.internal; import java.net.URI; import java.util.List; - import javax.ws.rs.core.MediaType; - -import org.eclipse.osee.ote.rest.client.Progress; +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.rest.client.OTECacheItem; +import org.eclipse.osee.ote.rest.client.Progress; import org.eclipse.osee.ote.rest.model.OTEConfiguration; import org.eclipse.osee.ote.rest.model.OTEConfigurationIdentity; import org.eclipse.osee.ote.rest.model.OTEConfigurationItem; import org.eclipse.osee.ote.rest.model.OTEJobStatus; - import com.sun.jersey.api.client.WebResource; public class PrepareOteServerFile extends BaseClientCallable<Progress> { private static final long POLLING_RATE = 1000; - private URI uri; - private List<OTECacheItem> jars; - private Progress progress; - private WebResourceFactory factory; + private final URI uri; + private final List<OTECacheItem> jars; + private final Progress progress; + private final WebClientProvider factory; private OTEJobStatus status; - private String baseJarURL; + private final String baseJarURL; - public PrepareOteServerFile(URI uri, String baseJarURL, List<OTECacheItem> jars, Progress progress, WebResourceFactory factory) { + public PrepareOteServerFile(URI uri, String baseJarURL, List<OTECacheItem> jars, Progress progress, WebClientProvider factory) { super(progress); this.uri = uri; this.jars = jars; @@ -35,33 +33,29 @@ public class PrepareOteServerFile extends BaseClientCallable<Progress> { @Override public void doWork() throws Exception { - try{ - status = sendBundleConfiguration(); - if(!status.isJobComplete()){ - waitForJobComplete(); - } + status = sendBundleConfiguration(); + if (!status.isJobComplete()) { + waitForJobComplete(); + } - if(!status.isSuccess()){ - throw new Exception("Failed to update the environment cache: " + status.getErrorLog()); - } - } finally { - + if (!status.isSuccess()) { + throw new Exception("Failed to update the environment cache: " + status.getErrorLog()); } } private void waitForJobComplete() throws Exception { - + URI jobUri = status.getUpdatedJobStatus().toURI(); final WebResource service = factory.createResource(jobUri); - while(!status.isJobComplete()){ + while (!status.isJobComplete()) { Thread.sleep(POLLING_RATE); status = service.accept(MediaType.APPLICATION_JSON).get(OTEJobStatus.class); progress.setUnitsOfWork(status.getTotalUnitsOfWork()); progress.setUnitsWorked(status.getUnitsWorked()); } } - + private OTEJobStatus sendBundleConfiguration() throws Exception { OTEConfiguration configuration = new OTEConfiguration(); OTEConfigurationIdentity identity = new OTEConfigurationIdentity(); @@ -77,7 +71,8 @@ public class PrepareOteServerFile extends BaseClientCallable<Progress> { } WebResource baseService = factory.createResource(uri); - return baseService.path("ote").path("cache").accept(MediaType.APPLICATION_XML).post(OTEJobStatus.class, configuration); + return baseService.path("ote").path("cache").accept(MediaType.APPLICATION_XML).post(OTEJobStatus.class, + configuration); } } diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/RunTests.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/RunTests.java index a9402786d93..f87cf1703a0 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/RunTests.java +++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/RunTests.java @@ -3,27 +3,25 @@ package org.eclipse.osee.ote.rest.client.internal; import java.net.URI; import java.util.concurrent.Callable; import java.util.logging.Level; - import javax.ws.rs.core.MediaType; - import org.eclipse.osee.framework.logging.OseeLog; +import org.eclipse.osee.jaxrs.client.WebClientProvider; import org.eclipse.osee.ote.rest.client.Progress; import org.eclipse.osee.ote.rest.client.ProgressWithCancel; import org.eclipse.osee.ote.rest.model.OTEJobStatus; import org.eclipse.osee.ote.rest.model.OTETestRun; - import com.sun.jersey.api.client.WebResource; public class RunTests implements ProgressWithCancel, Callable<ProgressWithCancel> { - private URI uri; - private OTETestRun tests; - private Progress progress; - private WebResourceFactory factory; + private final URI uri; + private final OTETestRun tests; + private final Progress progress; + private final WebClientProvider factory; private OTEJobStatus status; private String id; - public RunTests(URI uri, OTETestRun tests, Progress progress, WebResourceFactory factory) { + public RunTests(URI uri, OTETestRun tests, Progress progress, WebClientProvider factory) { this.uri = uri; this.tests = tests; this.progress = progress; @@ -31,33 +29,30 @@ public class RunTests implements ProgressWithCancel, Callable<ProgressWithCancel } public void doWork() throws Exception { - try{ - status = sendCommand(); - id = status.getJobId(); - if(!status.isSuccess()){ - throw new Exception("Failed to submit the run command: " + status.getErrorLog()); - } - } finally { - + status = sendCommand(); + id = status.getJobId(); + if (!status.isSuccess()) { + throw new Exception("Failed to submit the run command: " + status.getErrorLog()); } } - + @Override public boolean cancelSingle() { WebResource baseService; try { baseService = factory.createResource(uri); - OTEJobStatus cancelStatus = baseService.path("ote").path("run").path(id).accept(MediaType.APPLICATION_JSON).put(OTEJobStatus.class); - return cancelStatus.isSuccess(); + OTEJobStatus cancelStatus = + baseService.path("ote").path("run").path(id).accept(MediaType.APPLICATION_JSON).put(OTEJobStatus.class); + return cancelStatus.isSuccess(); } catch (Exception e) { OseeLog.log(getClass(), Level.SEVERE, e); return false; } } - + private OTEJobStatus sendCommand() throws Exception { WebResource baseService = factory.createResource(uri); - return baseService.path("ote").path("run").accept(MediaType.APPLICATION_JSON).post(OTEJobStatus.class, tests); + return baseService.path("ote").path("run").accept(MediaType.APPLICATION_JSON).post(OTEJobStatus.class, tests); } @Override @@ -65,20 +60,21 @@ public class RunTests implements ProgressWithCancel, Callable<ProgressWithCancel WebResource baseService; try { baseService = factory.createResource(uri); - OTEJobStatus cancelStatus = baseService.path("ote").path("run").path(id).accept(MediaType.APPLICATION_JSON).delete(OTEJobStatus.class); - return cancelStatus.isSuccess(); + OTEJobStatus cancelStatus = + baseService.path("ote").path("run").path(id).accept(MediaType.APPLICATION_JSON).delete(OTEJobStatus.class); + return cancelStatus.isSuccess(); } catch (Exception e) { OseeLog.log(getClass(), Level.SEVERE, e); return false; } } - + @Override final public ProgressWithCancel call() throws Exception { - try{ + try { doWork(); progress.success(); - } catch (Throwable th){ + } catch (Throwable th) { progress.fail(th); } return this; diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebClientProvider.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebClientProvider.java deleted file mode 100644 index ef94ca4e8fe..00000000000 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebClientProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Boeing. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.ote.rest.client.internal; - -import java.net.URI; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import com.sun.jersey.api.client.AsyncWebResource; -import com.sun.jersey.api.client.WebResource; - -/** - * @author John Misinco - * @author Roberto E. Escobar - */ -public interface WebClientProvider { - - WebResource createResource(URI uri) throws OseeCoreException; - - AsyncWebResource createAsyncResource(URI uri) throws OseeCoreException; - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebClientProviderImpl.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebClientProviderImpl.java deleted file mode 100644 index cab8a7f8695..00000000000 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebClientProviderImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012 Boeing. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Boeing - initial API and implementation - *******************************************************************************/ -package org.eclipse.osee.ote.rest.client.internal; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.eclipse.core.net.proxy.IProxyChangeEvent; -import org.eclipse.core.net.proxy.IProxyChangeListener; -import org.eclipse.core.net.proxy.IProxyData; -import org.eclipse.core.net.proxy.IProxyService; - -import com.sun.jersey.api.client.AsyncWebResource; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.WebResource; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.client.apache.ApacheHttpClient; -import com.sun.jersey.client.apache.config.DefaultApacheHttpClientConfig; - -/** - * @author Roberto E. Escobar - */ -public class WebClientProviderImpl implements WebClientProvider { - - private Map<String, IProxyData[]> proxiedData; - private IProxyService proxyService; - private Client client; - - public void setProxyService(IProxyService proxyService) { - this.proxyService = proxyService; - } - - public void start() { - proxiedData = new ConcurrentHashMap<String, IProxyData[]>(); - proxyService.addProxyChangeListener(new IProxyChangeListener() { - @Override - public void proxyInfoChanged(IProxyChangeEvent event) { - proxiedData.clear(); - } - }); - } - - public void stop() { - if (proxiedData != null) { - proxiedData.clear(); - } - } - - @Override - public WebResource createResource(URI uri) { - Client client = createClient(uri); - return client.resource(uri); - } - - @Override - public AsyncWebResource createAsyncResource(URI uri) { - Client client = createClient(uri); - return client.asyncResource(uri); - } - - private Client createClient(URI uri) { - if (client == null) { - DefaultApacheHttpClientConfig clientConfig = new DefaultApacheHttpClientConfig(); - Map<String, Object> properties = clientConfig.getProperties(); - - properties.put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, true); - -// configureProxyData(uri, properties); - client = ApacheHttpClient.create(clientConfig); - } - return client; - } - -// private void configureProxyData(URI uri, Map<String, Object> properties) { -// boolean proxyBypass = OseeProperties.getOseeProxyBypassEnabled(); -// if (!proxyBypass) { -// String key = String.format("%s_%s", uri.getScheme(), uri.getHost()); -// IProxyData[] datas = proxiedData.get(key); -// if (datas == null) { -// datas = proxyService.select(uri); -// proxiedData.put(key, datas); -// } -// -// for (IProxyData proxyData : datas) { -// String type = proxyData.getType(); -// if (Strings.isValid(type) && type.startsWith("HTTP")) { -// String proxyURL = -// String.format("%s://%s:%s", type.toLowerCase(), proxyData.getHost(), proxyData.getPort()); -// properties.put(ApacheHttpClientConfig.PROPERTY_PROXY_URI, proxyURL); -// } -// } -// } -// } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebResourceFactory.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebResourceFactory.java deleted file mode 100644 index d92981fb778..00000000000 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/WebResourceFactory.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.eclipse.osee.ote.rest.client.internal; - -import java.net.URI; - -import com.sun.jersey.api.client.WebResource; - -public interface WebResourceFactory { - - WebResource createResource(URI uri) throws Exception; - -} diff --git a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/jarserver/BundleResourceFinder.java b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/jarserver/BundleResourceFinder.java index 6be5f190df4..0ccfd631808 100644 --- a/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/jarserver/BundleResourceFinder.java +++ b/plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/jarserver/BundleResourceFinder.java @@ -3,15 +3,14 @@ package org.eclipse.osee.ote.rest.client.internal.jarserver; import java.io.FileInputStream; import java.io.IOException; import java.util.List; - import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.plugin.core.server.ResourceFinder; import org.eclipse.osee.ote.core.BundleInfo; public class BundleResourceFinder extends ResourceFinder { - private List<BundleInfo> bundleInfo; - + private final List<BundleInfo> bundleInfo; + public BundleResourceFinder(List<BundleInfo> bundleInfo) { super(); this.bundleInfo = bundleInfo; @@ -19,15 +18,16 @@ public class BundleResourceFinder extends ResourceFinder { @Override public byte[] find(String path) throws IOException { - for (BundleInfo info : bundleInfo) { - if (info.getSymbolicName().equals(path)) { - return Lib.inputStreamToBytes(new FileInputStream(info.getFile())); - } + for (BundleInfo info : bundleInfo) { + if (info.getSymbolicName().equals(path)) { + return Lib.inputStreamToBytes(new FileInputStream(info.getFile())); } + } return null; } @Override public void dispose() { + // } } |