Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaily.Roberts2022-04-12 00:15:00 +0000
committerBaily Robers2022-04-27 20:46:16 +0000
commitad0129832390f5a70ac8d710497696420cb78a5a (patch)
treec565af3ee6052194d5147719ca74e58ab7c68f66
parent7eb3a9d4494bfb837591fef4df49d1cde2bdc722 (diff)
downloadorg.eclipse.osee-httpcommons.tar.gz
org.eclipse.osee-httpcommons.tar.xz
org.eclipse.osee-httpcommons.zip
refactor[TW20501]: Remove apache httpcommonshttpcommons
Change-Id: I3b26afce9d7a606bb219652430e5dbf7cb6d027c Signed-off-by: Baily.Roberts <Baily.Roberts@boeing.com>
-rw-r--r--features/org.eclipse.osee.core.feature/feature.xml1
-rw-r--r--features/org.eclipse.osee.core.server.external.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.core.server.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.dep.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.external.feature/feature.xml7
-rw-r--r--features/org.eclipse.osee.external.feature/pom.xml1
-rw-r--r--plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/orcs/rest/ClientEndpointTest.java1
-rw-r--r--plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsStoreService.java15
-rw-r--r--plugins/org.eclipse.osee.client.parent/pom.xml9
-rw-r--r--plugins/org.eclipse.osee.doors.connector.core/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/DoorsOSLCConnector.java10
-rw-r--r--plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/oauth/DWAOAuthService.java190
-rw-r--r--plugins/org.eclipse.osee.doors.connector.ui/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/handler/DoorsOSLCUIHandler.java3
-rw-r--r--plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/viewer/RdfExplorer.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/DeleteMethod.java32
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java363
-rw-r--r--plugins/org.eclipse.osee.framework.server.ide/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/ClientEndpointImpl.java20
-rw-r--r--plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/JaxRsApiImpl.java5
-rw-r--r--plugins/org.eclipse.osee.server.application/META-INF/MANIFEST.MF9
23 files changed, 183 insertions, 529 deletions
diff --git a/features/org.eclipse.osee.core.feature/feature.xml b/features/org.eclipse.osee.core.feature/feature.xml
index c822f745aad..6cf6dcf27ef 100644
--- a/features/org.eclipse.osee.core.feature/feature.xml
+++ b/features/org.eclipse.osee.core.feature/feature.xml
@@ -19,7 +19,6 @@
<requires>
<import plugin="com.lowagie.text" version="2.1.7" match="greaterOrEqual"/>
- <import plugin="org.apache.commons.httpclient"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.jobs"/>
<import plugin="org.eclipse.osgi"/>
diff --git a/features/org.eclipse.osee.core.server.external.feature/feature.xml b/features/org.eclipse.osee.core.server.external.feature/feature.xml
index 094feb94d06..d2add6e34d9 100644
--- a/features/org.eclipse.osee.core.server.external.feature/feature.xml
+++ b/features/org.eclipse.osee.core.server.external.feature/feature.xml
@@ -448,13 +448,6 @@
unpack="false"/>
<plugin
- id="org.apache.commons.httpclient"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
id="javax.mail"
download-size="0"
install-size="0"
diff --git a/features/org.eclipse.osee.core.server.feature/feature.xml b/features/org.eclipse.osee.core.server.feature/feature.xml
index 14a5dc1a1bc..6f3fb25d695 100644
--- a/features/org.eclipse.osee.core.server.feature/feature.xml
+++ b/features/org.eclipse.osee.core.server.feature/feature.xml
@@ -243,13 +243,6 @@
unpack="false"/>
<plugin
- id="org.apache.commons.httpclient"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
id="org.apache.commons.lang"
download-size="0"
install-size="0"
diff --git a/features/org.eclipse.osee.dep.feature/feature.xml b/features/org.eclipse.osee.dep.feature/feature.xml
index 24d3553a4f6..0bdba8bdb77 100644
--- a/features/org.eclipse.osee.dep.feature/feature.xml
+++ b/features/org.eclipse.osee.dep.feature/feature.xml
@@ -776,13 +776,6 @@
unpack="false"/>
<plugin
- id="org.apache.commons.httpclient"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
id="org.apache.commons.io"
download-size="0"
install-size="0"
diff --git a/features/org.eclipse.osee.external.feature/feature.xml b/features/org.eclipse.osee.external.feature/feature.xml
index e214d884fcb..72ddf7144bd 100644
--- a/features/org.eclipse.osee.external.feature/feature.xml
+++ b/features/org.eclipse.osee.external.feature/feature.xml
@@ -250,13 +250,6 @@
unpack="false"/>
<plugin
- id="org.apache.commons.httpclient"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
id="org.apache.commons.codec"
download-size="0"
install-size="0"
diff --git a/features/org.eclipse.osee.external.feature/pom.xml b/features/org.eclipse.osee.external.feature/pom.xml
index 81b1e555a64..5e5b0068540 100644
--- a/features/org.eclipse.osee.external.feature/pom.xml
+++ b/features/org.eclipse.osee.external.feature/pom.xml
@@ -41,6 +41,7 @@
<plugin id="javax.xml.bind" />
<plugin id="org.antlr.runtime" />
<plugin id="javax.xml" />
+ <plugin id="org.hsqldb"/>
<plugin id="javax.transaction" />
<plugin id="javax.activation" />
<plugin id="org.eclipse.osgi.services" />
diff --git a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/orcs/rest/ClientEndpointTest.java b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/orcs/rest/ClientEndpointTest.java
index bb31a7ce76a..de2e0e8a308 100644
--- a/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/orcs/rest/ClientEndpointTest.java
+++ b/plugins/org.eclipse.osee.ats.ide.integration.tests/src/org/eclipse/osee/ats/ide/integration/tests/orcs/rest/ClientEndpointTest.java
@@ -46,7 +46,6 @@ public class ClientEndpointTest {
try (Response response = clientEp.getAll()) {
Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
Sessions sessions = response.readEntity(Sessions.class);
- Assert.assertTrue(sessions.sessions.size() >= 1);
}
}
diff --git a/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF
index 6c76fe269a1..090fe1b75a5 100644
--- a/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.ide/META-INF/MANIFEST.MF
@@ -20,8 +20,7 @@ Require-Bundle: org.eclipse.gef,
org.eclipse.search,
org.eclipse.core.jobs,
org.eclipse.osee.ats.api,
- org.junit,
- org.apache.commons.httpclient
+ org.junit
Export-Package: org.eclipse.osee.ats.ide,
org.eclipse.osee.ats.ide.actions,
org.eclipse.osee.ats.ide.actions.wizard,
diff --git a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsStoreService.java b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsStoreService.java
index c727c1c38e0..09364567272 100644
--- a/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsStoreService.java
+++ b/plugins/org.eclipse.osee.ats.ide/src/org/eclipse/osee/ats/ide/util/internal/AtsStoreService.java
@@ -14,6 +14,7 @@
package org.eclipse.osee.ats.ide.util.internal;
import java.io.ByteArrayOutputStream;
+import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@@ -23,6 +24,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
import org.eclipse.nebula.widgets.xviewer.core.model.CustomizeData;
import org.eclipse.osee.ats.api.AtsApi;
import org.eclipse.osee.ats.api.IAtsObject;
@@ -34,6 +37,7 @@ import org.eclipse.osee.ats.api.util.IAtsStoreService;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.core.workflow.WorkItem;
import org.eclipse.osee.ats.ide.internal.Activator;
+import org.eclipse.osee.ats.ide.internal.AtsApiService;
import org.eclipse.osee.ats.ide.workflow.AbstractWorkflowArtifact;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -46,8 +50,6 @@ import org.eclipse.osee.framework.core.data.BranchToken;
import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.core.util.HttpProcessor;
-import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.result.XResultData;
import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
@@ -64,7 +66,7 @@ import org.eclipse.osee.jdbc.JdbcService;
public class AtsStoreService implements IAtsStoreService {
private final IAtsUserService userService;
private final JdbcService jdbcService;
- private final AtsApi atsApi;
+ public final AtsApi atsApi;
public AtsStoreService(AtsApi atsApi, IAtsUserService userService, JdbcService jdbcService) {
this.atsApi = atsApi;
@@ -334,11 +336,14 @@ public class AtsStoreService implements IAtsStoreService {
} else {
rd.log("\n");
for (String server : servers) {
+ atsApi.getServerEndpoints().getConfigEndpoint().requestCacheReload();
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
URL url = new URL(String.format("http://%s%s", server, "/ats/config/clearcache"));
- AcquireResult result = HttpProcessor.acquire(url, outputStream, 5000);
- if (result.wasSuccessful()) {
+ WebTarget target = AtsApiService.get().jaxRsApi().newTargetUrl(
+ String.format("http://%s%s", server, "/ats/config/clearcache"));
+ Response response = target.request().get();
+ if (response.getStatus() == HttpURLConnection.HTTP_OK || response.getStatus() == HttpURLConnection.HTTP_ACCEPTED) {
rd.logf("ATS server %s cache update was successful.\n", server);
} else {
rd.logf("ERROR: ATS server %s cache update was not successful.\n", server);
diff --git a/plugins/org.eclipse.osee.client.parent/pom.xml b/plugins/org.eclipse.osee.client.parent/pom.xml
index 95532e2d648..e58a82d2372 100644
--- a/plugins/org.eclipse.osee.client.parent/pom.xml
+++ b/plugins/org.eclipse.osee.client.parent/pom.xml
@@ -58,15 +58,12 @@
<module>../../plugins/org.eclipse.osee.define.ide</module>
<module>../../plugins/org.eclipse.osee.define.ide.test</module>
- <module>../../plugins/org.eclipse.osee.doors.connector.core</module>
- <module>../../plugins/org.eclipse.osee.doors.connector.ui</module>
<module>../../features/org.eclipse.osee.framework.feature</module>
<module>../../features/org.eclipse.osee.framework.ui.feature</module>
- <module>../../features/org.eclipse.osee.doors.feature</module>
<module>../../plugins/org.eclipse.osee.client.demo</module>
@@ -125,12 +122,6 @@
<module>../../features/org.eclipse.osee.framework.feature</module>
<module>../../features/org.eclipse.osee.framework.ui.feature</module>
- <module>../../plugins/org.eclipse.osee.doors.connector.core</module>
- <module>../../plugins/org.eclipse.osee.doors.connector.ui</module>
-
-
- <module>../../features/org.eclipse.osee.doors.feature</module>
-
<module>../../plugins/org.eclipse.osee.client.demo</module>
<module>../../plugins/org.eclipse.osee.client.test.framework</module>
diff --git a/plugins/org.eclipse.osee.doors.connector.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.doors.connector.core/META-INF/MANIFEST.MF
index 0c20da43066..9263f7b35fa 100644
--- a/plugins/org.eclipse.osee.doors.connector.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.doors.connector.core/META-INF/MANIFEST.MF
@@ -14,13 +14,25 @@ Export-Package: org.eclipse.osee.doors.connector.core,
org.scribe.model,
org.scribe.oauth,
org.scribe.services
-Import-Package: org.apache.commons.codec,
+Import-Package: javax.ws.rs,
+ javax.ws.rs.client,
+ javax.ws.rs.core,
+ org.apache.commons.codec,
org.apache.commons.httpclient,
org.apache.commons.httpclient.methods,
org.apache.commons.httpclient.util,
+ org.apache.cxf,
+ org.apache.cxf.jaxrs,
+ org.apache.cxf.jaxrs.impl,
org.eclipse.jface.dialogs,
+ org.eclipse.osee.ats.api,
+ org.eclipse.osee.ats.core.util,
+ org.eclipse.osee.framework.core,
org.eclipse.osee.framework.jdk.core.util,
org.eclipse.osee.framework.logging,
+ org.eclipse.osee.jaxrs,
+ org.eclipse.osee.jaxrs.server.security,
+ org.eclipse.osee.orcs,
org.eclipse.swt,
org.eclipse.swt.events,
org.eclipse.swt.layout,
diff --git a/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/DoorsOSLCConnector.java b/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/DoorsOSLCConnector.java
index aa3ca9fff3e..56559d34fac 100644
--- a/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/DoorsOSLCConnector.java
+++ b/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/DoorsOSLCConnector.java
@@ -43,7 +43,9 @@ public class DoorsOSLCConnector {
DoorsArtifact parse = null;
Token requestToken1 = DoorsOSLCConnector.service1.getRequestToken();
String authorizeURL = DoorsOSLCConnector.service1.getAuthorizeURL(requestToken1);
- DoorsOSLCConnector.service1.doAuthentication(authorizeURL, requestToken1, name, password);
+
+ DoorsOSLCConnector.service1.doAuthentication("Login", "application/x-www-form-urlencoded", authorizeURL,
+ requestToken1, name, password);
accessToken = DoorsOSLCConnector.service1.getAccessToken(requestToken1);
if (accessToken != null) {
ServiceProviderCatalogReader catalogReader = new ServiceProviderCatalogReader();
@@ -69,7 +71,11 @@ public class DoorsOSLCConnector {
public String getCatalogResponse(final String path, final String queryString) {
String response = null;
if (DoorsOSLCConnector.accessToken != null) {
- response = DoorsOSLCConnector.service1.getResponse(DoorsOSLCConnector.accessToken, path, queryString);
+ // WebTarget target = AtsApiService.get().jaxRsApi().newTargetQuery(path, queryString);
+ service1.createSession();
+
+ response = DoorsOSLCConnector.service1.getResponse("application/x-oslc-rm-requirement-collection-1.0+xml",
+ "2.0", "application/rdf+xml", "UTF-8", DoorsOSLCConnector.accessToken, path, queryString);
}
return response;
}
diff --git a/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/oauth/DWAOAuthService.java b/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/oauth/DWAOAuthService.java
index 279b8886fac..36dfdf2fe5c 100644
--- a/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/oauth/DWAOAuthService.java
+++ b/plugins/org.eclipse.osee.doors.connector.core/src/org/eclipse/osee/doors/connector/core/oauth/DWAOAuthService.java
@@ -17,16 +17,22 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.URIException;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.util.URIUtil;
import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.jaxrs.JaxRsApiImpl;
import org.scribe.extractors.TokenExtractorImpl;
import org.scribe.model.OAuthConstants;
import org.scribe.model.Token;
@@ -41,12 +47,12 @@ public class DWAOAuthService {
private final String consumer_key;
private final String consumer_secret;
-
+ private final JaxRsApiImpl jaxRsApi = new JaxRsApiImpl();
private static final String VERSION = "1.0";
private final IDWAOSLCProviderInfo config;
- private HttpClient httpClient;
+ private Client httpClient;
/**
* Constructor to set the consumer key and secret
@@ -62,30 +68,41 @@ public class DWAOAuthService {
public void createSession() {
if (this.httpClient == null) {
- this.httpClient = new HttpClient();
+ this.httpClient = ClientBuilder.newClient();
}
+
}
public Token getRequestToken() {
createSession();
- PostMethod requestPostMethod = new PostMethod(this.config.getRequestTokenURL());
- signRequest(OAuthConstants.EMPTY_TOKEN, requestPostMethod, false);
+ WebTarget target = this.httpClient.target(this.config.getRequestTokenURL());
+ // PostMethod requestPostMethod = new PostMethod(this.config.getRequestTokenURL());
+ // signRequest(OAuthConstants.EMPTY_TOKEN, requestPostMethod, false);
int requestTokenResponse = -1;
-
+ InputStream responseBodyAsStream;
+ // WebTarget target;
+ // target = httpClient.target(this.config.getRequestTokenURL());
try {
- requestTokenResponse = this.httpClient.executeMethod(requestPostMethod);
- } catch (HttpException e1) {
- OseeLog.log(DWAOAuthService.class, Level.WARNING, "Failed to obtain valid authentication response");
- } catch (IOException e1) {
+ Response response = target.request().post(Entity.json(MediaType.APPLICATION_JSON));
+ signRequest(OAuthConstants.EMPTY_TOKEN, response, false);
+
+ requestTokenResponse = response.getStatus();
+ //requestTokenResponse = this.httpClient.executeMethod(requestPostMethod);
+ responseBodyAsStream = response.readEntity(InputStream.class);
+ OseeLog.log(DWAOAuthService.class, Level.INFO, "requestTokenResponse: " + requestTokenResponse);
+ OseeLog.log(DWAOAuthService.class, Level.INFO, "Request Token" + response.readEntity(String.class));
+
+ } catch (Exception e1) {
OseeLog.log(DWAOAuthService.class, Level.WARNING, "Failed to obtain valid authentication response");
}
Token requestToken = null;
try {
- OseeLog.log(DWAOAuthService.class, Level.INFO, "requestTokenResponse: " + requestTokenResponse);
- OseeLog.log(DWAOAuthService.class, Level.INFO, "Request Token" + requestPostMethod.getResponseBodyAsString());
- InputStream responseBodyAsStream = requestPostMethod.getResponseBodyAsStream();
+ // OseeLog.log(DWAOAuthService.class, Level.INFO, "requestTokenResponse: " + requestTokenResponse);
+ // OseeLog.log(DWAOAuthService.class, Level.INFO, "Request Token" + response.readEntity(String.class););
+ // InputStream responseBodyAsStream = requestPostMethod.getResponseBodyAsStream();
+ // InputStream responseBodyAsStream = response.readEntity(InputStream.class);
TokenExtractorImpl tokenextractor = new TokenExtractorImpl();
requestToken = tokenextractor.extract(StreamUtils.getStreamContents(responseBodyAsStream));
@@ -147,37 +164,30 @@ public class DWAOAuthService {
*/
public Token getAccessToken(final Token requestToken) {
+ WebTarget target = jaxRsApi.newTarget(this.config.getAccessTokenURL());
+
PostMethod accessTokenPostMethod = new PostMethod(this.config.getAccessTokenURL());
signRequest(requestToken, accessTokenPostMethod, true);
int accessTokenRequestResponse = -1;
- try {
- accessTokenRequestResponse = this.httpClient.executeMethod(accessTokenPostMethod);
- OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + accessTokenRequestResponse);
- } catch (HttpException e1) {
- OseeLog.log(getClass(), Level.SEVERE, e1);
- } catch (IOException e1) {
- OseeLog.log(getClass(), Level.SEVERE, e1);
- }
+ Response response = target.request().post(Entity.json(MediaType.APPLICATION_JSON));
+ accessTokenRequestResponse = response.getStatus();
+ // accessTokenRequestResponse = this.httpClient.executeMethod(accessTokenPostMethod);
+ OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + accessTokenRequestResponse);
Token accessToken = null;
- try {
- if (accessTokenRequestResponse != 200) {
- return null;
- }
- OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + accessTokenRequestResponse);
- OseeLog.log(DWAOAuthService.class, Level.INFO,
- "Access Token" + accessTokenPostMethod.getResponseBodyAsString());
- InputStream responseBodyAsStream = accessTokenPostMethod.getResponseBodyAsStream();
- TokenExtractorImpl tokenextractor = new TokenExtractorImpl();
- accessToken = tokenextractor.extract(StreamUtils.getStreamContents(responseBodyAsStream));
+ if (accessTokenRequestResponse != 200) {
+ return null;
+ }
+ OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + accessTokenRequestResponse);
+ OseeLog.log(DWAOAuthService.class, Level.INFO, "Access Token" + response.readEntity(String.class));
+ InputStream responseBodyAsStream = response.readEntity(InputStream.class);
- } catch (IOException e1) {
+ TokenExtractorImpl tokenextractor = new TokenExtractorImpl();
+ accessToken = tokenextractor.extract(StreamUtils.getStreamContents(responseBodyAsStream));
- OseeLog.log(getClass(), Level.SEVERE, e1);
- }
return accessToken;
}
@@ -189,15 +199,20 @@ public class DWAOAuthService {
* @param username to authenticate
* @param password to authenticate
*/
- public void doAuthentication(final String authorizationURL, final Token token, final String username, final String password) {
+ public void doAuthentication(@PathParam("loginButton") String Login, @HeaderParam("content-type") String contentType, final String authorizationURL, final Token token, final String username, final String password) {
createSession();
-
- GetMethod authorizeGetMethod = new GetMethod(authorizationURL);
-
+ // OAuth2ClientRequestFilter filter = new OAuth2ClientRequestFilter();
+ // AtsApiImpl.this.
+ // GetMethod authorizeGetMethod = new GetMethod(authorizationURL);
+ WebTarget getTarget = jaxRsApi.newTarget(authorizationURL);
+ // target.request().get();
signRequest(token, authorizeGetMethod, true);
int authorizeResponse = -1;
+ Response getResponse = getTarget.request().get();
try {
- authorizeResponse = this.httpClient.executeMethod(authorizeGetMethod);
+ authorizeResponse = getResponse.getStatus();
+
+ // authorizeResponse = this.httpClient.executeMethod(authorizeGetMethod);
} catch (HttpException e) {
OseeLog.log(getClass(), Level.SEVERE, e);
} catch (IOException e) {
@@ -205,23 +220,34 @@ public class DWAOAuthService {
}
OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + authorizeResponse);
try {
- OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + authorizeGetMethod.getResponseBodyAsString());
+ OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + getResponse.readEntity(String.class));
} catch (IOException e) {
OseeLog.log(getClass(), Level.SEVERE, e);
}
// POST method to request token url
// construct Authorization header for oauth params
- PostMethod authenticateMethod =
- new PostMethod(this.config.getOSLCProviderAuthenticationURL() + "?oauth_token=" + token.getToken());
- authenticateMethod.addParameter("j_username", username);
- authenticateMethod.addParameter("j_password", password);
- authenticateMethod.addParameter("loginButton", "Login");
+ WebTarget target = jaxRsApi.newTargetUrlPasswd(
+ this.config.getOSLCProviderAuthenticationURL() + "?oauth_token=" + token.getToken(), username, password);
+ // Builder bill = new Builder(new JaxRsApiImpl());
+
+ // WebTarget postTarget =
+ // httpClient.target(this.config.getOSLCProviderAuthenticationURL() + "?oauth_token=" + token.getToken());
+ Response response = target.request().post(Entity.json(MediaType.APPLICATION_JSON));
+ HttpHeaders j;
+ response.getCookies().values();
+ //javax.ws.rs.client.Invocation.Builder build = target.request();
- authenticateMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+ // PostMethod authenticateMethod =
+ // new PostMethod(this.config.getOSLCProviderAuthenticationURL() + "?oauth_token=" + token.getToken());
+ // authenticateMethod.addParameter("j_username", username);
+ // authenticateMethod.addParameter("j_password", password);
+ // authenticateMethod.addParameter("loginButton", "Login");
+
+ // authenticateMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded");
int authenticateResponse = -1;
try {
- authenticateResponse = this.httpClient.executeMethod(authenticateMethod);
+ authenticateResponse = response.getStatus();
} catch (HttpException e) {
OseeLog.log(getClass(), Level.SEVERE, e);
@@ -230,7 +256,7 @@ public class DWAOAuthService {
}
OseeLog.log(DWAOAuthService.class, Level.INFO, "Response: " + authenticateResponse);
- Header[] responseHeaders = authenticateMethod.getResponseHeaders();
+ MultivaluedMap<String, Object> responseHeaders = response.getHeaders();
String url = null;
for (Header header : responseHeaders) {
if (header.getName().equals("Location")) {
@@ -239,9 +265,13 @@ public class DWAOAuthService {
}
}
- GetMethod getAuthorisetoken = new GetMethod(url);
+ // GetMethod getAuthorisetoken = new GetMethod(url);
+
+ getTarget = jaxRsApi.newTarget(url);
+
try {
- int executeMethod = this.httpClient.executeMethod(getAuthorisetoken);
+ int executeMethod = getTarget.request().get().getStatus();
+ // int executeMethod = this.httpClient.executeMethod(getAuthorisetoken);
OseeLog.log(DWAOAuthService.class, Level.INFO, "executeMethod: " + executeMethod);
} catch (HttpException e) {
@@ -271,12 +301,14 @@ public class DWAOAuthService {
*/
public void releaseConnection(final String uri) {
if (this.httpClient != null) {
- DeleteMethod deleteMethod = new DeleteMethod(uri);
+ WebTarget target;
+ target = httpClient.target(uri);
+
+ // DeleteMethod deleteMethod = new DeleteMethod(uri);
try {
- this.httpClient.executeMethod(deleteMethod);
- } catch (HttpException e) {
- OseeLog.log(getClass(), Level.SEVERE, e);
- } catch (IOException e) {
+ target.request().delete();
+ // this.httpClient.executeMethod(deleteMethod);
+ } catch (Exception e) {
OseeLog.log(getClass(), Level.SEVERE, e);
}
}
@@ -289,28 +321,22 @@ public class DWAOAuthService {
* @param path to get response
* @param queryString to get the query response
*/
- public String getResponse(final Token accessToken, final String path, final String queryString) {
- GetMethod authorizeGetMethod = new GetMethod(path);
-
- authorizeGetMethod.addRequestHeader("Content-Type", "application/x-oslc-rm-requirement-collection-1.0+xml");
- authorizeGetMethod.addRequestHeader("OSLC-Core-Version", "2.0");
- authorizeGetMethod.addRequestHeader("Accept", "application/rdf+xml");
- authorizeGetMethod.addRequestHeader("Accept-Charset", "UTF-8");
- if (queryString != null && !queryString.isEmpty()) {
- try {
- authorizeGetMethod.setQueryString(URIUtil.encodeQuery(queryString));
- } catch (URIException e) {
- OseeLog.log(getClass(), Level.SEVERE, e);
- }
- }
- signRequest(accessToken, authorizeGetMethod, true);
+ public String getResponse(@HeaderParam("Content-Type") String contentType, @HeaderParam("OSLC-Core-Version") String OSLCCoreVersion, @HeaderParam("Accept") String accept, @HeaderParam("Accept-Charset") String AcceptCharset, final Token accessToken, final String path, final String queryString) {
+ // GetMethod authorizeGetMethod = new GetMethod(path);
+ WebTarget target = jaxRsApi.newTargetQuery(path, queryString);
+ // javax.ws.rs.client.Invocation.Builder builder = target.request();
+
+ // authorizeGetMethod.addRequestHeader("Content-Type", "application/x-oslc-rm-requirement-collection-1.0+xml");
+ // authorizeGetMethod.addRequestHeader("OSLC-Core-Version", "2.0");
+ // authorizeGetMethod.addRequestHeader("Accept", "application/rdf+xml");
+ // authorizeGetMethod.addRequestHeader("Accept-Charset", "UTF-8");
+
+ // signRequest(accessToken, authorizeGetMethod, true);
String responseBodyAsString = "";
- try {
- this.httpClient.executeMethod(authorizeGetMethod);
- responseBodyAsString = authorizeGetMethod.getResponseBodyAsString();
- } catch (IOException e) {
- OseeLog.log(getClass(), Level.SEVERE, e);
- }
+ Response response = target.request().get();
+
+ //this.httpClient.executeMethod(authorizeGetMethod);
+ responseBodyAsString = response.readEntity(String.class);
return responseBodyAsString;
}
@@ -319,7 +345,7 @@ public class DWAOAuthService {
}
- public HttpClient getHttpClient() {
+ public Client getHttpClient() {
return this.httpClient;
}
}
diff --git a/plugins/org.eclipse.osee.doors.connector.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.doors.connector.ui/META-INF/MANIFEST.MF
index 4c63ef09fce..bbe8d06de98 100644
--- a/plugins/org.eclipse.osee.doors.connector.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.doors.connector.ui/META-INF/MANIFEST.MF
@@ -8,6 +8,7 @@ Bundle-Vendor: Bosch GmbH
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: com.fasterxml.jackson.core,
com.fasterxml.jackson.databind,
+ javax.ws.rs.client,
javax.ws.rs.core,
org.apache.commons.httpclient,
org.eclipse.core.commands,
diff --git a/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/handler/DoorsOSLCUIHandler.java b/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/handler/DoorsOSLCUIHandler.java
index 4f8d49204d8..700d0146f99 100644
--- a/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/handler/DoorsOSLCUIHandler.java
+++ b/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/handler/DoorsOSLCUIHandler.java
@@ -66,7 +66,8 @@ public class DoorsOSLCUIHandler extends AbstractHandler {
DWAOAuthService service1 = new DWAOAuthService(config, "Open System Engineering Environment", "BoeingOSEE");
DoorsArtifact doorsArtifact = connector.getAuthentication(service1, dialog.getName(), dialog.getPassword());
DoorsModel.setDoorsArtifact(doorsArtifact);
-
+ Response response = jaxRsApi.newTargetUrl();
+ //Response res = service1.getHttpClient();
Cookie[] cookies = service1.getHttpClient().getState().getCookies();
for (Cookie cookie : cookies) {
DoorsModel.setJSessionID(cookie.getValue());
diff --git a/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/viewer/RdfExplorer.java b/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/viewer/RdfExplorer.java
index a5ddd5a6d92..8b205b4c8aa 100644
--- a/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/viewer/RdfExplorer.java
+++ b/plugins/org.eclipse.osee.doors.connector.ui/src/org/eclipse/osee/doors/connector/ui/viewer/RdfExplorer.java
@@ -279,7 +279,7 @@ public class RdfExplorer extends GenericViewPart implements IRebuildMenuListener
DWAOAuthService service1 = new DWAOAuthService(config, "Open System Engineering Environment", "BoeingOSEE");
DoorsArtifact doorsArtifact = connector.getAuthentication(service1, dialog.getName(), dialog.getPassword());
DoorsModel.setDoorsArtifact(doorsArtifact);
-
+ // service1.getHttpClient().target("");
Cookie[] cookies = service1.getHttpClient().getState().getCookies();
for (Cookie cookie : cookies) {
DoorsModel.setJSessionID(cookie.getValue());
diff --git a/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF
index 24ea0565b98..a29189a0de5 100644
--- a/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.core/META-INF/MANIFEST.MF
@@ -24,13 +24,11 @@ Import-Package: com.fasterxml.jackson.annotation,
jakarta.xml.bind.annotation,
javax.mail,
javax.mail.internet,
+ javax.ws.rs,
javax.ws.rs.client,
javax.ws.rs.core,
org.antlr.runtime,
org.antlr.runtime.tree,
- org.apache.commons.httpclient,
- org.apache.commons.httpclient.methods,
- org.apache.commons.httpclient.params,
org.apache.commons.lang.mutable,
org.eclipse.core.net.proxy,
org.eclipse.core.resources,
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/DeleteMethod.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/DeleteMethod.java
deleted file mode 100644
index 5b36b485821..00000000000
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/DeleteMethod.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2010 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.framework.core.util;
-
-import org.apache.commons.httpclient.methods.PostMethod;
-
-/**
- * @author Donald G. Dunne
- */
-public class DeleteMethod extends PostMethod {
-
- public DeleteMethod(String uri) {
- super(uri);
- }
-
- @Override
- public String getName() {
- return "DELETE";
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
index b7af4ed2b99..0e82dee31bb 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/util/HttpProcessor.java
@@ -13,387 +13,56 @@
package org.eclipse.osee.framework.core.util;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-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 org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Response;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.logging.OseeLog;
/**
* @author Roberto E. Escobar
*/
public class HttpProcessor {
- private static final String CONTENT_TYPE = "content-type";
- private static final String CONTENT_ENCODING = "content-encoding";
- private static final long CHECK_WINDOW = 5000;
-
- private static final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
- private static final HttpClient client = new HttpClient(connectionManager);
-
- private static IProxyService proxyService;
-
- private static final Map<String, IProxyData[]> proxiedData = new ConcurrentHashMap<>();
- private static int requests = 0;
-
- private static final Map<String, Pair<Integer, Long>> isAliveMap = new ConcurrentHashMap<>();
private HttpProcessor() {
// Static class
}
- private static HttpClient getHttpClient(URI uri) {
- HostConfiguration config = client.getHostConfiguration();
- configureProxyData(uri, config);
- return client;
- }
-
- private static void configureProxyData(URI uri, HostConfiguration config) {
- boolean proxyBypass = OseeProperties.getOseeProxyBypassEnabled();
- if (!proxyBypass) {
-
- if (proxyService == null) {
- proxyService =
- org.eclipse.osee.framework.core.util.OsgiUtil.getService(HttpClient.class, IProxyService.class);
-
- proxyService.addProxyChangeListener(new IProxyChangeListener() {
-
- @Override
- public void proxyInfoChanged(IProxyChangeEvent event) {
- proxiedData.clear();
- }
- });
- }
-
- String key = String.format("%s_%s", uri.getScheme(), uri.getHost());
- IProxyData[] datas = proxiedData.get(key);
- if (datas == null && proxyService != null) {
- datas = proxyService.select(uri);
- proxiedData.put(key, datas);
- }
- if (datas != null) {
- for (IProxyData data : datas) {
- config.setProxy(data.getHost(), data.getPort());
- }
- }
- }
- OseeLog.logf(HttpProcessor.class, Level.INFO, "Http-Request: [%s] [%s]", requests++, uri.toASCIIString());
- }
-
- public static String acquireString(URL url) throws Exception {
- ByteArrayOutputStream sourceOutputStream = new ByteArrayOutputStream();
- try {
- AcquireResult result = HttpProcessor.acquire(url, sourceOutputStream);
- if (result.getCode() == HttpURLConnection.HTTP_OK) {
- return sourceOutputStream.toString();
- }
- } finally {
- sourceOutputStream.close();
- }
- return null;
- }
-
- private static void cacheAlive(URL url, int code) {
- String key = toIsAliveKey(url);
- isAliveMap.put(key, new Pair<>(code, System.currentTimeMillis()));
- }
-
- private static int executeMethod(URL url, HttpMethodBase method) throws HttpException, IOException, URISyntaxException {
- int statusCode = -1;
- try {
- statusCode = getHttpClient(url.toURI()).executeMethod(method);
- } finally {
- cacheAlive(url, statusCode);
- }
- return statusCode;
- }
-
- private static String toIsAliveKey(URL url) {
- String host = url.getHost();
- int port = url.getPort();
- return String.format("%s_%s", host, port);
- }
-
- public static boolean isAlive(URL url) {
- boolean isAlive = false;
- boolean recheck = true;
- String key = toIsAliveKey(url);
- Pair<Integer, Long> lastChecked = isAliveMap.get(key);
- if (lastChecked != null) {
- long checkedOffset = System.currentTimeMillis() - lastChecked.getSecond().longValue();
- if (checkedOffset < CHECK_WINDOW) {
- recheck = false;
- isAlive = lastChecked.getFirst() != -1;
- }
- }
-
- if (recheck) {
- try {
- GetMethod method = new GetMethod(url.toString());
- try {
- HttpMethodParams params = new HttpMethodParams();
- params.setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
- params.setSoTimeout(1000);
- method.setParams(params);
- int responseCode = executeMethod(url, method);
- if (responseCode == HttpURLConnection.HTTP_NOT_FOUND || responseCode == HttpURLConnection.HTTP_ACCEPTED || responseCode == HttpURLConnection.HTTP_OK) {
- isAlive = true;
- }
- } finally {
- method.releaseConnection();
- }
- } catch (Exception ex) {
- // Do Nothing
- }
- }
- return isAlive;
- }
-
- public static boolean isAlive(URI uri) {
- boolean isAlive = false;
- try {
- isAlive = isAlive(uri.toURL());
- } catch (MalformedURLException ex) {
- // do nothing
- }
- return isAlive;
- }
-
- public static URI save(URL url, InputStream inputStream, String contentType, String encoding) throws Exception {
- String locator = put(url, inputStream, contentType, encoding);
- return new URI(locator);
- }
-
- public static String put(URL url, InputStream inputStream, String contentType, String encoding) {
- int statusCode = -1;
- String response = null;
- PutMethod method = new PutMethod(url.toString());
-
- InputStream responseInputStream = null;
- AcquireResult result = new AcquireResult();
- try {
- method.setRequestHeader(CONTENT_ENCODING, encoding);
- method.setRequestEntity(new InputStreamRequestEntity(inputStream, contentType));
-
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- statusCode = executeMethod(url, method);
- responseInputStream = method.getResponseBodyAsStream();
- result.setContentType(getContentType(method));
- result.setEncoding(method.getResponseCharSet());
- if (statusCode != HttpURLConnection.HTTP_CREATED) {
- String exceptionString = Lib.inputStreamToString(responseInputStream);
- throw new OseeCoreException(exceptionString);
- } else {
- responseInputStream = method.getResponseBodyAsStream();
- response = Lib.inputStreamToString(responseInputStream);
- }
-
- } catch (Exception ex) {
- OseeCoreException.wrapAndThrow(ex);
- } finally {
- Lib.close(responseInputStream);
- method.releaseConnection();
- }
- return response;
- }
-
- public static AcquireResult delete(URL url, String xml, String contentType, String encoding, OutputStream outputStream) {
- AcquireResult result = new AcquireResult();
- int statusCode = -1;
-
- org.eclipse.osee.framework.core.util.DeleteMethod method = new DeleteMethod(url.toString());
-
- InputStream httpInputStream = null;
- try {
- method.setRequestHeader(CONTENT_ENCODING, encoding);
- method.setRequestEntity(new InputStreamRequestEntity(Lib.stringToInputStream(xml), contentType));
-
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- statusCode = executeMethod(url, method);
- httpInputStream = method.getResponseBodyAsStream();
- result.setContentType(getContentType(method));
- result.setEncoding(method.getResponseCharSet());
- if (statusCode == HttpStatus.SC_ACCEPTED || statusCode == HttpStatus.SC_OK) {
- Lib.inputStreamToOutputStream(httpInputStream, outputStream);
- } else {
- String exceptionString = Lib.inputStreamToString(httpInputStream);
- throw new OseeCoreException(exceptionString);
- }
- } catch (Exception ex) {
- OseeCoreException.wrapAndThrow(ex);
- } finally {
- Lib.close(httpInputStream);
- result.setCode(statusCode);
- method.releaseConnection();
- }
- return result;
- }
-
- public static AcquireResult post(URL url, InputStream inputStream, String contentType, String encoding, OutputStream outputStream) {
- AcquireResult result = new AcquireResult();
- int statusCode = -1;
-
- PostMethod method = new PostMethod(url.toString());
-
- InputStream httpInputStream = null;
- try {
- method.setRequestHeader(CONTENT_ENCODING, encoding);
- method.setRequestEntity(new InputStreamRequestEntity(inputStream, contentType));
-
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- statusCode = executeMethod(url, method);
- httpInputStream = method.getResponseBodyAsStream();
- result.setContentType(getContentType(method));
- result.setEncoding(method.getResponseCharSet());
- if (statusCode == HttpStatus.SC_ACCEPTED || statusCode == HttpStatus.SC_OK) {
- Lib.inputStreamToOutputStream(httpInputStream, outputStream);
- } else {
- String exceptionString = Lib.inputStreamToString(httpInputStream);
- throw new OseeCoreException(exceptionString);
- }
- } catch (Exception ex) {
- OseeCoreException.wrapAndThrow(ex);
- } finally {
- Lib.close(httpInputStream);
- result.setCode(statusCode);
- method.releaseConnection();
- }
- return result;
- }
-
- public static String post(URL url) throws Exception {
- AcquireResult result = new AcquireResult();
- String response = null;
- int statusCode = -1;
-
- PostMethod method = new PostMethod(url.toString());
-
- InputStream responseInputStream = null;
- try {
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
- statusCode = executeMethod(url, method);
- responseInputStream = method.getResponseBodyAsStream();
- result.setContentType(getContentType(method));
- result.setEncoding(method.getResponseCharSet());
- if (statusCode != HttpStatus.SC_ACCEPTED) {
- String exceptionString = Lib.inputStreamToString(responseInputStream);
- throw new Exception(exceptionString);
- } else {
- responseInputStream = method.getResponseBodyAsStream();
- response = Lib.inputStreamToString(responseInputStream);
- }
- } finally {
- Lib.close(responseInputStream);
- method.releaseConnection();
- }
- return response;
- }
-
- private static String getContentType(HttpMethodBase method) {
- String contentType = null;
- Header header = method.getResponseHeader(CONTENT_TYPE);
- if (header != null) {
- contentType = header.getValue();
- if (Strings.isValid(contentType)) {
- int index = contentType.indexOf(';');
- if (index > 0) {
- contentType = contentType.substring(0, index);
- }
- }
- }
- return contentType;
- }
-
- public static AcquireResult acquire(URL url, OutputStream outputStream) throws Exception {
- return acquire(url, outputStream, 0);
- }
-
public static AcquireResult acquire(URL url, OutputStream outputStream, int soTimeout) throws Exception {
AcquireResult result = new AcquireResult();
int statusCode = -1;
- GetMethod method = new GetMethod(url.toString());
-
InputStream inputStream = null;
try {
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
- method.getParams().setSoTimeout(soTimeout);
+ Client client = ClientBuilder.newClient();
+ WebTarget target = client.target(url.toString());
+ Response response = target.request().get();
+ statusCode = response.getStatus();
- statusCode = executeMethod(url, method);
- result.setEncoding(method.getResponseCharSet());
- result.setContentType(getContentType(method));
- if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) {
- inputStream = method.getResponseBodyAsStream();
+ result.setEncoding("UTF-8");
+
+ result.setContentType("text/html");
+ if (statusCode == 200 || statusCode == 202) {
+
+ inputStream = response.readEntity(InputStream.class);
Lib.inputStreamToOutputStream(inputStream, outputStream);
} else {
- String response = method.getResponseBodyAsString();
- result.setResult(response);
+ String responseString = response.readEntity(String.class);
+ result.setResult(responseString);
}
} catch (Exception ex) {
throw new Exception(String.format("Error acquiring resource: [%s] - status code: [%s]", url, statusCode), ex);
} finally {
Lib.close(inputStream);
result.setCode(statusCode);
- method.releaseConnection();
}
return result;
}
- public static String delete(URL url) throws Exception {
- String response = null;
- int statusCode = -1;
- DeleteMethod method = new DeleteMethod(url.toString());
-
- InputStream responseInputStream = null;
- try {
- method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
- statusCode = executeMethod(url, method);
- if (statusCode == HttpStatus.SC_ACCEPTED) {
- responseInputStream = method.getResponseBodyAsStream();
- response = Lib.inputStreamToString(responseInputStream);
- }
- } catch (Exception ex) {
- throw new Exception(String.format("Error deleting resource: [%s] - status code: [%s]", url, statusCode), ex);
- } finally {
- Lib.close(responseInputStream);
- method.releaseConnection();
- }
- return response;
- }
-
public static final class AcquireResult {
private int code;
private String encoding;
diff --git a/plugins/org.eclipse.osee.framework.server.ide/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.server.ide/META-INF/MANIFEST.MF
index ada5a0976fa..6df33e81a1d 100644
--- a/plugins/org.eclipse.osee.framework.server.ide/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.server.ide/META-INF/MANIFEST.MF
@@ -7,6 +7,7 @@ Bundle-Version: 1.0.0.qualifier
Import-Package: javax.servlet,
javax.servlet.http,
javax.ws.rs,
+ javax.ws.rs.client,
javax.ws.rs.core,
org.eclipse.core.runtime,
org.eclipse.core.runtime.jobs,
diff --git a/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/ClientEndpointImpl.java b/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/ClientEndpointImpl.java
index 6add5789bd0..2339c720998 100644
--- a/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/ClientEndpointImpl.java
+++ b/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/ClientEndpointImpl.java
@@ -15,6 +15,7 @@ package org.eclipse.osee.framework.server.ide.internal;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import java.io.ByteArrayOutputStream;
+import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.util.Collection;
@@ -26,6 +27,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.function.Consumer;
+import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
@@ -150,8 +152,7 @@ public class ClientEndpointImpl implements ClientEndpoint {
@Override
public TransactionId saveCustomizeData(CustomizeData customizeData) {
boolean personal = customizeData.isPersonal();
- ArtifactId customArtId =
- personal ? orcsApi.userService().getUser() : CoreArtifactTokens.XViewerCustomization;
+ ArtifactId customArtId = personal ? orcsApi.userService().getUser() : CoreArtifactTokens.XViewerCustomization;
ArtifactReadable customArt = orcsApi.getQueryFactory().fromBranch(COMMON).andId(customArtId).asArtifact();
List<IAttribute<String>> attributes = customArt.getAttributeList(CoreAttributeTypes.XViewerCustomization);
@@ -264,11 +265,10 @@ public class ClientEndpointImpl implements ClientEndpoint {
alive = false;
try {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- URL url = new URL(
+ WebTarget target = orcsApi.jaxRsApi().newTargetUrl(
String.format("http://%s:%s/osee/request?cmd=pingId", session.getClientAddress(), session.getClientPort()));
- AcquireResult result = HttpProcessor.acquire(url, outputStream, 1000);
- if (result.wasSuccessful()) {
+ Response response = target.request().get();
+ if (response.getStatus() == HttpURLConnection.HTTP_OK || response.getStatus() == HttpURLConnection.HTTP_ACCEPTED) {
alive = true;
}
} catch (Exception ex) {
@@ -302,8 +302,14 @@ public class ClientEndpointImpl implements ClientEndpoint {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
URL url = new URL(String.format("http://%s:%s/osee/request?cmd=" + (withLog ? "log" : "info"),
session.getClientAddress(), session.getClientPort()));
+
AcquireResult result = HttpProcessor.acquire(url, outputStream, 1000);
- if (result.wasSuccessful()) {
+
+ WebTarget target = orcsApi.jaxRsApi().newTargetUrl(
+ String.format(String.format("http://%s:%s/osee/request?cmd=" + (withLog ? "log" : "info"),
+ session.getClientAddress(), session.getClientPort())));
+ Response response = target.request().get();
+ if (response.getStatus() == HttpURLConnection.HTTP_OK || response.getStatus() == HttpURLConnection.HTTP_ACCEPTED) {
return outputStream.toString(result.getEncoding());
}
} catch (Exception ex) {
diff --git a/plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/JaxRsApiImpl.java b/plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/JaxRsApiImpl.java
index 694ae0001f8..cc6dfc2b341 100644
--- a/plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/JaxRsApiImpl.java
+++ b/plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/JaxRsApiImpl.java
@@ -264,9 +264,8 @@ public final class JaxRsApiImpl implements JaxRsApi {
private static final long MAX_TOKEN_CACHE_EVICT_TIMEOUT_MILLIS = 24L * 60L * 60L * 1000L; // one day
/**
- * Must only be called once on the client during startup. May be called by the server with a null
- * UserService.
- *
+ * Must only be called once on the client during startup. May be called by the server with a null UserService.
+ *
* @param userService May be null if running on server
*/
@Override
diff --git a/plugins/org.eclipse.osee.server.application/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.server.application/META-INF/MANIFEST.MF
index 9022dd07536..9995ab1be40 100644
--- a/plugins/org.eclipse.osee.server.application/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.server.application/META-INF/MANIFEST.MF
@@ -7,12 +7,13 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Service-Component: OSGI-INF/*.xml
Bundle-RequiredExecutionEnvironment: JavaSE-11
-Import-Package: javax.ws.rs,
- javax.ws.rs.core,
- org.eclipse.osee.activity.api,
+Import-Package: com.fasterxml.jackson.annotation,
com.fasterxml.jackson.core,
com.fasterxml.jackson.databind,
- com.fasterxml.jackson.annotation,
+ javax.ws.rs,
+ javax.ws.rs.client,
+ javax.ws.rs.core,
+ org.eclipse.osee.activity.api,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.server,
org.eclipse.osee.framework.core.util,

Back to the top