[ https://issues.apache.org/jira/browse/OAK-8048?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16771670#comment-16771670 ]
Marco Piovesana commented on OAK-8048: -------------------------------------- Hi Marcel, here the code snippet: {code:java} @Test public void shouldDeleteNodeHistory() throws IOException, InvalidFileStoreVersionException, RepositoryException { File root = new File(System.getProperty("java.io.tmpdir"), "oakTest"); File repo = new File(root, "content"); FileDataStore fileDataStore = new FileDataStore(); fileDataStore.init(repo.getAbsolutePath()); DataStoreBlobStore dataStoreBlobStore = new DataStoreBlobStore(fileDataStore); FileStore fileStore = FileStoreBuilder.fileStoreBuilder(repo).withBlobStore(dataStoreBlobStore).build(); SegmentNodeStore nodeStore = SegmentNodeStoreBuilders.builder(fileStore).build(); Oak oak = new Oak(nodeStore); Jcr jcrRepo = new Jcr(oak); Repository repository = jcrRepo.createRepository(); try { Session adminSession = repository.login(new SimpleCredentials("admin", "admin".toCharArray())); adminSession.save(); Node myFolder = JcrUtils.getOrAddNode(adminSession.getRootNode(), "my node", JcrConstants.NT_UNSTRUCTURED); myFolder.addMixin(JcrConstants.MIX_VERSIONABLE); myFolder.addMixin(AccessControlConstants.MIX_REP_ACCESS_CONTROLLABLE); adminSession.save(); adminSession.getWorkspace().getVersionManager().checkout(myFolder.getPath()); adminSession.getWorkspace().getVersionManager().checkin(myFolder.getPath()); adminSession.getWorkspace().getVersionManager().checkout(myFolder.getPath()); adminSession.getWorkspace().getVersionManager().checkin(myFolder.getPath()); VersionHistory versionHistory = adminSession.getWorkspace().getVersionManager().getVersionHistory(myFolder.getPath()); String historyNodePath = versionHistory.getPath(); VersionIterator allVersions = versionHistory.getAllVersions(); myFolder.remove(); adminSession.save(); while (allVersions.hasNext()) { Version version = allVersions.nextVersion(); if (!version.getName().equals(JcrConstants.JCR_ROOTVERSION)) { versionHistory.removeVersion(version.getName()); } } adminSession.save(); boolean historyExists = adminSession.itemExists(historyNodePath); adminSession.logout(); assertFalse(historyExists); } finally { fileStore.close(); ((JackrabbitRepository) repository).shutdown(); } } {code} > VersionHistory not removed when removing node and all its versions > ------------------------------------------------------------------ > > Key: OAK-8048 > URL: https://issues.apache.org/jira/browse/OAK-8048 > Project: Jackrabbit Oak > Issue Type: Bug > Components: core > Affects Versions: 1.8.9 > Reporter: Marco Piovesana > Priority: Major > > Hi all, > I'm trying to delete a node and all its versions, but the version history is > not removed. I'm doing the following steps (as described in OAK-4370 and > JCR-34): > # retrieve the version history > # delete the node and save the session > # delete all versions except for the base version > # save the session > The versions are all gone but the versionHistory node, and the base version > node, are still there. Am I doing something wrong? > The only test related to this that I found is > {{ReadOnlyVersionManagerTest.testRemoveEmptyHistoryAfterRemovingVersionable}}. > It does work, but uses Oak related classes and not the JCR interface. -- This message was sent by Atlassian JIRA (v7.6.3#76005)