protected void changeLastUpgradeId( JcrRepository repository, int value ) throws Exception { // modify the repository-info document to force an upgrade on the next restart DocumentStore documentStore = repository.documentStore(); documentStore.localStore().runInTransaction(() -> { EditableDocument editableDocument = documentStore.localStore().edit(RepositoryCache.REPOSITORY_INFO_KEY, true); editableDocument.set("lastUpgradeId", value); documentStore.localStore().put(RepositoryCache.REPOSITORY_INFO_KEY, editableDocument); return null; }, 0); }
String documentStoreKey = null; try { documentStoreKey = session().repository().documentStore() .newDocumentKey(key().toString(), childName, childPrimaryNodeTypeName); } catch (Exception e) {
String documentStoreKey = null; try { documentStoreKey = session().repository().documentStore() .newDocumentKey(key().toString(), childName, childPrimaryNodeTypeName); } catch (Exception e) {
@Test @FixFor( "MODE-2450" ) public void shouldCleanupCorruptedLocks() throws Exception { final AbstractJcrNode testNode = session.getRootNode().addNode("test"); final String path = testNode.getPath(); testNode.addMixin("mix:lockable"); session.save(); final org.modeshape.jcr.RepositoryLockManager.Lock lock = (RepositoryLockManager.Lock) session.getWorkspace().getLockManager().lock(path, false, false, Long.MAX_VALUE, session.getUserID()); Assert.assertNotNull(lock); session.logout(); //forcibly remove the lock node from the system area... String lockKey = lock.lockKey().toString(); assertTrue(runInTransaction(() -> repository.documentStore().remove(lockKey))); //and then force a refresh RepositoryLockManager lockManager = repository.lockManager(); lockManager.refreshFromSystem(); //check that the lock has been removed session = repository.login(); assertFalse(session.getWorkspace().getLockManager().isLocked("/test")); // issue another refresh and verify the node is still unlocked lockManager.refreshFromSystem(); assertFalse(session.getWorkspace().getLockManager().isLocked("/test")); }