code: private void removeOldStructure() throws RepositoryException
     {
        ExtendedSession session = (ExtendedSession)service.getStorageSession();
        try
        {
           if (session.itemExists(storagePathOld))
           {
              NodeIterator usersIter = ((ExtendedNode)session.getItem(usersStorageOld)).getNodesLazily();
              while (usersIter.hasNext())
              {
                 Node currentUser = usersIter.nextNode();
                 currentUser.remove();
                 session.save();
              }
  
              NodeIterator groupsIter = ((ExtendedNode)session.getItem(groupsStorageOld)).getNodesLazily();
              while (groupsIter.hasNext())
              {
                 Node currentGroup = groupsIter.nextNode();
                 currentGroup.remove();
                 session.save();
              }
  
              NodeIterator membershipTypesIter =
                 ((ExtendedNode)session.getItem(membershipTypesStorageOld)).getNodesLazily();
              while (membershipTypesIter.hasNext())
              {
                 Node currentMembershipType = membershipTypesIter.nextNode();
                 currentMembershipType.remove();
                 session.save();
              }
  
              session.getItem(storagePathOld).remove();
              session.save();
           }
        }
        finally
        {
           session.logout();
        }
     }
docs: Method for removing old storage from temporary location.
  @throws RepositoryException