public LocalSession(String repositoryName, NuxeoPrincipal principal) { if (TransactionHelper.isTransactionMarkedRollback()) { throw new NuxeoException("Cannot create a CoreSession when transaction is marked rollback-only"); } if (!TransactionHelper.isTransactionActive()) { throw new NuxeoException("Cannot create a CoreSession outside a transaction"); } this.repositoryName = repositoryName; this.principal = principal; createMetrics(); // needs repo name sessionId = newSessionId(repositoryName, principal); if (log.isDebugEnabled()) { log.debug("Creating CoreSession: " + sessionId); } createSession(); // create first session for current thread }
@Override public Session getSession() { if (!TransactionHelper.isTransactionActiveOrMarkedRollback()) { throw new NuxeoException("Cannot use a CoreSession outside a transaction"); } TransactionHelper.checkTransactionTimeout(); SessionInfo si = sessionHolder.get(); if (si == null || !si.session.isLive()) { // close old one, previously completed closeInThisThread(); if (log.isDebugEnabled()) { log.debug("Reconnecting CoreSession: " + sessionId); } if (TransactionHelper.isTransactionMarkedRollback()) { throw new NuxeoException("Cannot reconnect a CoreSession when transaction is marked rollback-only"); } si = createSession(); } return si.session; }