private HttpSession session() { if (session == null) { throw new SessionMissingException("Invalid session"); } return session; }
@Override public Response toResponse(final SessionMissingException e) { debugException(this, e, LOGGER); return status(GONE).entity(e.getMessage()).type(TEXT_PLAIN_WITH_CHARSET).build(); } }
/** * Get a JCR session for the given HTTP servlet request with a * SecurityContext attached * * @param servletRequest the servlet request * @return the Session * @throws RuntimeException if the transaction could not be found */ public HttpSession getSession(final HttpServletRequest servletRequest) { final HttpSession session; final String txId = getEmbeddedId(servletRequest, Prefix.TX); try { if (txId == null) { session = createSession(servletRequest); } else { session = getSessionFromTransaction(servletRequest, txId); } } catch (final SessionMissingException e) { LOGGER.warn("Transaction missing: {}", e.getMessage()); return null; } return session; }
@Override public FedoraSession getSession(final String sessionId, final String username) { final FedoraSession session = sessions.get(getTxKey(sessionId, username)); if (session == null) { throw new SessionMissingException("Batch session with id: " + sessionId + " is not available"); } return session; }