Search in sources :

Example 1 with DECLARING_NODE_TYPES

use of org.apache.jackrabbit.oak.plugins.index.IndexConstants.DECLARING_NODE_TYPES in project jackrabbit-oak by apache.

the class IndexPathServiceImpl method getIndexPaths.

@Override
public Iterable<String> getIndexPaths() {
    NodeState nodeType = NodeStateUtils.getNode(nodeStore.getRoot(), "/oak:index/nodetype");
    checkState("property".equals(nodeType.getString("type")), "nodetype index at " + "/oak:index/nodetype is found to be disabled. Cannot determine the paths of all indexes");
    // Check if oak:QueryIndexDefinition is indexed as part of nodetype index
    boolean indxDefnTypeIndexed = Iterables.contains(nodeType.getNames(DECLARING_NODE_TYPES), INDEX_DEFINITIONS_NODE_TYPE);
    if (!indxDefnTypeIndexed) {
        log.warn("{} is not found to be indexed as part of nodetype index. Non root indexes would " + "not be listed", INDEX_DEFINITIONS_NODE_TYPE);
        NodeState oakIndex = nodeStore.getRoot().getChildNode("oak:index");
        return transform(filter(oakIndex.getChildNodeEntries(), cne -> INDEX_DEFINITIONS_NODE_TYPE.equals(cne.getNodeState().getName(JCR_PRIMARYTYPE))), cne -> PathUtils.concat("/oak:index", cne.getName()));
    }
    return () -> {
        Iterator<IndexRow> itr = getIndex().query(createFilter(INDEX_DEFINITIONS_NODE_TYPE), nodeStore.getRoot());
        return transform(itr, input -> input.getPath());
    };
}
Also used : Iterables(com.google.common.collect.Iterables) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) Iterables.transform(com.google.common.collect.Iterables.transform) PathUtils(org.apache.jackrabbit.oak.commons.PathUtils) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) DECLARING_NODE_TYPES(org.apache.jackrabbit.oak.plugins.index.IndexConstants.DECLARING_NODE_TYPES) JCR_PRIMARYTYPE(org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE) Mounts(org.apache.jackrabbit.oak.spi.mount.Mounts) LoggerFactory(org.slf4j.LoggerFactory) Iterators(com.google.common.collect.Iterators) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) Component(org.osgi.service.component.annotations.Component) MountInfoProvider(org.apache.jackrabbit.oak.spi.mount.MountInfoProvider) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeTypeInfoProvider(org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider) ChildNodeEntry(org.apache.jackrabbit.oak.spi.state.ChildNodeEntry) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) INDEX_DEFINITIONS_NODE_TYPE(org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE) NodeTypeIndexProvider(org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider) Iterators.transform(com.google.common.collect.Iterators.transform) Preconditions.checkState(com.google.common.base.Preconditions.checkState) NodeTypeInfo(org.apache.jackrabbit.oak.query.ast.NodeTypeInfo) IndexRow(org.apache.jackrabbit.oak.spi.query.IndexRow) Iterables.filter(com.google.common.collect.Iterables.filter) Reference(org.osgi.service.component.annotations.Reference) NodeStateUtils(org.apache.jackrabbit.oak.spi.state.NodeStateUtils) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Iterator(java.util.Iterator)

Aggregations

Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Iterables (com.google.common.collect.Iterables)1 Iterables.filter (com.google.common.collect.Iterables.filter)1 Iterables.transform (com.google.common.collect.Iterables.transform)1 Iterators (com.google.common.collect.Iterators)1 Iterators.transform (com.google.common.collect.Iterators.transform)1 Iterator (java.util.Iterator)1 JCR_PRIMARYTYPE (org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE)1 PathUtils (org.apache.jackrabbit.oak.commons.PathUtils)1 DECLARING_NODE_TYPES (org.apache.jackrabbit.oak.plugins.index.IndexConstants.DECLARING_NODE_TYPES)1 INDEX_DEFINITIONS_NODE_TYPE (org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE)1 NodeTypeIndexProvider (org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider)1 NodeStateNodeTypeInfoProvider (org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)1 QueryEngineSettings (org.apache.jackrabbit.oak.query.QueryEngineSettings)1 NodeTypeInfo (org.apache.jackrabbit.oak.query.ast.NodeTypeInfo)1 NodeTypeInfoProvider (org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider)1 SelectorImpl (org.apache.jackrabbit.oak.query.ast.SelectorImpl)1 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)1 MountInfoProvider (org.apache.jackrabbit.oak.spi.mount.MountInfoProvider)1 Mounts (org.apache.jackrabbit.oak.spi.mount.Mounts)1