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);
}
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;
}
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);
}
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();
}
}
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();
}
}
Aggregations