Package org.modeshape.jcr.cache

Examples of org.modeshape.jcr.cache.RepositoryCache


        session.checkLive();
        session.checkWorkspacePermission(name, ModeShapePermissions.DELETE_WORKSPACE);
        // start an internal remove session which needs to act as a unit for the entire operation
        JcrSession removeSession = session.spawnSession(name, false);
        JcrRepository repository = session.repository();
        RepositoryCache repositoryCache = repository.repositoryCache();
        NodeKey systemKey = repositoryCache.getSystemKey();
        try {
            JcrRootNode rootNode = removeSession.getRootNode();

            // first remove all the nodes via JCR, because we need validations to be performed
            for (NodeIterator nodeIterator = rootNode.getNodesInternal(); nodeIterator.hasNext();) {
                AbstractJcrNode child = (AbstractJcrNode)nodeIterator.nextNode();
                if (child.key().equals(systemKey)) {
                    // we don't remove the jcr:system node here, we just unlink it via the cache
                    continue;
                }
                child.remove();
            }

            // then remove the workspace itself and unlink the system content. This method will create & save the session cache
            // therefore, we don't need to call removeSession.save() from here.
            if (!repositoryCache.destroyWorkspace(name, (WritableSessionCache)removeSession.cache())) {
                throw new NoSuchWorkspaceException(JcrI18n.workspaceNotFound.text(name, getName()));
            }
        } catch (UnsupportedOperationException e) {
            throw new UnsupportedRepositoryOperationException(e.getMessage());
        } finally {
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.cache.RepositoryCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.