diff options
author | Angel Avila | 2015-03-19 21:41:43 +0000 |
---|---|---|
committer | Ryan T. Baldwin | 2015-03-19 21:41:43 +0000 |
commit | 116f50a36024f88f4fb0e510c158dbea45830183 (patch) | |
tree | 466d6654925f2042fc443ceef02deaf3a4d9d168 /plugins | |
parent | e666c0c0f2977c8eb8ab8b85a6b8ab96c5dd24e4 (diff) | |
download | org.eclipse.osee-116f50a36024f88f4fb0e510c158dbea45830183.tar.gz org.eclipse.osee-116f50a36024f88f4fb0e510c158dbea45830183.tar.xz org.eclipse.osee-116f50a36024f88f4fb0e510c158dbea45830183.zip |
refactor: Extract IdeClientEndpoint API
Change-Id: I1b44c6c9474250b7e81ed94afbe021b7c10db766
Signed-off-by: Angel Avila <angel.avila2@boeing.com>
Diffstat (limited to 'plugins')
9 files changed, 76 insertions, 61 deletions
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF index 6258e3aed31..133d6bca318 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.framework.ui.skynet/META-INF/MANIFEST.MF @@ -137,6 +137,7 @@ Import-Package: com.google.common.base;version="[11.0.0,15.0.0)", org.eclipse.osee.jaxrs.client, org.eclipse.osee.jdbc, org.eclipse.osee.orcs.rest.client, + org.eclipse.osee.orcs.rest.model, org.eclipse.search.ui, org.eclipse.search.ui.text, org.eclipse.swt, diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DbConnectionUtility.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DbConnectionUtility.java index bad8268c3a0..0e923e17330 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DbConnectionUtility.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/util/DbConnectionUtility.java @@ -10,13 +10,18 @@ *******************************************************************************/ package org.eclipse.osee.framework.ui.skynet.util; +import java.util.Collection; +import java.util.Collections; import org.eclipse.osee.framework.core.client.OseeClientProperties; import org.eclipse.osee.framework.core.data.OseeCodeVersion; import org.eclipse.osee.framework.core.util.Result; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; import org.eclipse.osee.framework.ui.skynet.internal.ServiceUtil; +import org.eclipse.osee.jaxrs.client.JaxRsExceptions; import org.eclipse.osee.orcs.rest.client.OseeClient; +import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint; +import org.eclipse.osee.orcs.rest.model.IdeVersion; /** * @author Donald G Dunne @@ -57,10 +62,10 @@ public class DbConnectionUtility { if (applicationServerAlive == null) { String address = OseeClientProperties.getOseeApplicationServer(); if (Strings.isValid(address)) { - OseeClient client = ServiceUtil.getOseeClient(); - if (client != null) { - applicationServerAlive = client.isApplicationServerAlive(); - } else { + try { + getIdeClientSupportedVersions(); + applicationServerAlive = true; + } catch (Exception ex) { applicationServerAlive = false; } } else { @@ -74,12 +79,7 @@ public class DbConnectionUtility { if (supported == null) { String address = OseeClientProperties.getOseeApplicationServer(); if (Strings.isValid(address)) { - OseeClient client = ServiceUtil.getOseeClient(); - if (client != null) { - supported = client.isClientVersionSupportedByApplicationServer(); - } else { - supported = false; - } + supported = getIdeClientSupportedVersions().contains(OseeCodeVersion.getVersion()); } else { supported = false; } @@ -87,4 +87,19 @@ public class DbConnectionUtility { return supported; } + private static Collection<String> getIdeClientSupportedVersions() { + IdeVersion clientResult = null; + + OseeClient client = ServiceUtil.getOseeClient(); + if (client != null) { + IdeClientEndpoint endpoint = client.getIdeClientEndpoint(); + try { + clientResult = endpoint.getSupportedVersions(); + } catch (Exception ex) { + throw JaxRsExceptions.asOseeException(ex); + } + } + return clientResult != null ? clientResult.getVersions() : Collections.<String> emptySet(); + } + } diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java index 76450c43b54..fadb8fb2b45 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java @@ -11,11 +11,11 @@ package org.eclipse.osee.orcs.rest.client; import java.io.Writer; -import java.util.Collection; import java.util.Properties; import javax.ws.rs.core.MediaType; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.rest.model.BranchEndpoint; +import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint; import org.eclipse.osee.orcs.rest.model.IndexerEndpoint; import org.eclipse.osee.orcs.rest.model.TransactionEndpoint; import org.eclipse.osee.orcs.rest.model.TypesEndpoint; @@ -27,14 +27,8 @@ public interface OseeClient { QueryBuilder createQueryBuilder(IOseeBranch branch); - boolean isClientVersionSupportedByApplicationServer(); - - boolean isApplicationServerAlive(); - void executeScript(String script, Properties properties, boolean debug, MediaType media, Writer writer); - Collection<String> getIdeClientSupportedVersions(); - BranchEndpoint getBranchEndpoint(); TransactionEndpoint getTransactionEndpoint(); @@ -43,4 +37,5 @@ public interface OseeClient { IndexerEndpoint getIndexerEndpoint(); + IdeClientEndpoint getIdeClientEndpoint(); } diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java index db9b2f2a273..526b8db4c4d 100644 --- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java +++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java @@ -14,8 +14,6 @@ import java.io.StringWriter; import java.io.Writer; import java.net.URI; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; @@ -24,7 +22,6 @@ import javax.ws.rs.core.Form; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import org.eclipse.osee.framework.core.data.IOseeBranch; -import org.eclipse.osee.framework.core.data.OseeCodeVersion; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.jaxrs.client.JaxRsClient; @@ -38,7 +35,7 @@ import org.eclipse.osee.orcs.rest.client.internal.search.QueryBuilderImpl; import org.eclipse.osee.orcs.rest.client.internal.search.QueryExecutor; import org.eclipse.osee.orcs.rest.client.internal.search.QueryOptions; import org.eclipse.osee.orcs.rest.model.BranchEndpoint; -import org.eclipse.osee.orcs.rest.model.IdeVersion; +import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint; import org.eclipse.osee.orcs.rest.model.IndexerEndpoint; import org.eclipse.osee.orcs.rest.model.TransactionEndpoint; import org.eclipse.osee.orcs.rest.model.TypesEndpoint; @@ -94,34 +91,6 @@ public class OseeClientImpl implements OseeClient, QueryExecutor { } @Override - public Collection<String> getIdeClientSupportedVersions() { - IdeVersion clientResult = null; - try { - clientResult = newTarget("ide/versions").request(MediaType.APPLICATION_JSON).get(IdeVersion.class); - } catch (Exception ex) { - throw JaxRsExceptions.asOseeException(ex); - } - return clientResult != null ? clientResult.getVersions() : Collections.<String> emptySet(); - } - - @Override - public boolean isClientVersionSupportedByApplicationServer() { - return getIdeClientSupportedVersions().contains(OseeCodeVersion.getVersion()); - } - - @Override - public boolean isApplicationServerAlive() { - boolean alive = false; - try { - getIdeClientSupportedVersions(); - alive = true; - } catch (Exception ex) { - alive = false; - } - return alive; - } - - @Override public int getCount(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException { SearchResponse result = performSearch(RequestType.COUNT, branch, predicates, options); return result.getTotal(); @@ -197,4 +166,9 @@ public class OseeClientImpl implements OseeClient, QueryExecutor { public IndexerEndpoint getIndexerEndpoint() { return client.targetProxy(baseUri, IndexerEndpoint.class); } + + @Override + public IdeClientEndpoint getIdeClientEndpoint() { + return client.targetProxy(baseUri, IdeClientEndpoint.class); + } } diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/IdeClientEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/IdeClientEndpoint.java new file mode 100644 index 00000000000..788356dbad6 --- /dev/null +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/IdeClientEndpoint.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2015 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.orcs.rest.model; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +/** + * @author Roberto E. Escobar + */ +@Path("ide") +public interface IdeClientEndpoint { + + @GET + @Path("versions") + @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + IdeVersion getSupportedVersions(); + +} diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IdeClientResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IdeClientEndpointImpl.java index fc9db377e41..0347f4a9cf3 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IdeClientResource.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/IdeClientEndpointImpl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014 Boeing. + * Copyright (c) 2015 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 @@ -10,22 +10,16 @@ *******************************************************************************/ package org.eclipse.osee.orcs.rest.internal; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; import org.eclipse.osee.framework.core.data.OseeCodeVersion; +import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint; import org.eclipse.osee.orcs.rest.model.IdeVersion; /** * @author Roberto E. Escobar */ -@Path("ide") -public class IdeClientResource { +public class IdeClientEndpointImpl implements IdeClientEndpoint { - @GET - @Path("versions") - @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + @Override public IdeVersion getSupportedVersions() { IdeVersion versions = new IdeVersion(); versions.addVersion(OseeCodeVersion.getVersion()); diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java index 58d42e021be..967fb019861 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java @@ -42,7 +42,7 @@ public class OrcsApplication extends Application { resources.add(new OrcsScriptResource(engine)); classes.add(BranchesResource.class); - resources.add(new IdeClientResource()); + resources.add(new IdeClientEndpointImpl()); resources.add(new BranchEndpointImpl(orcsApi)); resources.add(new TransactionEndpointImpl(orcsApi)); diff --git a/plugins/org.eclipse.osee.x.server.integration.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.x.server.integration.tests/META-INF/MANIFEST.MF index cc4ae4f676b..29479e2db40 100644 --- a/plugins/org.eclipse.osee.x.server.integration.tests/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.osee.x.server.integration.tests/META-INF/MANIFEST.MF @@ -19,6 +19,7 @@ Import-Package: javax.ws.rs.core;version="2.0.0", org.eclipse.osee.jaxrs, org.eclipse.osee.jaxrs.client, org.eclipse.osee.orcs.rest.client, + org.eclipse.osee.orcs.rest.model, org.eclipse.osee.orcs.rest.model.search.artifact, org.hamcrest.core, org.junit, diff --git a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java index ff037acd345..72a977cf8c1 100644 --- a/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java +++ b/plugins/org.eclipse.osee.x.server.integration.tests/src/org/eclipse/osee/x/server/integration/tests/performance/OseeClientQueryTest.java @@ -19,6 +19,7 @@ import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.AccessCon import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Active; import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.io.StringWriter; import java.util.Collection; import java.util.Properties; @@ -31,6 +32,8 @@ import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.framework.jdk.core.type.Identity; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.rest.client.OseeClient; +import org.eclipse.osee.orcs.rest.model.IdeClientEndpoint; +import org.eclipse.osee.orcs.rest.model.IdeVersion; import org.eclipse.osee.orcs.rest.model.search.artifact.RequestType; import org.eclipse.osee.orcs.rest.model.search.artifact.SearchResult; import org.eclipse.osee.x.server.integration.tests.util.IntegrationUtil; @@ -197,7 +200,10 @@ public class OseeClientQueryTest { @PerfTest(threads = 1, invocations = 1) @Test public void supportedVersions() { - Collection<String> supportedVersions = createClient.getIdeClientSupportedVersions(); + IdeClientEndpoint endpoint = createClient.getIdeClientEndpoint(); + IdeVersion versions = endpoint.getSupportedVersions(); + assertNotNull(versions); + Collection<String> supportedVersions = versions.getVersions(); assertEquals(true, !supportedVersions.isEmpty()); } |