Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-09-28 22:23:28 -0400
committerRyan D. Brooks2010-09-28 22:23:28 -0400
commit4010b3d96416e375c38aeff87ed5a04a90fd47fb (patch)
treebd938baea1dfdb2b3b36b9b1bc34f70ed27bfb8a /plugins
parent936c81622a32fb4be316681d15583e2e636c33f1 (diff)
downloadorg.eclipse.osee-4010b3d96416e375c38aeff87ed5a04a90fd47fb.tar.gz
org.eclipse.osee-4010b3d96416e375c38aeff87ed5a04a90fd47fb.tar.xz
org.eclipse.osee-4010b3d96416e375c38aeff87ed5a04a90fd47fb.zip
refactor: Cleanup sessionManagementServlet exception handling
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SessionManagementServlet.java68
1 files changed, 22 insertions, 46 deletions
diff --git a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SessionManagementServlet.java b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SessionManagementServlet.java
index 2704a13a82..a01f5a684b 100644
--- a/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SessionManagementServlet.java
+++ b/plugins/org.eclipse.osee.framework.manager.servlet/src/org/eclipse/osee/framework/manager/servlet/SessionManagementServlet.java
@@ -19,8 +19,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.osee.framework.core.data.OseeCredential;
import org.eclipse.osee.framework.core.data.OseeSessionGrant;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.server.IAuthenticationManager;
import org.eclipse.osee.framework.core.server.ISessionManager;
import org.eclipse.osee.framework.core.server.UnsecuredOseeHttpServlet;
@@ -105,54 +103,32 @@ public class SessionManagementServlet extends UnsecuredOseeHttpServlet {
}
}
- private void createSession(HttpServletRequest request, HttpServletResponse response) throws OseeCoreException {
- try {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- Lib.inputStreamToOutputStream(request.getInputStream(), outputStream);
- byte[] bytes = outputStream.toByteArray();
- // TODO Decrypt credential info
-
- OseeCredential credential = OseeCredential.fromXml(new ByteArrayInputStream(bytes));
- OseeSessionGrant oseeSessionGrant = sessionManager.createSession(credential);
+ private void createSession(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ Lib.inputStreamToOutputStream(request.getInputStream(), outputStream);
+ byte[] bytes = outputStream.toByteArray();
- response.setStatus(HttpServletResponse.SC_ACCEPTED);
- ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
- oseeSessionGrant.write(byteOutputStream);
+ // TODO Decrypt credential info
+ OseeCredential credential = OseeCredential.fromXml(new ByteArrayInputStream(bytes));
+ OseeSessionGrant oseeSessionGrant = sessionManager.createSession(credential);
- // TODO after encrypted these will need to change
- response.setContentType("application/xml");
- response.setCharacterEncoding("UTF-8");
- response.setContentLength(byteOutputStream.size());
- Lib.inputStreamToOutputStream(new ByteArrayInputStream(byteOutputStream.toByteArray()),
- response.getOutputStream());
+ response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+ oseeSessionGrant.write(byteOutputStream);
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
- } finally {
- try {
- response.getOutputStream().flush();
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- }
+ // TODO after encrypted these will need to change
+ response.setContentType("application/xml");
+ response.setCharacterEncoding("UTF-8");
+ response.setContentLength(byteOutputStream.size());
+ Lib.inputStreamToOutputStream(new ByteArrayInputStream(byteOutputStream.toByteArray()),
+ response.getOutputStream());
}
- private void releaseSession(HttpServletRequest request, HttpServletResponse response) throws OseeCoreException {
- try {
- String sessionId = request.getParameter("sessionId");
- sessionManager.releaseSession(sessionId);
- response.setStatus(HttpServletResponse.SC_ACCEPTED);
- response.setContentType("text/plain");
- response.getWriter().write(String.format("Session [%s] released.", sessionId));
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
- } finally {
- try {
- response.getWriter().flush();
- response.getWriter().close();
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- }
+ private void releaseSession(HttpServletRequest request, HttpServletResponse response) throws Exception {
+ String sessionId = request.getParameter("sessionId");
+ sessionManager.releaseSession(sessionId);
+ response.setStatus(HttpServletResponse.SC_ACCEPTED);
+ response.setContentType("text/plain");
+ response.getWriter().write(String.format("Session [%s] released.", sessionId));
}
}

Back to the top