Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2020-05-10 05:22:29 +0000
committerRyan D. Brooks2021-01-15 16:22:20 +0000
commitb75f92fdc000fbed75b4bd49993f2dccfd801581 (patch)
treeab722c8628199c6072e2034221666a896a36867a
parent1ee47c493c0cad98e51efef051123e14d4447004 (diff)
downloadorg.eclipse.osee-b75f92fdc000fbed75b4bd49993f2dccfd801581.tar.gz
org.eclipse.osee-b75f92fdc000fbed75b4bd49993f2dccfd801581.tar.xz
org.eclipse.osee-b75f92fdc000fbed75b4bd49993f2dccfd801581.zip
refactor[TW18593]: Add SessionEndpoint to OseeClient
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/InternalClientSessionManager.java52
-rw-r--r--plugins/org.eclipse.osee.framework.server.ide.api/src/org/eclipse/osee/framework/server/ide/api/SessionEndpoint.java13
-rw-r--r--plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/SessionEndpointImpl.java37
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java6
6 files changed, 30 insertions, 82 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/InternalClientSessionManager.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/InternalClientSessionManager.java
index 4a8e08bb44b..ebef0bf57e4 100644
--- a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/InternalClientSessionManager.java
+++ b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/InternalClientSessionManager.java
@@ -14,12 +14,8 @@
package org.eclipse.osee.framework.core.client.internal;
import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
import org.eclipse.osee.framework.core.client.AnonymousCredentialProvider;
import org.eclipse.osee.framework.core.client.BaseCredentialProvider;
import org.eclipse.osee.framework.core.client.ICredentialProvider;
@@ -32,12 +28,13 @@ import org.eclipse.osee.framework.core.data.OseeCredential;
import org.eclipse.osee.framework.core.data.OseeSessionGrant;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.core.exception.OseeAuthenticationRequiredException;
+import org.eclipse.osee.framework.core.util.OsgiUtil;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.logging.BaseStatus;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.server.ide.api.SessionEndpoint;
-import org.eclipse.osee.jaxrs.client.JaxRsClient;
+import org.eclipse.osee.orcs.rest.client.OseeClient;
/**
* @author Roberto E. Escobar
@@ -112,7 +109,7 @@ public class InternalClientSessionManager {
try {
OseeCredential credential = credentialProvider.getCredential();
clearData();
- oseeSessionGrant = internalAcquireSession(credential);
+ oseeSessionGrant = getSessionEndpoint().createIdeClientSession(credential);
if (oseeSessionGrant == null) {
return;
} else if (SystemUser.UnAuthenticated.getUserId().equals(oseeSessionGrant.getUserToken().getUserId())) {
@@ -166,35 +163,13 @@ public class InternalClientSessionManager {
public void releaseSession() {
if (isSessionValid()) {
- internalReleaseSession(getOseeSessionGrant().getSessionId());
- }
- }
-
- private void internalReleaseSession(String sessionId) {
- try {
- SessionEndpoint sessionEp = getSessionEp();
- Response response = sessionEp.releaseIdeClientSession(sessionId);
- if (response.getStatus() != Status.OK.getStatusCode()) {
- throw new OseeCoreException("Unable to Release Session " + response.toString());
- }
+ getSessionEndpoint().releaseIdeClientSession(getOseeSessionGrant().getSessionId());
clearData();
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
}
}
public List<String> getAuthenticationProtocols() {
- List<String> toReturn = new ArrayList<>();
- try {
- SessionEndpoint sessionEp = getSessionEp();
- Response response = sessionEp.getIdeClientProtocols();
- @SuppressWarnings("unchecked")
- List<String> protocols = response.readEntity(LinkedList.class);
- toReturn.addAll(protocols);
- } catch (Exception ex) {
- OseeLog.log(Activator.class, Level.SEVERE, ex);
- }
- return toReturn;
+ return getSessionEndpoint().getIdeClientProtocols();
}
private void clearData() {
@@ -202,18 +177,7 @@ public class InternalClientSessionManager {
this.oseeSessionGrant = null;
}
- private OseeSessionGrant internalAcquireSession(OseeCredential credential) {
- SessionEndpoint sessionEp = getSessionEp();
- Response response = sessionEp.createIdeClientSession(credential);
- OseeSessionGrant sessionGrant = response.readEntity(OseeSessionGrant.class);
- return sessionGrant;
+ private SessionEndpoint getSessionEndpoint() {
+ return OsgiUtil.getService(getClass(), OseeClient.class).getSessionEndpoint();
}
-
- private static SessionEndpoint getSessionEp() {
- String appServer = OseeClientProperties.getOseeApplicationServer();
- String atsUri = String.format("%s/ide", appServer);
- JaxRsClient jaxRsClient = JaxRsClient.newBuilder().createThreadSafeProxyClients(true).build();
- return jaxRsClient.target(atsUri).newProxy(SessionEndpoint.class);
- }
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.server.ide.api/src/org/eclipse/osee/framework/server/ide/api/SessionEndpoint.java b/plugins/org.eclipse.osee.framework.server.ide.api/src/org/eclipse/osee/framework/server/ide/api/SessionEndpoint.java
index 67f4a5327ad..fd1dade2f03 100644
--- a/plugins/org.eclipse.osee.framework.server.ide.api/src/org/eclipse/osee/framework/server/ide/api/SessionEndpoint.java
+++ b/plugins/org.eclipse.osee.framework.server.ide.api/src/org/eclipse/osee/framework/server/ide/api/SessionEndpoint.java
@@ -13,6 +13,7 @@
package org.eclipse.osee.framework.server.ide.api;
+import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
@@ -21,8 +22,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
import org.eclipse.osee.framework.core.data.OseeCredential;
+import org.eclipse.osee.framework.core.data.OseeSessionGrant;
/**
* @author Donald G. Dunne
@@ -36,7 +37,7 @@ public interface SessionEndpoint {
@Path("session")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
- public Response createIdeClientSession(OseeCredential clientSession);
+ public OseeSessionGrant createIdeClientSession(OseeCredential clientSession);
/**
* @return protocols associated with the specified application server
@@ -44,14 +45,12 @@ public interface SessionEndpoint {
@GET
@Path("session/protocols")
@Produces({MediaType.APPLICATION_JSON})
- Response getIdeClientProtocols();
+ List<String> getIdeClientProtocols();
/**
* DeRegister an IDE client with an application server.
*/
@DELETE
@Path("session/{sessionId}")
- @Produces({MediaType.APPLICATION_JSON})
- public Response releaseIdeClientSession(@PathParam("sessionId") String sessionId);
-
-}
+ public void releaseIdeClientSession(@PathParam("sessionId") String sessionId);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/SessionEndpointImpl.java b/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/SessionEndpointImpl.java
index 4ac67670934..3baf265fcaf 100644
--- a/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/SessionEndpointImpl.java
+++ b/plugins/org.eclipse.osee.framework.server.ide/src/org/eclipse/osee/framework/server/ide/internal/SessionEndpointImpl.java
@@ -16,17 +16,7 @@ package org.eclipse.osee.framework.server.ide.internal;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import org.eclipse.osee.activity.api.ActivityLog;
import org.eclipse.osee.framework.core.data.CoreActivityTypes;
@@ -57,41 +47,27 @@ public class SessionEndpointImpl implements SessionEndpoint {
}
@Override
- @PUT
- @Path("session")
- @Consumes({MediaType.APPLICATION_JSON})
- @Produces({MediaType.APPLICATION_JSON})
- public Response createIdeClientSession(OseeCredential credential) {
+ public OseeSessionGrant createIdeClientSession(OseeCredential credential) {
OseeSessionGrant sessionGrant = sessionManager.createSession(credential);
if (sessionGrant != null) {
logSessionCreation(credential, sessionGrant);
- } else {
- // session could not be created due to version or invalid user
- Response.serverError().status(Status.FORBIDDEN).entity("Unable to create session");
}
- return Response.ok().entity(sessionGrant).build();
+ return sessionGrant;
}
@Override
- @DELETE
- @Path("session/{sessionId}")
- @Produces({MediaType.APPLICATION_JSON})
- public Response releaseIdeClientSession(@PathParam("sessionId") String sessionId) {
+ public void releaseIdeClientSession(String sessionId) {
logSessionReleased(sessionId);
sessionManager.releaseSession(sessionId);
- return Response.ok().build();
}
@Override
- @GET
- @Path("session/protocols")
- @Produces({MediaType.APPLICATION_JSON})
- public Response getIdeClientProtocols() {
+ public List<String> getIdeClientProtocols() {
List<String> protocols = new LinkedList<>();
for (String protocol : authenticationManager.getProtocols()) {
protocols.add(protocol);
}
- return Response.ok(protocols).build();
+ return protocols;
}
private void logSessionCreation(OseeCredential credential, OseeSessionGrant oseeSessionGrant) {
@@ -143,5 +119,4 @@ public class SessionEndpointImpl implements SessionEndpoint {
}
return duration;
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF
index f58d226cd40..6e95d3a068d 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest.client/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Import-Package: javax.ws.rs,
org.eclipse.osee.framework.core.enums.token,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.server.ide.api,
org.eclipse.osee.framework.server.ide.api.client,
org.eclipse.osee.jaxrs.client,
org.eclipse.osee.orcs.rest.model,
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
index bb3ed5662ea..1183da124d7 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
@@ -18,6 +18,7 @@ import org.eclipse.osee.define.api.DataRightsEndpoint;
import org.eclipse.osee.define.api.DefineBranchEndpointApi;
import org.eclipse.osee.define.api.RenderEndpoint;
import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.server.ide.api.SessionEndpoint;
import org.eclipse.osee.framework.server.ide.api.client.ClientEndpoint;
import org.eclipse.osee.orcs.rest.model.ApplicabilityEndpoint;
import org.eclipse.osee.orcs.rest.model.ApplicabilityUiEndpoint;
@@ -69,4 +70,6 @@ public interface OseeClient {
DefineBranchEndpointApi getDefineBranchEndpoint();
+ SessionEndpoint getSessionEndpoint();
+
} \ No newline at end of file
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 f61959a51db..f6dde464417 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
@@ -28,6 +28,7 @@ import org.eclipse.osee.framework.core.JaxRsApi;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.server.ide.api.SessionEndpoint;
import org.eclipse.osee.framework.server.ide.api.client.ClientEndpoint;
import org.eclipse.osee.jaxrs.client.JaxRsClient;
import org.eclipse.osee.jaxrs.client.JaxRsWebTarget;
@@ -217,4 +218,9 @@ public class OseeClientImpl implements OseeClient, QueryExecutor {
private <T> T getOrcsEndpoint(Class<T> clazz) {
return jaxRsApi.newProxy("orcs", clazz);
}
+
+ @Override
+ public SessionEndpoint getSessionEndpoint() {
+ return jaxRsApi.newProxy("ide", SessionEndpoint.class);
+ }
} \ No newline at end of file

Back to the top