Examples of RepositoryCache


Examples of org.modeshape.jcr.cache.RepositoryCache

        // check that there is something which should be imported
        if (!initialContentConfig.hasInitialContentFile(workspaceName)) {
            return;
        }

        RepositoryCache repositoryCache = repository.repositoryCache();
        WorkspaceCache wsCache = repositoryCache.getWorkspaceCache(workspaceName);
        if (!wsCache.isEmpty()) {
            // the ws cache must be empty for initial content to be imported
            LOGGER.debug("Skipping import of initial content into workspace {0} as it is not empty", workspaceName);
            return;
        }
View Full Code Here

Examples of org.modeshape.jcr.cache.RepositoryCache

        @Override
        public void apply( Context resources ) {
            LOGGER.info(JcrI18n.upgrade4_0_0_Alpha1_Running);
            RunningState runningState = resources.getRepository();
            RepositoryCache repositoryCache = runningState.repositoryCache();

            try {
                long nodesWithAccessControl = 0;
                for (String workspaceName : repositoryCache.getWorkspaceNames()) {
                    JcrSession session = runningState.loginInternalSession(workspaceName);
                    try {
                        JcrQueryManager queryManager = session.getWorkspace().getQueryManager();
                        Query query = queryManager.createQuery(
                                "select [jcr:name] from [" + ModeShapeLexicon.ACCESS_CONTROLLABLE_STRING + "]",
                                JcrQuery.JCR_SQL2);
                        nodesWithAccessControl = query.execute().getRows().getSize();
                    } finally {
                        session.logout();
                    }
                }
                if (nodesWithAccessControl == 0) {
                    repositoryCache.setAccessControlEnabled(false);
                }

                ExecutionContext context = runningState.context();
                SessionCache systemSession = runningState.createSystemSession(context, false);
                SystemContent systemContent = new SystemContent(systemSession);
View Full Code Here

Examples of org.modeshape.jcr.cache.RepositoryCache

        assert command != null : "Could not parse " + expression;

        Schemata schemata = getRepositorySchemata();

        // Now query the entire repository for any nodes that use this node type ...
        RepositoryCache repoCache = repository.repositoryCache();
        RepositoryQueryManager queryManager = repository.queryManager();
        Set<String> workspaceNames = repoCache.getWorkspaceNames();
        Map<String, NodeCache> overridden = null;
        NodeTypes nodeTypes = repository.nodeTypeManager().getNodeTypes();
        RepositoryIndexes indexDefns = repository.queryManager().getIndexes();
        CancellableQuery query = queryManager.query(context, repoCache, workspaceNames, overridden, command, schemata,
                                                    indexDefns, nodeTypes, null, null);
View Full Code Here

Examples of org.modeshape.jcr.cache.RepositoryCache

     */
    protected void reindexIfNeeded() {
        final ScanningRequest request = toBeScanned.drain();
        if (!request.isEmpty()) {
            final IndexWriter writer = indexManager.getIndexWriterForProviders(request.providerNames());
            final RepositoryCache repoCache = runningState.repositoryCache();
            scan(true, writer, new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    // Scan each of the workspace-path pairs ...
                    ScanOperation op = new ScanOperation() {
                        @Override
                        public void scan( String workspaceName,
                                          Path path ) {
                            NodeCache workspaceCache = repoCache.getWorkspaceCache(workspaceName);
                            if (workspaceCache != null) {
                                // The workspace is still valid ...
                                CachedNode node = workspaceCache.getNode(workspaceCache.getRootKey());
                                if (!path.isRoot()) {
                                    for (Path.Segment segment : path) {
                                        ChildReference child = node.getChildReferences(workspaceCache).getChild(segment);
                                        if (child == null) {
                                            // The child no longer exists, so ignore this pair ...
                                            node = null;
                                            break;
                                        }
                                        node = workspaceCache.getNode(child);
                                        if (node == null) break;
                                    }
                                }
                                if (node != null) {
                                    // If we find a node to start at, then scan the content ...
                                    boolean scanSystemContent = repoCache.getSystemWorkspaceName().equals(workspaceName);
                                    reindexContent(workspaceName, workspaceCache, node, Integer.MAX_VALUE, scanSystemContent,
                                                   writer);
                                }
                            }
                        }
View Full Code Here

Examples of org.modeshape.jcr.cache.RepositoryCache

     */
    private void reindexContent( boolean includeSystemContent,
                                 IndexWriter indexes ) {
        if (indexes.canBeSkipped()) return;
        // The node type schemata changes every time a node type is (un)registered, so get the snapshot that we'll use throughout
        RepositoryCache repoCache = runningState.repositoryCache();

        logger.debug(JcrI18n.reindexAll.text(runningState.name()));

        if (includeSystemContent) {
            NodeCache systemWorkspaceCache = repoCache.getWorkspaceCache(repoCache.getSystemWorkspaceName());
            CachedNode rootNode = systemWorkspaceCache.getNode(repoCache.getSystemKey());
            // Index the system content ...
            logger.debug("Starting reindex of system content in '{0}' repository.", runningState.name());
            reindexSystemContent(rootNode, Integer.MAX_VALUE, indexes);
            logger.debug("Completed reindex of system content in '{0}' repository.", runningState.name());
        }

        // Index the non-system workspaces ...
        for (String workspaceName : repoCache.getWorkspaceNames()) {
            NodeCache workspaceCache = repoCache.getWorkspaceCache(workspaceName);
            CachedNode rootNode = workspaceCache.getNode(workspaceCache.getRootKey());
            logger.debug("Starting reindex of workspace '{0}' content in '{1}' repository.", runningState.name(), workspaceName);
            reindexContent(workspaceName, workspaceCache, rootNode, Integer.MAX_VALUE, false, indexes);
            logger.debug("Completed reindex of workspace '{0}' content in '{1}' repository.", runningState.name(), workspaceName);
        }
View Full Code Here

Examples of org.modeshape.jcr.cache.RepositoryCache

    }

    protected void reindexSystemContent( CachedNode nodeInSystemBranch,
                                         int depth,
                                         IndexWriter indexes ) {
        RepositoryCache repoCache = runningState.repositoryCache();
        String workspaceName = repoCache.getSystemWorkspaceName();
        NodeCache systemWorkspaceCache = repoCache.getWorkspaceCache(workspaceName);
        reindexContent(workspaceName, systemWorkspaceCache, nodeInSystemBranch, depth, true, indexes);
    }
View Full Code Here

Examples of org.modeshape.jcr.cache.RepositoryCache

        NodeCache systemWorkspaceCache = repoCache.getWorkspaceCache(workspaceName);
        reindexContent(workspaceName, systemWorkspaceCache, nodeInSystemBranch, depth, true, indexes);
    }

    protected void reindexSystemContent() {
        RepositoryCache repoCache = runningState.repositoryCache();
        String workspaceName = repoCache.getSystemWorkspaceName();
        NodeCache systemWorkspaceCache = repoCache.getWorkspaceCache(workspaceName);
        CachedNode systemNode = systemWorkspaceCache.getNode(repoCache.getSystemKey());
        reindexContent(workspaceName, systemWorkspaceCache, systemNode, Integer.MAX_VALUE, true, getIndexWriter());
    }
View Full Code Here

Examples of org.modeshape.jcr.cache.RepositoryCache

            RepositoryIndexes indexDefns = session.repository().queryManager().getIndexes();
            ExecutionContext context = session.context();
            String workspaceName = session.workspaceName();
            JcrRepository.RunningState state = session.repository().runningState();
            RepositoryQueryManager queryManager = state.queryManager();
            RepositoryCache repoCache = state.repositoryCache();
            NodeCache nodeCache = hints.useSessionContent ? session.cache() : session.cache().getWorkspace();
            Map<String, NodeCache> overriddenNodeCaches = new HashMap<String, NodeCache>();
            overriddenNodeCaches.put(workspaceName, nodeCache);
            Set<String> workspaceNames = null;
            if (hints.includeSystemContent) {
                workspaceNames = new LinkedHashSet<String>();
                workspaceNames.add(workspaceName);
                workspaceNames.add(repoCache.getSystemWorkspaceName());
            } else {
                workspaceNames = Collections.singleton(workspaceName);
            }
            return queryManager.query(context, repoCache, workspaceNames, overriddenNodeCaches, query, schemata, indexDefns,
                                      nodeTypes, hints, variables);
View Full Code Here

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

Examples of org.openrdf.repository.http.helpers.RepositoryCache

  public HTTPRepository(String serverURL, String repositoryID) {
    ValueFactory vf = new ValueFactoryImpl(new BNodeFactoryImpl(), uf, lf);
    pool = new HTTPConnectionPool(serverURL, vf);
    client = new SesameClient(pool).repositories().slash(repositoryID);
    cache = new RepositoryCache(client);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.