Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-09-04 19:26:59 +0000
committerRoberto E. Escobar2014-09-04 21:34:22 +0000
commit0e5f003b2994eb82a8f1f6ffbb8c362d5eff8bc8 (patch)
tree24a7a70fb4e4ccd6313bcdb9ffd31cafd04875c2 /plugins
parentb6344fd2a6dcacb733e5d5edb23de582522c0d7d (diff)
downloadorg.eclipse.osee-0e5f003b2994eb82a8f1f6ffbb8c362d5eff8bc8.tar.gz
org.eclipse.osee-0e5f003b2994eb82a8f1f6ffbb8c362d5eff8bc8.tar.xz
org.eclipse.osee-0e5f003b2994eb82a8f1f6ffbb8c362d5eff8bc8.zip
bug[ats_ATS105324]: Create a new WebTarget for each request
Update JaxRsClient interface to prevent creation of nested web targets. Change-Id: Ia59dc912d505e12536ddb0646e6429f2c913cf6f
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java104
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigurationUtil.java4
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java9
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClient.java9
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsWebTarget.java79
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientFactory.java7
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsWebTargetImpl.java129
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OAuth2Transport.java11
-rw-r--r--plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthResourceServerFilter.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java75
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java79
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/AddServer.java9
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/GetAvailableServers.java9
-rw-r--r--plugins/org.eclipse.osee.ote.master.rest.client/src/org/eclipse/osee/ote/master/rest/client/internal/RemoveServer.java10
-rw-r--r--plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/ConfigureOteServer.java18
-rw-r--r--plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/GetOteServerFile.java15
-rw-r--r--plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/PrepareOteServerFile.java10
-rw-r--r--plugins/org.eclipse.osee.ote.rest.client/src/org/eclipse/osee/ote/rest/client/internal/RunTests.java20
18 files changed, 383 insertions, 218 deletions
diff --git a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java
index 5d0840ad6b3..e583e8191f8 100644
--- a/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java
+++ b/plugins/org.eclipse.osee.account.rest.client/src/org/eclipse/osee/account/rest/client/internal/AccountClientImpl.java
@@ -12,13 +12,11 @@ package org.eclipse.osee.account.rest.client.internal;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNTS;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_ACTIVE;
-import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_ID_PARAM;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_ID_TEMPLATE;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_LOGIN;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_LOGOUT;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_PREFERENCES;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_SESSSIONS;
-import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_USERNAME;
import static org.eclipse.osee.account.rest.model.AccountContexts.ACCOUNT_USERNAME_TEMPLATE;
import java.net.URI;
import java.util.ArrayList;
@@ -26,8 +24,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@@ -47,6 +43,7 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ResultSets;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.jaxrs.client.JaxRsExceptions;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
/**
* @author Roberto E. Escobar
@@ -54,29 +51,30 @@ import org.eclipse.osee.jaxrs.client.JaxRsExceptions;
public class AccountClientImpl implements AccountClient {
private static final String OSEE_APPLICATION_SERVER = "osee.application.server";
- private WebTarget baseTarget;
- private WebTarget accountTarget;
+
+ private volatile JaxRsClient client;
+ private volatile URI baseUri;
public void start(Map<String, Object> properties) {
update(properties);
}
public void stop() {
- baseTarget = null;
- accountTarget = null;
+ client = null;
+ baseUri = null;
}
public void update(Map<String, Object> properties) {
- JaxRsClient client = JaxRsClient.newBuilder().properties(properties).build();
-
+ client = JaxRsClient.newBuilder().properties(properties).build();
String address = properties != null ? (String) properties.get(OSEE_APPLICATION_SERVER) : null;
if (address == null) {
address = System.getProperty(OSEE_APPLICATION_SERVER, "");
}
+ baseUri = UriBuilder.fromUri(address).build();
+ }
- URI uri = UriBuilder.fromUri(address).build();
- baseTarget = client.target(uri);
- accountTarget = baseTarget.path(ACCOUNTS);
+ private JaxRsWebTarget newTarget(URI uri) {
+ return client.target(uri);
}
@Override
@@ -86,9 +84,10 @@ public class AccountClientImpl implements AccountClient {
data.setPassword(password);
data.setScheme(scheme);
- WebTarget resource = accountTarget.path(ACCOUNT_LOGIN);
+ URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_LOGIN).build();
try {
- return resource.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(data), AccountSessionData.class);
+ return newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(data),
+ AccountSessionData.class);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
@@ -96,9 +95,9 @@ public class AccountClientImpl implements AccountClient {
@Override
public boolean logout(AccountSessionData session) {
- WebTarget resource = accountTarget.path(ACCOUNT_LOGOUT);
+ URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_LOGOUT).build();
try {
- Response response = resource.request().post(Entity.json(session));
+ Response response = newTarget(uri).request().post(Entity.json(session));
return Status.OK.getStatusCode() == response.getStatus();
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
@@ -107,9 +106,9 @@ public class AccountClientImpl implements AccountClient {
@Override
public AccountInfoData createAccount(String userName, AccountInput input) {
- WebTarget resource = accountTarget.path(ACCOUNT_USERNAME_TEMPLATE).resolveTemplate(ACCOUNT_USERNAME, userName);
+ URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_USERNAME_TEMPLATE).build(userName);
try {
- return resource.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(input), AccountInfoData.class);
+ return newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(input), AccountInfoData.class);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
@@ -117,9 +116,9 @@ public class AccountClientImpl implements AccountClient {
@Override
public boolean deleteAccount(String accountId) {
- WebTarget resource = accountTarget.path(ACCOUNT_ID_TEMPLATE).resolveTemplate(ACCOUNT_ID_PARAM, accountId);
+ URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).build(accountId);
try {
- Response response = resource.request().delete();
+ Response response = newTarget(uri).request().delete();
return Status.OK.getStatusCode() == response.getStatus();
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
@@ -128,11 +127,11 @@ public class AccountClientImpl implements AccountClient {
@Override
public ResultSet<AccountSessionDetailsData> getAccountSessionDataByUniqueField(String accountId) {
- WebTarget resource =
- accountTarget.path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_SESSSIONS).resolveTemplate(ACCOUNT_ID_PARAM, accountId);
+ URI uri =
+ UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_SESSSIONS).build(accountId);
try {
AccountSessionDetailsData[] data =
- resource.request(MediaType.APPLICATION_JSON_TYPE).get(AccountSessionDetailsData[].class);
+ newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(AccountSessionDetailsData[].class);
return ResultSets.newResultSet(data);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
@@ -141,9 +140,10 @@ public class AccountClientImpl implements AccountClient {
@Override
public ResultSet<AccountInfoData> getAllAccounts() {
+ URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).build();
try {
AccountInfoData[] accounts =
- accountTarget.request(MediaType.APPLICATION_JSON_TYPE).get(AccountInfoData[].class);
+ newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(AccountInfoData[].class);
return ResultSets.newResultSet(accounts);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
@@ -152,9 +152,9 @@ public class AccountClientImpl implements AccountClient {
@Override
public AccountDetailsData getAccountDetailsByUniqueField(String accountId) {
- WebTarget resource = accountTarget.path(ACCOUNT_ID_TEMPLATE).resolveTemplate(ACCOUNT_ID_PARAM, accountId);
+ URI uri = UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).build(accountId);
try {
- return resource.request(MediaType.APPLICATION_JSON_TYPE).get(AccountDetailsData.class);
+ return newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(AccountDetailsData.class);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
@@ -162,10 +162,10 @@ public class AccountClientImpl implements AccountClient {
@Override
public AccountPreferencesData getAccountPreferencesByUniqueField(String accountId) {
- WebTarget resource =
- accountTarget.path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_PREFERENCES).resolveTemplate(ACCOUNT_ID_PARAM, accountId);
+ URI uri =
+ UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_PREFERENCES).build(accountId);
try {
- return resource.request(MediaType.APPLICATION_JSON_TYPE).get(AccountPreferencesData.class);
+ return newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(AccountPreferencesData.class);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
@@ -173,41 +173,43 @@ public class AccountClientImpl implements AccountClient {
@Override
public boolean setAccountActive(String accountId, boolean active) {
- WebTarget resource =
- accountTarget.path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_ACTIVE).resolveTemplate(ACCOUNT_ID_PARAM, accountId);
+ URI uri =
+ UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_ACTIVE).build(accountId);
+
boolean result;
if (active) {
- result = setAccountActive(resource);
+ result = setAccountActive(uri);
} else {
- result = setAccountInActive(resource);
+ result = setAccountInActive(uri);
}
return result;
}
@Override
public boolean isAccountActive(String accountId) {
- WebTarget resource =
- accountTarget.path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_ACTIVE).resolveTemplate(ACCOUNT_ID_PARAM, accountId);
+ URI uri =
+ UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_ACTIVE).build(accountId);
+
try {
- AccountActiveData data = resource.request(MediaType.APPLICATION_JSON_TYPE).get(AccountActiveData.class);
+ AccountActiveData data = newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(AccountActiveData.class);
return data.isActive();
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
}
- private boolean setAccountActive(WebTarget resource) {
+ private boolean setAccountActive(URI uri) {
try {
- Response response = resource.request().put(null);
+ Response response = newTarget(uri).request().put(null);
return Status.OK.getStatusCode() == response.getStatus();
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
}
- private boolean setAccountInActive(WebTarget resource) {
+ private boolean setAccountInActive(URI uri) {
try {
- Response response = resource.request().delete();
+ Response response = newTarget(uri).request().delete();
return Status.OK.getStatusCode() == response.getStatus();
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
@@ -216,13 +218,13 @@ public class AccountClientImpl implements AccountClient {
@Override
public boolean setAccountPreferences(String accountId, Map<String, String> preferences) {
- WebTarget resource =
- accountTarget.path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_PREFERENCES).resolveTemplate(ACCOUNT_ID_PARAM, accountId);
+ URI uri =
+ UriBuilder.fromUri(baseUri).path(ACCOUNTS).path(ACCOUNT_ID_TEMPLATE).path(ACCOUNT_PREFERENCES).build(accountId);
AccountPreferencesInput input = new AccountPreferencesInput();
input.setMap(preferences);
try {
- Response response = resource.request().put(Entity.json(input));
+ Response response = newTarget(uri).request().put(Entity.json(input));
return Status.OK.getStatusCode() == response.getStatus();
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
@@ -230,21 +232,17 @@ public class AccountClientImpl implements AccountClient {
}
private ResultSet<SubscriptionData> getSubscriptionsForAccount(String userId) {
- WebTarget resource =
- baseTarget.path("subscriptions/for-account/{account-id}").resolveTemplate(ACCOUNT_ID_PARAM, userId);
- Builder builder = resource.request(MediaType.APPLICATION_JSON_TYPE);
+ URI uri =
+ UriBuilder.fromUri(baseUri).path("subscriptions").path("for-account").path("{account-id}").build(userId);
try {
- SubscriptionData[] data = builder.get(SubscriptionData[].class);
+ SubscriptionData[] data =
+ newTarget(uri).request(MediaType.APPLICATION_JSON_TYPE).get(SubscriptionData[].class);
return ResultSets.newResultSet(data);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
}
- private UriBuilder newUnsubscribeBuilder() {
- return baseTarget.getUriBuilder().path("unsubscribe").path("ui").path("{subscription-uuid}");
- }
-
@Override
public ResultSet<UnsubscribeInfo> getUnsubscribeUris(String userUuid, Collection<String> groupNames) {
ResultSet<UnsubscribeInfo> toReturn = ResultSets.emptyResultSet();
@@ -252,7 +250,7 @@ public class AccountClientImpl implements AccountClient {
if (!results.isEmpty()) {
List<UnsubscribeInfo> infos = new ArrayList<UnsubscribeInfo>();
- UriBuilder builder = newUnsubscribeBuilder();
+ UriBuilder builder = UriBuilder.fromUri(baseUri).path("unsubscribe").path("ui").path("{subscription-uuid}");
for (SubscriptionData subscription : results) {
if (subscription.isActive() && groupNames.contains(subscription.getName())) {
String name = subscription.getName();
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigurationUtil.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigurationUtil.java
index 9253dad868b..e65c0615a6b 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigurationUtil.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsConfigurationUtil.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.ats.config;
import java.net.URI;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.ats.api.config.AtsConfigurations;
@@ -27,9 +26,8 @@ public class AtsConfigurationUtil {
public static AtsConfigurations getConfigurations() {
String appServer = OseeClientProperties.getOseeApplicationServer();
URI uri = UriBuilder.fromUri(appServer).path("ats").path("config").build();
- WebTarget resource = JaxRsClient.newClient().target(uri);
try {
- return resource.request(MediaType.APPLICATION_JSON).get(AtsConfigurations.class);
+ return JaxRsClient.newClient().target(uri).request(MediaType.APPLICATION_JSON).get(AtsConfigurations.class);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java
index f726dc577f9..7c17d4a8a11 100644
--- a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java
@@ -15,7 +15,6 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.net.URI;
import java.net.URISyntaxException;
-import javax.ws.rs.client.WebTarget;
import org.eclipse.osee.jaxrs.client.JaxRsClient.JaxRsClientFactory;
import org.junit.Before;
import org.junit.Test;
@@ -37,7 +36,7 @@ public class JaxRsClientTest {
//@formatter:off
@Mock private JaxRsClientFactory factory;
@Mock private JaxRsClientConfig config;
- @Mock private WebTarget target;
+ @Mock private JaxRsWebTarget target;
//@formatter:on
private JaxRsClient client;
@@ -53,7 +52,7 @@ public class JaxRsClientTest {
public void testTargetEmpty() {
when(factory.newTarget(config, null)).thenReturn(target);
- WebTarget actual = client.target();
+ JaxRsWebTarget actual = client.target();
assertEquals(target, actual);
verify(factory).newTarget(config, null);
}
@@ -62,7 +61,7 @@ public class JaxRsClientTest {
public void testTargetString() {
when(factory.newTarget(config, URI_STRING)).thenReturn(target);
- WebTarget actual = client.target(URI_STRING);
+ JaxRsWebTarget actual = client.target(URI_STRING);
assertEquals(target, actual);
verify(factory).newTarget(config, URI_STRING);
}
@@ -73,7 +72,7 @@ public class JaxRsClientTest {
when(factory.newTarget(config, URI)).thenReturn(target);
- WebTarget actual = client.target(expectedUri);
+ JaxRsWebTarget actual = client.target(expectedUri);
assertEquals(target, actual);
verify(factory).newTarget(config, URI);
}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClient.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClient.java
index e42ee55c2f4..b7a6b15e426 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClient.java
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsClient.java
@@ -12,7 +12,6 @@ package org.eclipse.osee.jaxrs.client;
import java.net.URI;
import java.util.Map;
-import javax.ws.rs.client.WebTarget;
import org.eclipse.osee.jaxrs.client.JaxRsClientConstants.ConnectionType;
import org.eclipse.osee.jaxrs.client.JaxRsClientConstants.ProxyType;
import org.eclipse.osee.jaxrs.client.internal.JaxRsClientRuntime;
@@ -26,7 +25,7 @@ public final class JaxRsClient {
<T> T newClient(JaxRsClientConfig config, String serverAddress, Class<T> clazz);
- WebTarget newTarget(JaxRsClientConfig config, String serverAddress);
+ JaxRsWebTarget newTarget(JaxRsClientConfig config, String serverAddress);
}
public static JaxRsClientBuilder newBuilder() {
@@ -68,7 +67,7 @@ public final class JaxRsClient {
*
* @return target
*/
- public WebTarget target() {
+ public JaxRsWebTarget target() {
return target((String) null);
}
@@ -78,7 +77,7 @@ public final class JaxRsClient {
* @param baseAddress
* @return target
*/
- public WebTarget target(URI address) {
+ public JaxRsWebTarget target(URI address) {
return target(address != null ? address.toString() : null);
}
@@ -88,7 +87,7 @@ public final class JaxRsClient {
* @param baseAddress
* @return target
*/
- public WebTarget target(String address) {
+ public JaxRsWebTarget target(String address) {
return factory.newTarget(config, address);
}
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsWebTarget.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsWebTarget.java
new file mode 100644
index 00000000000..aac75141383
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/JaxRsWebTarget.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.jaxrs.client;
+
+import java.net.URI;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.core.Configurable;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+/**
+ * Facade over WebTarget
+ *
+ * @author Roberto E. Escobar
+ */
+public interface JaxRsWebTarget extends Configurable<JaxRsWebTarget> {
+
+ /**
+ * Get the URI identifying the resource.
+ *
+ * @return the resource URI.
+ */
+ public URI getUri();
+
+ /**
+ * Get the URI builder initialized with the {@link URI} of the current resource target. The returned URI builder is
+ * detached from the target, i.e. any updates in the URI builder MUST NOT have any effects on the URI of the
+ * originating target.
+ *
+ * @return the initialized URI builder.
+ */
+ public UriBuilder getUriBuilder();
+
+ /**
+ * Start building a request to the targeted web resource.
+ *
+ * @return builder for a request targeted at the URI referenced by this target instance.
+ */
+ public Invocation.Builder request();
+
+ /**
+ * Start building a request to the targeted web resource and define the accepted response media types.
+ * <p>
+ * Invoking this method is identical to:
+ * </p>
+ *
+ * <pre>
+ * webTarget.request().accept(types);
+ * </pre>
+ *
+ * @param acceptedResponseTypes accepted response media types.
+ * @return builder for a request targeted at the URI referenced by this target instance.
+ */
+ public Invocation.Builder request(String... acceptedResponseTypes);
+
+ /**
+ * Start building a request to the targeted web resource and define the accepted response media types.
+ * <p>
+ * Invoking this method is identical to:
+ * </p>
+ *
+ * <pre>
+ * webTarget.request().accept(types);
+ * </pre>
+ *
+ * @param acceptedResponseTypes accepted response media types.
+ * @return builder for a request targeted at the URI referenced by this target instance.
+ */
+ public Invocation.Builder request(MediaType... acceptedResponseTypes);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientFactory.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientFactory.java
index 98e60cf1d21..8ce2ecdc56a 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientFactory.java
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientFactory.java
@@ -18,8 +18,9 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.transport.http.HTTPConduit;
import org.eclipse.osee.jaxrs.client.JaxRsClient.JaxRsClientFactory;
-import org.eclipse.osee.jaxrs.client.internal.JaxRsClientConfigurator;
import org.eclipse.osee.jaxrs.client.JaxRsClientConfig;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
+import org.eclipse.osee.jaxrs.client.internal.JaxRsClientConfigurator;
/**
* @author Roberto E. Escobar
@@ -41,7 +42,7 @@ public class CxfJaxRsClientFactory implements JaxRsClientFactory {
* @return target
*/
@Override
- public WebTarget newTarget(JaxRsClientConfig config, String serverAddress) {
+ public JaxRsWebTarget newTarget(JaxRsClientConfig config, String serverAddress) {
ClientBuilder builder = ClientBuilder.newBuilder();
configurator.configureClientBuilder(config, builder);
@@ -53,7 +54,7 @@ public class CxfJaxRsClientFactory implements JaxRsClientFactory {
target.request();
configureConnection(config, target);
- return target;
+ return new JaxRsWebTargetImpl(target);
}
/**
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsWebTargetImpl.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsWebTargetImpl.java
new file mode 100644
index 00000000000..3a9a5f0fd9c
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsWebTargetImpl.java
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.jaxrs.client.internal.ext;
+
+import java.net.URI;
+import java.util.Map;
+import javax.ws.rs.client.Invocation.Builder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Configuration;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.client.spec.ClientImpl.WebTargetImpl;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
+
+/**
+ * Facade over WebTarget
+ *
+ * @author Roberto E. Escobar
+ */
+public class JaxRsWebTargetImpl implements JaxRsWebTarget {
+
+ private final WebTarget target;
+
+ public JaxRsWebTargetImpl(WebTarget target) {
+ this.target = target;
+ }
+
+ @Override
+ public Configuration getConfiguration() {
+ return target.getConfiguration();
+ }
+
+ @Override
+ public JaxRsWebTarget property(String name, Object value) {
+ target.property(name, value);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Class<?> componentClass) {
+ target.register(componentClass);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Class<?> componentClass, int priority) {
+ target.register(componentClass, priority);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Class<?> componentClass, Class<?>... contracts) {
+ target.register(componentClass, contracts);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Class<?> componentClass, Map<Class<?>, Integer> contracts) {
+ target.register(componentClass, contracts);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Object component) {
+ target.register(component);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Object component, int priority) {
+ target.register(component, priority);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Object component, Class<?>... contracts) {
+ target.register(component, contracts);
+ return this;
+ }
+
+ @Override
+ public JaxRsWebTarget register(Object component, Map<Class<?>, Integer> contracts) {
+ target.register(component, contracts);
+ return this;
+ }
+
+ @Override
+ public URI getUri() {
+ return target.getUri();
+ }
+
+ @Override
+ public UriBuilder getUriBuilder() {
+ return target.getUriBuilder();
+ }
+
+ @Override
+ public Builder request() {
+ return target.request();
+ }
+
+ @Override
+ public Builder request(String... acceptedResponseTypes) {
+ return target.request(acceptedResponseTypes);
+ }
+
+ @Override
+ public Builder request(MediaType... acceptedResponseTypes) {
+ return target.request(acceptedResponseTypes);
+ }
+
+ protected WebClient getWebClient() {
+ WebClient webClient = null;
+ if (target instanceof WebTargetImpl) {
+ webClient = ((WebTargetImpl) target).getWebClient();
+ }
+ return webClient;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OAuth2Transport.java b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OAuth2Transport.java
index 4f7edd79657..9fff238cb67 100644
--- a/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OAuth2Transport.java
+++ b/plugins/org.eclipse.osee.jaxrs.client/src/org/eclipse/osee/jaxrs/client/internal/ext/OAuth2Transport.java
@@ -15,13 +15,11 @@ import java.util.Map;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation.Builder;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.client.spec.ClientImpl.WebTargetImpl;
import org.apache.cxf.rs.security.oauth2.client.OAuthClientUtils;
import org.apache.cxf.rs.security.oauth2.client.OAuthClientUtils.Consumer;
import org.apache.cxf.rs.security.oauth2.common.AccessTokenValidation;
@@ -32,6 +30,7 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.jaxrs.client.JaxRsClient.JaxRsClientBuilder;
import org.eclipse.osee.jaxrs.client.JaxRsExceptions;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
import org.eclipse.osee.jaxrs.client.internal.ext.OAuth2Flows.OwnerCredentials;
/**
@@ -92,7 +91,7 @@ public class OAuth2Transport {
}
private WebClient newWebClient(OwnerCredentials credentials, String uri, String sessionCookie) {
- WebTarget target;
+ JaxRsWebTarget target;
if (Strings.isValid(sessionCookie)) {
target = JaxRsClient.newClient().target(uri);
} else {
@@ -103,10 +102,10 @@ public class OAuth2Transport {
}
WebClient webClient = null;
- if (target instanceof WebTargetImpl) {
- webClient = ((WebTargetImpl) target).getWebClient();
+ if (target instanceof JaxRsWebTargetImpl) {
+ webClient = ((JaxRsWebTargetImpl) target).getWebClient();
}
- if (Strings.isValid(sessionCookie)) {
+ if (webClient != null && Strings.isValid(sessionCookie)) {
webClient.header(HttpHeaders.COOKIE, sessionCookie);
}
return webClient;
diff --git a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthResourceServerFilter.java b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthResourceServerFilter.java
index 1b9953833d0..b4d147a428a 100644
--- a/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthResourceServerFilter.java
+++ b/plugins/org.eclipse.osee.jaxrs.server/src/org/eclipse/osee/jaxrs/server/security/JaxRsOAuthResourceServerFilter.java
@@ -16,7 +16,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.Form;
@@ -32,6 +31,7 @@ import org.apache.cxf.security.SecurityContext;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
import org.eclipse.osee.jaxrs.server.internal.security.oauth2.OAuthUtil;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
@@ -213,7 +213,7 @@ public class JaxRsOAuthResourceServerFilter implements ContainerRequestFilter {
Form form = new Form();
form.param(OAuthConstants.AUTHORIZATION_SCHEME_TYPE, authScheme);
form.param(OAuthConstants.AUTHORIZATION_SCHEME_DATA, accessToken);
- WebTarget target = client.target(validationServerUri);
+ JaxRsWebTarget target = client.target(validationServerUri);
return target.request().post(Entity.form(form), AccessTokenValidation.class);
}
}
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 6832bf9095b..27c9b8f8257 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,34 +14,41 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.client.Entity;
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.jaxrs.client.JaxRsClient;
import org.eclipse.osee.jaxrs.client.JaxRsExceptions;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.eclipse.osee.orcs.rest.client.QueryBuilder;
import org.eclipse.osee.orcs.rest.client.internal.search.PredicateFactory;
import org.eclipse.osee.orcs.rest.client.internal.search.PredicateFactoryImpl;
import org.eclipse.osee.orcs.rest.client.internal.search.QueryBuilderImpl;
-import org.eclipse.osee.orcs.rest.client.internal.search.QueryExecutorV1;
+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.Client;
+import org.eclipse.osee.orcs.rest.model.search.artifact.OutputFormat;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
+import org.eclipse.osee.orcs.rest.model.search.artifact.RequestType;
+import org.eclipse.osee.orcs.rest.model.search.artifact.SearchRequest;
+import org.eclipse.osee.orcs.rest.model.search.artifact.SearchResponse;
+import org.eclipse.osee.orcs.rest.model.search.artifact.SearchResult;
/**
* @author John Misinco
* @author Roberto E. Escobar
*/
-public class OseeClientImpl implements OseeClient {
+public class OseeClientImpl implements OseeClient, QueryExecutor {
private static final String OSEE_APPLICATION_SERVER = "osee.application.server";
- private volatile PredicateFactory predicateFactory;
- private volatile QueryExecutorV1 executor;
- private volatile WebTarget baseTarget;
+ private PredicateFactory predicateFactory;
+ private volatile JaxRsClient client;
+ private volatile URI baseUri;
public void start(Map<String, Object> properties) {
predicateFactory = new PredicateFactoryImpl();
@@ -50,38 +57,38 @@ public class OseeClientImpl implements OseeClient {
}
public void stop() {
- executor = null;
- baseTarget = null;
+ client = null;
+ baseUri = null;
predicateFactory = null;
}
public void update(Map<String, Object> properties) {
- JaxRsClient client = JaxRsClient.newBuilder().properties(properties).build();
-
+ client = JaxRsClient.newBuilder().properties(properties).build();
String address = properties != null ? (String) properties.get(OSEE_APPLICATION_SERVER) : null;
if (address == null) {
address = System.getProperty(OSEE_APPLICATION_SERVER, "");
}
+ baseUri = UriBuilder.fromUri(address).path("orcs").build();
+ }
- URI uri = UriBuilder.fromUri(address).path("orcs").build();
- baseTarget = client.target(uri);
- executor = new QueryExecutorV1(baseTarget);
+ private JaxRsWebTarget newTarget(String path, Object... values) {
+ URI uri = UriBuilder.fromUri(baseUri).path(path).build(values);
+ return client.target(uri);
}
@Override
public QueryBuilder createQueryBuilder(IOseeBranch branch) {
QueryOptions options = new QueryOptions();
List<Predicate> predicates = new ArrayList<Predicate>();
- return new QueryBuilderImpl(branch, predicates, options, predicateFactory, executor);
+ return new QueryBuilderImpl(branch, predicates, options, predicateFactory, this);
}
@Override
public boolean isClientVersionSupportedByApplicationServer() {
boolean result = false;
- WebTarget resource = baseTarget.path("client");
Client clientResult = null;
try {
- clientResult = resource.request(MediaType.APPLICATION_JSON).get(Client.class);
+ clientResult = newTarget("client").request(MediaType.APPLICATION_JSON).get(Client.class);
} catch (Exception ex) {
throw JaxRsExceptions.asOseeException(ex);
}
@@ -102,4 +109,40 @@ public class OseeClientImpl implements OseeClient {
}
return alive;
}
+
+ @Override
+ public int getCount(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
+ SearchResponse result = performSearch(RequestType.COUNT, OutputFormat.XML, branch, predicates, options);
+ return result.getTotal();
+ }
+
+ @Override
+ public SearchResult getResults(RequestType request, IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
+ SearchResponse result = performSearch(request, OutputFormat.XML, branch, predicates, options);
+ return result;
+ }
+
+ private SearchResponse performSearch(RequestType requestType, OutputFormat outputFormat, IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
+ int fromTx = 0;
+ if (options.isHistorical()) {
+ fromTx = options.getFromTransaction();
+ }
+
+ boolean includeDeleted = false;
+ if (options.areDeletedIncluded()) {
+ includeDeleted = true;
+ }
+
+ SearchRequest params =
+ new SearchRequest(branch.getUuid(), predicates, outputFormat.name().toLowerCase(),
+ requestType.name().toLowerCase(), fromTx, includeDeleted);
+
+ JaxRsWebTarget resource = newTarget("branch/{branch-uuid}/artifact/search/v1", branch.getUuid());
+ try {
+ return resource.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(params), SearchResponse.class);
+ } catch (Exception ex) {
+ throw JaxRsExceptions.asOseeException(ex);
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
deleted file mode 100644
index e2eb08a8a13..00000000000
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/search/QueryExecutorV1.java
+++ /dev/null
@@ -1,79 +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.orcs.rest.client.internal.search;
-
-import java.util.List;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
-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.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.jaxrs.client.JaxRsExceptions;
-import org.eclipse.osee.orcs.rest.model.search.artifact.OutputFormat;
-import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
-import org.eclipse.osee.orcs.rest.model.search.artifact.RequestType;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchRequest;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchResponse;
-import org.eclipse.osee.orcs.rest.model.search.artifact.SearchResult;
-
-/**
- * @author John Misinco
- */
-public class QueryExecutorV1 implements QueryExecutor {
-
- public static interface BaseUriBuilder {
- UriBuilder newBuilder();
- }
-
- private final WebTarget target;
-
- public QueryExecutorV1(WebTarget target) {
- super();
- this.target = target;
- }
-
- @Override
- public int getCount(IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
- SearchResponse result = performSearch(RequestType.COUNT, OutputFormat.XML, branch, predicates, options);
- return result.getTotal();
- }
-
- @Override
- public SearchResult getResults(RequestType request, IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
- SearchResponse result = performSearch(request, OutputFormat.XML, branch, predicates, options);
- return result;
- }
-
- private SearchResponse performSearch(RequestType requestType, OutputFormat outputFormat, IOseeBranch branch, List<Predicate> predicates, QueryOptions options) throws OseeCoreException {
- int fromTx = 0;
- if (options.isHistorical()) {
- fromTx = options.getFromTransaction();
- }
-
- boolean includeDeleted = false;
- if (options.areDeletedIncluded()) {
- includeDeleted = true;
- }
-
- SearchRequest params =
- new SearchRequest(branch.getUuid(), predicates, outputFormat.name().toLowerCase(),
- requestType.name().toLowerCase(), fromTx, includeDeleted);
-
- WebTarget resource =
- target.path("branch/{branch-uuid}/artifact/search/v1").resolveTemplate("branch-uuid", branch.getUuid());
- try {
- return resource.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(params), SearchResponse.class);
- } catch (Exception ex) {
- throw JaxRsExceptions.asOseeException(ex);
- }
- }
-}
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 32fd2687565..0dc70eee8c7 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
@@ -3,8 +3,8 @@ package org.eclipse.osee.ote.master.rest.client.internal;
import java.net.URI;
import java.util.concurrent.Callable;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
@@ -23,11 +23,12 @@ public class AddServer implements Callable<OTEMasterServerResult> {
@Override
public OTEMasterServerResult call() throws Exception {
+ URI targetUri =
+ UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).build();
+
OTEMasterServerResult result = new OTEMasterServerResult();
try {
- WebTarget resource = webClientProvider.target(uri);
- resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).request(
- MediaType.APPLICATION_XML).post(Entity.xml(server));
+ webClientProvider.target(targetUri).request(MediaType.APPLICATION_XML).post(Entity.xml(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 a3af0bd4379..57bc86f2347 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,8 +2,8 @@ package org.eclipse.osee.ote.master.rest.client.internal;
import java.net.URI;
import java.util.concurrent.Callable;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerAvailableNodes;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
@@ -20,12 +20,13 @@ public class GetAvailableServers implements Callable<OTEMasterServerAvailableNod
@Override
public OTEMasterServerAvailableNodes call() throws Exception {
+ URI targetUri =
+ UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).build();
+
OTEMasterServerAvailableNodes result = new OTEMasterServerAvailableNodes();
try {
- WebTarget resource = webClientProvider.target(uri);
OTEServer[] servers =
- resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).request(
- MediaType.APPLICATION_XML).get(OTEServer[].class);
+ webClientProvider.target(targetUri).request(MediaType.APPLICATION_XML).get(OTEServer[].class);
result.setServers(servers);
result.setSuccess(true);
} catch (Throwable th) {
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 5cfed8e621c..b966e07956d 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
@@ -4,8 +4,8 @@ import java.net.URI;
import java.util.concurrent.Callable;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.ote.master.rest.client.OTEMasterServerResult;
import org.eclipse.osee.ote.master.rest.model.OTEServer;
@@ -24,11 +24,13 @@ public class RemoveServer implements Callable<OTEMasterServerResult> {
@Override
public OTEMasterServerResult call() throws Exception {
+ URI targetUri =
+ UriBuilder.fromUri(uri).path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).build();
+
OTEMasterServerResult result = new OTEMasterServerResult();
try {
- WebTarget resource = webClientProvider.target(uri);
- resource.path(OTEMasterServerImpl.CONTEXT_NAME).path(OTEMasterServerImpl.CONTEXT_SERVERS).request(
- MediaType.APPLICATION_XML).method(HttpMethod.DELETE, Entity.xml(server));
+ webClientProvider.target(targetUri).request(MediaType.APPLICATION_XML).method(HttpMethod.DELETE,
+ Entity.xml(server));
} catch (Throwable th) {
result.setSuccess(false);
result.setThrowable(th);
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 5ed3c9433a0..7ac8af368f2 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
@@ -5,10 +5,11 @@ import java.net.InetAddress;
import java.net.URI;
import java.util.List;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.framework.jdk.core.util.network.PortUtil;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
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;
@@ -65,7 +66,7 @@ public class ConfigureOteServer extends BaseClientCallable<Progress> {
private void waitForJobComplete() throws Exception {
URI jobUri = status.getUpdatedJobStatus().toURI();
- final WebTarget service = factory.target(jobUri);
+ final JaxRsWebTarget service = factory.target(jobUri);
while (!status.isJobComplete()) {
Thread.sleep(POLLING_RATE);
@@ -76,7 +77,8 @@ public class ConfigureOteServer extends BaseClientCallable<Progress> {
}
private OTEJobStatus sendBundleConfiguration() throws Exception {
- WebTarget baseService = factory.target(uri);
+ URI targetUri = UriBuilder.fromUri(uri).path("ote").path("config").build();
+
if (configuration == null) {
OTEConfiguration localConfiguration = new OTEConfiguration();
OTEConfigurationIdentity identity = new OTEConfigurationIdentity();
@@ -92,19 +94,19 @@ public class ConfigureOteServer extends BaseClientCallable<Progress> {
localConfiguration.addItem(item);
}
OTEConfiguration currentConfig =
- baseService.path("ote").path("config").request(MediaType.APPLICATION_JSON).get(OTEConfiguration.class);
+ factory.target(targetUri).request(MediaType.APPLICATION_JSON).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").request(MediaType.APPLICATION_JSON).post(
- Entity.xml(localConfiguration), OTEJobStatus.class);
+ return factory.target(targetUri).request(MediaType.APPLICATION_JSON).post(Entity.xml(localConfiguration),
+ OTEJobStatus.class);
}
} else {
- return baseService.path("ote").path("config").request(MediaType.APPLICATION_JSON).post(
- Entity.xml(configuration), OTEJobStatus.class);
+ return factory.target(targetUri).request(MediaType.APPLICATION_JSON).post(Entity.xml(configuration),
+ OTEJobStatus.class);
}
}
}
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 f1e23d5f4f2..17c90b13c17 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,10 +4,10 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URI;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.ote.rest.client.Progress;
@@ -32,19 +32,14 @@ public class GetOteServerFile extends BaseClientCallable<Progress> {
@Override
public void doWork() throws Exception {
- WebTarget client = factory.target(uri);
- Response response =
- client.queryParam("path", filePath).path("ote").path("file").request(MediaType.APPLICATION_JSON).get();
+ URI targetUri = UriBuilder.fromUri(uri).path("ote").path("file").queryParam("path", filePath).build();
+
+ Response response = factory.target(targetUri).request(MediaType.APPLICATION_JSON).get();
if (response.getStatus() == Status.OK.getStatusCode()) {
InputStream is = (InputStream) response.getEntity();
FileOutputStream fos = new FileOutputStream(destination);
try {
- byte[] data = new byte[2048];
- int numRead = 0;
- while ((numRead = is.read(data)) != -1) {
- fos.write(data, 0, numRead);
- }
- fos.flush();
+ Lib.inputStreamToOutputStream(is, fos);
} finally {
Lib.close(fos);
}
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 5faab98df70..59a4a1d62de 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
@@ -3,9 +3,10 @@ package org.eclipse.osee.ote.rest.client.internal;
import java.net.URI;
import java.util.List;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
import org.eclipse.osee.ote.rest.client.OTECacheItem;
import org.eclipse.osee.ote.rest.client.Progress;
import org.eclipse.osee.ote.rest.model.OTEConfiguration;
@@ -47,7 +48,7 @@ public class PrepareOteServerFile extends BaseClientCallable<Progress> {
private void waitForJobComplete() throws Exception {
URI jobUri = status.getUpdatedJobStatus().toURI();
- final WebTarget service = factory.target(jobUri);
+ JaxRsWebTarget service = factory.target(jobUri);
while (!status.isJobComplete()) {
Thread.sleep(POLLING_RATE);
@@ -70,9 +71,8 @@ public class PrepareOteServerFile extends BaseClientCallable<Progress> {
item.setMd5Digest(bundleInfo.getMd5());
configuration.addItem(item);
}
- WebTarget baseService = factory.target(uri);
-
- return baseService.path("ote").path("cache").request(MediaType.APPLICATION_JSON).post(Entity.json(configuration),
+ URI targetUri = UriBuilder.fromUri(uri).path("ote").path("cache").build();
+ return factory.target(targetUri).request(MediaType.APPLICATION_JSON).post(Entity.json(configuration),
OTEJobStatus.class);
}
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 775c76c31d7..f28be597355 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
@@ -4,14 +4,15 @@ import java.net.URI;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
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;
+
public class RunTests implements ProgressWithCancel, Callable<ProgressWithCancel> {
private final URI uri;
@@ -38,12 +39,10 @@ public class RunTests implements ProgressWithCancel, Callable<ProgressWithCancel
@Override
public boolean cancelSingle() {
- WebTarget baseService;
+ URI targetUri = UriBuilder.fromUri(uri).path("ote").path("run").path("{run-id}").build(id);
try {
- baseService = factory.target(uri);
OTEJobStatus cancelStatus =
- baseService.path("ote").path("run").path(id).request(MediaType.APPLICATION_JSON).put(Entity.json(""),
- OTEJobStatus.class);
+ factory.target(targetUri).request(MediaType.APPLICATION_JSON).put(Entity.json(""), OTEJobStatus.class);
return cancelStatus.isSuccess();
} catch (Exception e) {
OseeLog.log(getClass(), Level.SEVERE, e);
@@ -52,18 +51,17 @@ public class RunTests implements ProgressWithCancel, Callable<ProgressWithCancel
}
private OTEJobStatus sendCommand() throws Exception {
- WebTarget baseService = factory.target(uri);
- return baseService.path("ote").path("run").request(MediaType.APPLICATION_JSON).post(Entity.json(tests),
- OTEJobStatus.class);
+ URI targetUri = UriBuilder.fromUri(uri).path("ote").path("run").build();
+ return factory.target(targetUri).request(MediaType.APPLICATION_JSON).post(Entity.json(tests), OTEJobStatus.class);
}
@Override
public boolean cancelAll() {
- WebTarget baseService;
+ URI targetUri = UriBuilder.fromUri(uri).path("ote").path("run").path("{run-id}").build(id);
+
try {
- baseService = factory.target(uri);
OTEJobStatus cancelStatus =
- baseService.path("ote").path("run").path(id).request(MediaType.APPLICATION_JSON).delete(OTEJobStatus.class);
+ factory.target(targetUri).request(MediaType.APPLICATION_JSON).delete(OTEJobStatus.class);
return cancelStatus.isSuccess();
} catch (Exception e) {
OseeLog.log(getClass(), Level.SEVERE, e);

Back to the top