use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver in project jackrabbit by apache.
the class QDefinitionBuilderFactory method setNamespaceMapping.
@Override
public void setNamespaceMapping(NamespaceMapping nsMapping) {
this.nsMappings = nsMapping;
this.resolver = new DefaultNamePathResolver(nsMapping);
}
use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver in project jackrabbit by apache.
the class CompactNodeTypeDefTest method testCompactNodeTypeDef.
public void testCompactNodeTypeDef() throws Exception {
// Read in node type def from test file
Reader reader = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(TEST_FILE));
CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping> cndReader = new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(reader, TEST_FILE, new QDefinitionBuilderFactory());
List<QNodeTypeDefinition> ntdList1 = cndReader.getNodeTypeDefinitions();
NamespaceMapping nsm = cndReader.getNamespaceMapping();
NamePathResolver resolver = new DefaultNamePathResolver(nsm);
// Put imported node type def back into CND form with CND writer
StringWriter sw = new StringWriter();
CompactNodeTypeDefWriter.write(ntdList1, nsm, resolver, sw);
// Rerun the reader on the product of the writer
cndReader = new CompactNodeTypeDefReader<QNodeTypeDefinition, NamespaceMapping>(new StringReader(sw.toString()), TEST_FILE, new QDefinitionBuilderFactory());
List<QNodeTypeDefinition> ntdList2 = cndReader.getNodeTypeDefinitions();
if (ntdList1.size() == 0 || ntdList1.size() != ntdList2.size()) {
fail("Exported node type definition was not successfully read back in");
} else {
for (int k = 0; k < ntdList1.size(); k++) {
QNodeTypeDefinition ntd1 = ntdList1.get(k);
QNodeTypeDefinition ntd2 = ntdList2.get(k);
NodeTypeDefDiff diff = NodeTypeDefDiff.create(ntd1, ntd2);
if (diff.isModified() && !diff.isTrivial()) {
fail("Exported node type definition was not successfully read back in. " + ntd2.getName() + "differs from original");
}
}
}
}
use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver in project jackrabbit by apache.
the class NodeDefinitionTemplateImplTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
NamePathResolver resolver = new DefaultNamePathResolver(new DummyNamespaceResolver());
tmpl = new NodeDefinitionTemplateImpl(resolver);
}
use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver in project jackrabbit by apache.
the class ValueConstraintTest method setUp.
protected void setUp() throws Exception {
super.setUp();
valueFactory = QValueFactoryImpl.getInstance();
resolver = new DefaultNamePathResolver(new NamespaceResolver() {
public String getURI(String prefix) throws NamespaceException {
return prefix;
}
public String getPrefix(String uri) throws NamespaceException {
return uri;
}
});
}
use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver 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;
}
Aggregations