Search in sources :

Example 1 with PathResolver

use of org.apache.jackrabbit.spi.commons.conversion.PathResolver in project jackrabbit by apache.

the class EventState method setupCachingPathResolver.

private static void setupCachingPathResolver() {
    if (cachingPathResolver != null) {
        return;
    }
    PathResolver pathResolver = new ParsingPathResolver(PathFactoryImpl.getInstance(), new NameResolver() {

        public Name getQName(String name) throws IllegalNameException, NamespaceException {
            return null;
        }

        public String getJCRName(Name name) throws NamespaceException {
            return name.getLocalName();
        }
    });
    cachingPathResolver = new CachingPathResolver(pathResolver);
}
Also used : NamespaceException(javax.jcr.NamespaceException) CachingPathResolver(org.apache.jackrabbit.spi.commons.conversion.CachingPathResolver) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver) IllegalNameException(org.apache.jackrabbit.spi.commons.conversion.IllegalNameException) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver) NameResolver(org.apache.jackrabbit.spi.commons.conversion.NameResolver) Name(org.apache.jackrabbit.spi.Name) CachingPathResolver(org.apache.jackrabbit.spi.commons.conversion.CachingPathResolver)

Example 2 with PathResolver

use of org.apache.jackrabbit.spi.commons.conversion.PathResolver in project jackrabbit by apache.

the class MultiIndex method createIndex.

/**
     * Recursively creates an index starting with the NodeState
     * <code>node</code>.
     *
     * @param node     the current NodeState.
     * @param path     the path of the current <code>node</code> state.
     * @param stateMgr the shared item state manager.
     * @param count    the number of nodes already indexed.
     * @return the number of nodes indexed so far.
     * @throws IOException         if an error occurs while writing to the
     *                             index.
     * @throws ItemStateException  if an node state cannot be found.
     * @throws RepositoryException if any other error occurs
     */
private long createIndex(NodeState node, Path path, ItemStateManager stateMgr, long count) throws IOException, ItemStateException, RepositoryException {
    NodeId id = node.getNodeId();
    if (excludedIDs.contains(id)) {
        return count;
    }
    executeAndLog(new AddNode(getTransactionId(), id));
    if (++count % 100 == 0) {
        PathResolver resolver = new DefaultNamePathResolver(handler.getContext().getNamespaceRegistry());
        log.info("indexing... {} ({})", resolver.getJCRPath(path), count);
    }
    if (count % 10 == 0) {
        checkIndexingQueue(true);
    }
    checkVolatileCommit();
    for (ChildNodeEntry child : node.getChildNodeEntries()) {
        Path childPath = PATH_FACTORY.create(path, child.getName(), child.getIndex(), false);
        NodeState childState = null;
        try {
            childState = (NodeState) stateMgr.getItemState(child.getId());
        } catch (NoSuchItemStateException e) {
            handler.getOnWorkspaceInconsistencyHandler().handleMissingChildNode(e, handler, path, node, child);
        } catch (ItemStateException e) {
            // JCR-3268 log bundle corruption and continue
            handler.getOnWorkspaceInconsistencyHandler().logError(e, handler, childPath, node, child);
        }
        if (childState != null) {
            count = createIndex(childState, childPath, stateMgr, count);
        }
    }
    return count;
}
Also used : Path(org.apache.jackrabbit.spi.Path) NodeState(org.apache.jackrabbit.core.state.NodeState) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ChildNodeEntry(org.apache.jackrabbit.core.state.ChildNodeEntry) NodeId(org.apache.jackrabbit.core.id.NodeId) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 3 with PathResolver

use of org.apache.jackrabbit.spi.commons.conversion.PathResolver in project jackrabbit by apache.

the class NamePathResolverImpl method create.

public static NamePathResolver create(NamespaceMappings nsMappings) {
    NameResolver nResolver = new NameResolverImpl(nsMappings);
    PathResolver pResolver = new ParsingPathResolver(PATH_FACTORY, nResolver);
    return new NamePathResolverImpl(nResolver, pResolver);
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) NameResolver(org.apache.jackrabbit.spi.commons.conversion.NameResolver) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver)

Example 4 with PathResolver

use of org.apache.jackrabbit.spi.commons.conversion.PathResolver in project jackrabbit by apache.

the class RetentionRegistryImplTest method testWriteFile.

public void testWriteFile() throws RepositoryException {
    PathResolver resolver = (SessionImpl) superuser;
    FileSystem fs = createFileSystem();
    RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
    try {
        // write the changes to the fs
        re.close();
        // create a new dummy registry again.
        re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
        // test holds
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3.getPath()), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/somechild"), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/hold/is/deep"), false));
        // test policies
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childNPath + "/somechild"), true));
    } finally {
        re.close();
    }
}
Also used : FileSystem(org.apache.jackrabbit.core.fs.FileSystem) MemoryFileSystem(org.apache.jackrabbit.core.fs.mem.MemoryFileSystem) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) RetentionRegistryImpl(org.apache.jackrabbit.core.retention.RetentionRegistryImpl)

Example 5 with PathResolver

use of org.apache.jackrabbit.spi.commons.conversion.PathResolver in project jackrabbit by apache.

the class RetentionRegistryImplTest method testWriteFileWithChanges.

public void testWriteFileWithChanges() throws RepositoryException, NotExecutableException {
    PathResolver resolver = (SessionImpl) superuser;
    FileSystem fs = createFileSystem();
    RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
    String childN3Path = childN3.getPath();
    try {
        retentionMgr.removeRetentionPolicy(childNPath);
        retentionMgr.removeHold(childNPath, retentionMgr.getHolds(childNPath)[0]);
        superuser.save();
        retentionMgr.setRetentionPolicy(childN3Path, getApplicableRetentionPolicy("retentionOnChild2"));
        retentionMgr.addHold(childNPath, "holdOnChild", false);
        superuser.save();
        // write the changes to the fs
        re.close();
        // create a new dummy registry again.
        re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
        // test holds
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), true));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3Path), true));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path), false));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), false));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), true));
        // test policies
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path), false));
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child"), true));
        assertFalse(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child/more"), true));
        assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), true));
        assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), false));
    } finally {
        re.close();
        // remove the extra policy that is not cleared upon teardown
        if (retentionMgr.getRetentionPolicy(childN3Path) != null) {
            retentionMgr.removeRetentionPolicy(childN3.getPath());
        }
        superuser.save();
    }
}
Also used : FileSystem(org.apache.jackrabbit.core.fs.FileSystem) MemoryFileSystem(org.apache.jackrabbit.core.fs.mem.MemoryFileSystem) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) RetentionRegistryImpl(org.apache.jackrabbit.core.retention.RetentionRegistryImpl)

Aggregations

PathResolver (org.apache.jackrabbit.spi.commons.conversion.PathResolver)7 RetentionRegistryImpl (org.apache.jackrabbit.core.retention.RetentionRegistryImpl)3 DefaultNamePathResolver (org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)3 NameResolver (org.apache.jackrabbit.spi.commons.conversion.NameResolver)3 ParsingPathResolver (org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver)3 FileSystem (org.apache.jackrabbit.core.fs.FileSystem)2 MemoryFileSystem (org.apache.jackrabbit.core.fs.mem.MemoryFileSystem)2 Path (org.apache.jackrabbit.spi.Path)2 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)2 NamespaceException (javax.jcr.NamespaceException)1 NodeId (org.apache.jackrabbit.core.id.NodeId)1 ChildNodeEntry (org.apache.jackrabbit.core.state.ChildNodeEntry)1 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)1 NoSuchItemStateException (org.apache.jackrabbit.core.state.NoSuchItemStateException)1 NodeState (org.apache.jackrabbit.core.state.NodeState)1 Name (org.apache.jackrabbit.spi.Name)1 CachingPathResolver (org.apache.jackrabbit.spi.commons.conversion.CachingPathResolver)1 DummyNamespaceResolver (org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver)1 IdentifierResolver (org.apache.jackrabbit.spi.commons.conversion.IdentifierResolver)1 IllegalNameException (org.apache.jackrabbit.spi.commons.conversion.IllegalNameException)1