public static InternalView openViewWithLockArea( InternalSession session, InternalLockManager lockManager, CDOBranch viewedBranch, String lockAreaID) { LockArea lockArea; InternalView view; try { lockArea = lockManager.getLockArea(lockAreaID); // If we get here, the lockArea already exists. view = (InternalView) lockManager.openView(session, InternalSession.TEMP_VIEW_ID, true, lockAreaID); } catch (LockAreaNotFoundException e) { // If we get here, the lockArea does not yet exist, so we open // a view without a lockArea first, then create a lockArea with the given ID, // and associate it with the view. view = session.openView(InternalSession.TEMP_VIEW_ID, viewedBranch.getHead()); lockArea = lockManager.createLockArea(view, lockAreaID); view.setDurableLockingID(lockAreaID); } CheckUtil.checkNull(lockAreaID, "lockAreaID"); CheckUtil.checkNull(lockArea, "lockArea"); CheckUtil.checkState( lockAreaID.equals(lockArea.getDurableLockingID()), "lockAreaID has incorrect value"); return view; }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { if (!validateRequest(request)) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } String op = request.getParameter(OP); if (op.equals(RECOVER_OP)) { HttpSession httpSession = request.getSession(false); if (httpSession != null) { if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message( "GetHttpSession.recover: " + "Old HttpSession is obtained"); } SessionID sid = new SessionID(request); if (!sid.isNull()) { SessionService.getSessionService().retrieveSession(sid, httpSession); } } else { SessionService.sessionDebug.error( "GetHttpSession.recover: " + "Old HttpSession is not obtained"); } } else if (op.equals(SAVE_OP)) { HttpSession httpSession = request.getSession(false); if (httpSession != null) { if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message("GetHttpSession.save: HttpSession is obtained"); } SessionID sid = new SessionID(request); if (!sid.isNull()) { int status = SessionService.getSessionService().handleSaveSession(sid, httpSession); response.setStatus(status); } } else { SessionService.sessionDebug.error("GetHttpSession.save: HttpSession is not obtained"); response.setStatus(HttpServletResponse.SC_NOT_FOUND); } } else if (op.equals(CREATE_OP)) { HttpSession httpSession = request.getSession(true); String domain = request.getParameter(DOMAIN); InternalSession is = SessionService.getSessionService().newInternalSession(domain, httpSession); if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message( "GetHttpSession.create: Created new session=" + is.getID()); } DataOutputStream out = new DataOutputStream(response.getOutputStream()); out.writeUTF(is.getID().toString()); out.flush(); out.close(); } else if (op.equals(INVALIDATE_OP)) { HttpSession httpSession = request.getSession(false); if (httpSession != null) { if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message( "GetHttpSession.invalidate: " + "HttpSession is obtained"); } try { httpSession.invalidate(); } catch (IllegalStateException ise) { if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message( "Exception:invalidateSession: the web " + "containers session timeout could be " + "shorter than the OpenSSO session " + "timeout", ise); } } } else { if (SessionService.sessionDebug.warningEnabled()) { SessionService.sessionDebug.warning( "GetHttpSession.invalidate: session is " + "not obtained"); } } } else if (op.equals(RELEASE_OP)) { SessionID sid = new SessionID(request); if (!sid.isNull()) { if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message("GetHttpSession.release: releasing session=" + sid); } int status = SessionService.getSessionService().handleReleaseSession(sid); response.setStatus(status); } else { if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message("GetHttpSession.release: missing session id"); } } } else if (op.equals(GET_RESTRICTED_TOKEN_OP)) { DataInputStream in = null; DataOutputStream out = null; SessionID sid = new SessionID(request); try { in = new DataInputStream(request.getInputStream()); TokenRestriction restriction = TokenRestrictionFactory.unmarshal(in.readUTF()); String token = SessionService.getSessionService().handleGetRestrictedTokenIdRemotely(sid, restriction); if (token != null) { if (SessionService.sessionDebug.messageEnabled()) { SessionService.sessionDebug.message( "GetHttpSession.get_restricted_token: " + "Created new session=" + token); } response.setStatus(HttpServletResponse.SC_OK); out = new DataOutputStream(response.getOutputStream()); out.writeUTF(token); out.flush(); } else { SessionService.sessionDebug.error( "GetHttpSession.get_restricted_token: " + "failed to create token"); response.setStatus(HttpServletResponse.SC_NOT_FOUND); } } catch (Exception ex) { SessionService.sessionDebug.error( "GetHttpSession.get_restricted_token: " + "exception occured while create token", ex); response.setStatus(HttpServletResponse.SC_NOT_FOUND); } finally { SessionService.closeStream(in); SessionService.closeStream(out); } } else { SessionService.sessionDebug.error("GetHttpSession: unknown operation requested"); response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); } }