Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2020-05-06 19:53:13 +0000
committerRyan D. Brooks2020-12-15 21:40:20 +0000
commit66ced531218137d3c9feb114ce8535b495004b7e (patch)
tree52e3fcda9c1acc98a4bbb4736445a1299af9740a
parent0b96a68a3d691317dad80a203a6cc528fc9cc82f (diff)
downloadorg.eclipse.osee-66ced531218137d3c9feb114ce8535b495004b7e.tar.gz
org.eclipse.osee-66ced531218137d3c9feb114ce8535b495004b7e.tar.xz
org.eclipse.osee-66ced531218137d3c9feb114ce8535b495004b7e.zip
refactor[TW17022]: Use JaxRsApi with SessionEndpoint
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.jdbc.service.xml1
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/ClientSessionManager.java28
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/ClientJdbcServiceImpl.java15
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/InternalClientSessionManager.java48
-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
7 files changed, 54 insertions, 93 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
index b94d21e7fb3..572fa81b42e 100644
--- a/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
@@ -7,8 +7,10 @@ Bundle-Version: 0.26.0.qualifier
Bundle-Activator: org.eclipse.osee.framework.core.client.internal.Activator
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Import-Package: org.eclipse.core.runtime,
+Import-Package: javax.ws.rs.client,
+ org.eclipse.core.runtime,
org.eclipse.jdt.annotation,
+ org.eclipse.osee.framework.core,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.enums.token,
@@ -30,4 +32,3 @@ Import-Package: org.eclipse.core.runtime,
Export-Package: org.eclipse.osee.framework.core.client,
org.eclipse.osee.framework.core.client.server
Service-Component: OSGI-INF/*.xml
-Require-Bundle: javax.ws.rs
diff --git a/plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.jdbc.service.xml b/plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.jdbc.service.xml
index dfa29dd3307..455dfc8519d 100644
--- a/plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.jdbc.service.xml
+++ b/plugins/org.eclipse.osee.framework.core.client/OSGI-INF/client.jdbc.service.xml
@@ -4,4 +4,5 @@
<service>
<provide interface="org.eclipse.osee.jdbc.JdbcService"/>
</service>
+ <reference bind="setJaxRsApi" cardinality="1..1" interface="org.eclipse.osee.framework.core.JaxRsApi" name="jaxRsApi" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/ClientSessionManager.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/ClientSessionManager.java
index 7a536311370..1a10f33871c 100644
--- a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/ClientSessionManager.java
+++ b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/ClientSessionManager.java
@@ -24,30 +24,35 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Roberto E. Escobar
*/
-public class ClientSessionManager {
+public final class ClientSessionManager {
+ private static InternalClientSessionManager internal;
private ClientSessionManager() {
//
}
+ public static void setInternalSessionManager(InternalClientSessionManager internalSessionManager) {
+ internal = internalSessionManager;
+ }
+
public static final String getStatusId() {
return InternalClientSessionManager.STATUS_ID;
}
public static boolean isSessionValid() {
- return InternalClientSessionManager.getInstance().isSessionValid();
+ return internal.isSessionValid();
}
public static void ensureSessionCreated() {
- InternalClientSessionManager.getInstance().ensureSessionCreated();
+ internal.ensureSessionCreated();
}
private static OseeSessionGrant getSessionGrant() {
- return InternalClientSessionManager.getInstance().getOseeSessionGrant();
+ return internal.getOseeSessionGrant();
}
public static IdeClientSession getSession() {
- return InternalClientSessionManager.getInstance().getOseeSession();
+ return internal.getOseeSession();
}
public static UserToken getCurrentUserToken() {
@@ -96,19 +101,19 @@ public class ClientSessionManager {
}
public static List<String> getAuthenticationProtocols() {
- return InternalClientSessionManager.getInstance().getAuthenticationProtocols();
+ return internal.getAuthenticationProtocols();
}
public static void authenticateAsAnonymous() {
- InternalClientSessionManager.getInstance().authenticateAsAnonymous();
+ internal.authenticateAsAnonymous();
}
public static void authenticate(ICredentialProvider credentialProvider) {
- InternalClientSessionManager.getInstance().authenticate(credentialProvider);
+ internal.authenticate(credentialProvider);
}
public static void releaseSession() {
- InternalClientSessionManager.getInstance().releaseSession();
+ internal.releaseSession();
}
public static String getDatabaseInfo() {
@@ -116,7 +121,6 @@ public class ClientSessionManager {
}
public static IdeClientSession getSafeSession() {
- return InternalClientSessionManager.getInstance().getSafeSession();
+ return internal.getSafeSession();
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/ClientJdbcServiceImpl.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/ClientJdbcServiceImpl.java
index d03eca1bece..7b2a23daf0c 100644
--- a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/ClientJdbcServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/internal/ClientJdbcServiceImpl.java
@@ -18,6 +18,8 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map.Entry;
import java.util.Properties;
+import org.eclipse.osee.framework.core.JaxRsApi;
+import org.eclipse.osee.framework.core.client.ClientSessionManager;
import org.eclipse.osee.framework.core.data.OseeSessionGrant;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcClientBuilder;
@@ -33,6 +35,15 @@ public class ClientJdbcServiceImpl implements JdbcService {
private final JdbcClientExtended clientProxy = createClientProxy();
+ private JaxRsApi jaxRsApi;
+ private InternalClientSessionManager sessionManager;
+
+ public void setJaxRsApi(JaxRsApi jaxRsApi) {
+ this.jaxRsApi = jaxRsApi;
+ }
+ sessionManager = new InternalClientSessionManager(jaxRsApi);
+ ClientSessionManager.setInternalSessionManager(sessionManager);
+
@Override
public String getId() {
return clientProxy.getId();
@@ -112,8 +123,7 @@ public class ClientJdbcServiceImpl implements JdbcService {
}
private OseeSessionGrant getDbInfo() {
- OseeSessionGrant sessionGrant = InternalClientSessionManager.getInstance().getOseeSessionGrant();
- return sessionGrant;
+ return sessionManager.getOseeSessionGrant();
}
private JdbcClient newClient(OseeSessionGrant sessionGrant) {
@@ -132,5 +142,4 @@ public class ClientJdbcServiceImpl implements JdbcService {
return builder.build();
}
}
-
} \ No newline at end of file
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..bee55ec4f3e 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,9 @@
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.JaxRsApi;
import org.eclipse.osee.framework.core.client.AnonymousCredentialProvider;
import org.eclipse.osee.framework.core.client.BaseCredentialProvider;
import org.eclipse.osee.framework.core.client.ICredentialProvider;
@@ -37,21 +34,21 @@ 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;
/**
* @author Roberto E. Escobar
*/
public class InternalClientSessionManager {
public static final String STATUS_ID = "Session Manager";
- private static final InternalClientSessionManager instance = new InternalClientSessionManager();
private final OseeClientInfo clientInfo;
+ private final JaxRsApi jaxRsApi;
private OseeSessionGrant oseeSessionGrant;
private IdeClientSession oseeSession;
- private InternalClientSessionManager() {
+ InternalClientSessionManager(JaxRsApi jaxRsApi) {
clearData();
+ this.jaxRsApi = jaxRsApi;
this.clientInfo = new OseeClientInfo();
clientInfo.setClientAddress(HttpServer.getServerAddressForExternalCommunication(),
HttpServer.getDefaultServicePort());
@@ -63,10 +60,6 @@ public class InternalClientSessionManager {
}
}
- public static InternalClientSessionManager getInstance() {
- return instance;
- }
-
public boolean isSessionValid() {
return oseeSession != null;
}
@@ -172,11 +165,7 @@ public class InternalClientSessionManager {
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());
- }
+ getSessionEp().releaseIdeClientSession(sessionId);
clearData();
} catch (Exception ex) {
OseeLog.log(Activator.class, Level.SEVERE, ex);
@@ -184,17 +173,7 @@ public class InternalClientSessionManager {
}
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 getSessionEp().getIdeClientProtocols();
}
private void clearData() {
@@ -203,17 +182,10 @@ public class InternalClientSessionManager {
}
private OseeSessionGrant internalAcquireSession(OseeCredential credential) {
- SessionEndpoint sessionEp = getSessionEp();
- Response response = sessionEp.createIdeClientSession(credential);
- OseeSessionGrant sessionGrant = response.readEntity(OseeSessionGrant.class);
- return sessionGrant;
+ return getSessionEp().createIdeClientSession(credential);
}
- 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);
+ private SessionEndpoint getSessionEp() {
+ return jaxRsApi.newProxy("ide", 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

Back to the top