@Override protected void finalize() throws Throwable { if ( target.isLive() ) { // target.logout(); } } }
@Override public void afterTest() throws RepositoryException { for (Session session : sessions) { if (session.isLive()) { session.logout(); } } } }
@Override public void close() throws MetadataRepositoryException { if ( jcrSession != null && jcrSession.isLive() ) { jcrSession.logout(); } }
@Override public Instant updateExpiry(final Duration amountToAdd) { if (jcrSession.isLive()) { expires = now().plus(amountToAdd); } return expires; }
private synchronized Session getSession() { if (session==null || !session.isLive()) { try { session = MgnlContext.getJCRSession(DefaultReportingService.WORKSPACE); } catch (Exception e) { log.error("Cannot obtain JCR session: "+e.getMessage()); log.debug("Cannot obtain JCR session.", e); } } return session; }
/** * Return true if session is live. */ public boolean isLive() { return getSession().isLive(); }
public void tearDown() throws Exception { if (file != null) { file.delete(); file = null; } if (session != null && session.isLive()) { session.logout(); session = null; } workspace = null; super.tearDown(); }
/** * Checks if this <code>QueryManagerImpl</code> instance is still usable, * otherwise throws a {@link javax.jcr.RepositoryException}. * * @throws RepositoryException if this query manager is not usable anymore, * e.g. the corresponding session is closed. */ private void checkIsAlive() throws RepositoryException { if (!session.isLive()) { throw new RepositoryException("corresponding session has been closed"); } }
@Override public synchronized Node getWrappedNode() { try { if (node == null || !node.getSession().isLive()) { Session session = getSessionForWrappedNode(this.workspace); node = session.getNodeByIdentifier(this.nodeIdentifier); } } catch (RepositoryException e) { throw new RuntimeException(e); } return node; }
@Override public void expire() { expires = now(); try { if (jcrSession.isLive()) { jcrSession.refresh(false); jcrSession.logout(); } } catch (final RepositoryException ex) { throw new RepositoryRuntimeException(ex); } }
public Session getJcrSession() throws RepositoryException { if ( this.jcrSession == null || !this.jcrSession.isLive() ) { jcrSession = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) ); } return this.jcrSession; }
default boolean isLive() { if (getNode() != null) { try { if (getNode().getSession() != null) { return getNode().getSession().isLive(); } } catch (RepositoryException e) { } } return false; }
@Override public synchronized Content getWrappedContent() { try { if (node == null || !node.getJCRNode().getSession().isLive()) { node = getHierarchyManager().getContentByUUID(getUuid()); } } catch (RepositoryException e) { log.error("can't reinitialize node {}", getUuid(), e); } return node; }
@Override protected void tearDown() throws Exception { try { if (testSession != null && testSession.isLive()) { testSession.logout(); } } finally { super.tearDown(); } }
@Override protected void tearDown() throws Exception { try { if (testSession != null && testSession.isLive()) { testSession.logout(); } } finally { super.tearDown(); } }
private void unsubscribe() throws RepositoryException { if (fro != null) { fro.unsubscribe(this, session); fro = null; } cmsEventDispatcherService.unsubscribe(listenerPath, this); if (!isvirtual && session.isLive()) { ObservationManager obMgr = session.getWorkspace().getObservationManager(); obMgr.removeEventListener(this); } session = null; }
@Before public void setUp() throws RepositoryException { when( nodeMock.getSession() ).thenReturn( sessionMock ); // Live session when( sessionMock.isLive() ).thenReturn( true ); repoFileProxy = new RepositoryFileProxy( nodeMock, templateMock, pentahoLocale ); repoFileProxySpy = spy( repoFileProxy ); // test metadata doReturn( metadata ).when( repoFileProxySpy ).getMetadata(); }
@Override protected void tearDown() throws Exception { try { if (testSession != null && testSession.isLive()) { testSession.logout(); } user.remove(); superuser.save(); } finally { super.tearDown(); } }
@Override public NodeData getWrappedNodeData() { try { // DHM.getNodeData() can still return null and the var itself is transient and won't survive serialization if (nodeData == null || (nodeData.isExist() && !nodeData.getJCRProperty().getSession().isLive())) { nodeData = getHierarchyManager().getNodeData(getPath()); } } catch (RepositoryException e) { log.error("can't reinitialize node {}", getPath(), e); } return nodeData; }
@Test public void shouldBeEmpty() throws Exception { Session session = session(); assertThat(session.isLive(), is(true)); assertThat(session.getRootNode().getNodes().getSize(), is(1L)); assertThat(session.getRootNode().getNode("jcr:system"), is(notNullValue())); }