Search in sources :

Example 6 with DefaultNamePathResolver

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);
}
Also used : DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 7 with DefaultNamePathResolver

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");
            }
        }
    }
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) InputStreamReader(java.io.InputStreamReader) NamespaceMapping(org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping) CompactNodeTypeDefReader(org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) StringReader(java.io.StringReader) QNodeTypeDefinition(org.apache.jackrabbit.spi.QNodeTypeDefinition) StringWriter(java.io.StringWriter) QDefinitionBuilderFactory(org.apache.jackrabbit.spi.commons.nodetype.QDefinitionBuilderFactory) StringReader(java.io.StringReader) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) CompactNodeTypeDefReader(org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader) NodeTypeDefDiff(org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefDiff)

Example 8 with DefaultNamePathResolver

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);
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) DummyNamespaceResolver(org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 9 with DefaultNamePathResolver

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;
        }
    });
}
Also used : NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 10 with DefaultNamePathResolver

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

Aggregations

DefaultNamePathResolver (org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)28 NamespaceResolver (org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver)12 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)10 RepositoryException (javax.jcr.RepositoryException)8 AbstractNamespaceResolver (org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver)8 Batch (org.apache.jackrabbit.spi.Batch)6 QValue (org.apache.jackrabbit.spi.QValue)5 DummyNamespaceResolver (org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver)4 Value (javax.jcr.Value)3 Session (javax.jcr.Session)2 Path (org.apache.jackrabbit.spi.Path)2 PathResolver (org.apache.jackrabbit.spi.commons.conversion.PathResolver)2 ValueFactoryQImpl (org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl)2 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Principal (java.security.Principal)1 HashMap (java.util.HashMap)1 ValueFactory (javax.jcr.ValueFactory)1