code: protected HttpSession getSessionFromTransaction(final HttpServletRequest servletRequest, final String txId) {
  
          final Principal userPrincipal = servletRequest.getUserPrincipal();
          final String userName = userPrincipal == null ? null : userPrincipal.getName();
  
          final FedoraSession session = batchService.getSession(txId, userName);
          final HttpSession batchSession = new HttpSession(session);
          batchSession.makeBatchSession();
          LOGGER.debug("Returning a session in the batch {} for user {}", batchSession, userName);
          return batchSession;
      }
docs: Retrieve a JCR session from an active transaction
  
  @param servletRequest the servlet request
  @param txId the transaction id
  @return a JCR session that is associated with the transaction