RepositoryIndexManager(JcrRepository.RunningState repository, RepositoryConfiguration config) {
    this.repository = repository;
    this.config = config;
    this.context = repository.context();
    this.systemWorkspaceName = this.repository.repositoryCache().getSystemWorkspaceName();

    PathFactory pathFactory = this.context.getValueFactories().getPathFactory();
    this.indexesPath = pathFactory.createAbsolutePath(JcrLexicon.SYSTEM, ModeShapeLexicon.INDEXES);

    // Set up the index providers ...
    this.components = config.getIndexProviders();
    for (Component component : components) {
      try {
        IndexProvider provider =
            component.createInstance(ScanningQueryEngine.class.getClassLoader());
        register(provider);
      } catch (Throwable t) {
        if (t.getCause() != null) {
          t = t.getCause();
        }
        this.repository.error(
            t,
            JcrI18n.unableToInitializeIndexProvider,
            component,
            repository.name(),
            t.getMessage());
      }
    }
  }
 RepositoryNodeTypeManager with(
     JcrRepository.RunningState repository,
     boolean includeColumnsForInheritedProperties,
     boolean includePseudoColumnsInSelectStar) {
   assert this.systemWorkspaceName.equals(repository.repositoryCache().getSystemWorkspaceName());
   PathFactory pathFactory = repository.context().getValueFactories().getPathFactory();
   Path nodeTypesPath = pathFactory.createAbsolutePath(JcrLexicon.SYSTEM, JcrLexicon.NODE_TYPES);
   assert this.nodeTypesPath.equals(nodeTypesPath);
   RepositoryNodeTypeManager result =
       new RepositoryNodeTypeManager(
           repository, includeColumnsForInheritedProperties, includePseudoColumnsInSelectStar);
   // Now copy the node types from this cache into the new manager's cache ...
   // (If we didn't do this, we'd have to refresh from the system storage)
   result.nodeTypesCache = result.nodeTypesCache.with(this.nodeTypesCache.getAllNodeTypes());
   return result;
 }
  RepositoryNodeTypeManager(
      JcrRepository.RunningState repository,
      boolean includeColumnsForInheritedProperties,
      boolean includePseudoColumnsInSelectStar) {
    this.repository = repository;
    this.context = repository.context();
    this.nameFactory = this.context.getValueFactories().getNameFactory();
    this.systemWorkspaceName = this.repository.repositoryCache().getSystemWorkspaceName();

    PathFactory pathFactory = this.context.getValueFactories().getPathFactory();
    this.nodeTypesPath = pathFactory.createAbsolutePath(JcrLexicon.SYSTEM, JcrLexicon.NODE_TYPES);
    this.nodeTypesCache = new NodeTypes(this.context);

    this.includeColumnsForInheritedProperties = includeColumnsForInheritedProperties;
    this.includePseudoColumnsInSelectStar = includePseudoColumnsInSelectStar;
    queryParser = new BasicSqlQueryParser();
  }
Esempio n. 4
0
 /**
  * Get all of the paths through which the specified node is accessible, including all paths based
  * upon the node's {@link CachedNode#getParentKey(NodeCache) parent} (which can potentially have
  * multiple paths) and upon the node's {@link CachedNode#getAdditionalParentKeys(NodeCache)
  * additional parents} (which each can potentially have multiple paths).
  *
  * @param node the node for which the paths are to be returned; may not be null
  * @return the paths for the node; never null but possibly empty
  */
 public Iterable<Path> getPaths(CachedNode node) {
   NodeKey key = node.getKey();
   List<Path> pathList = paths.get(key);
   if (pathList == null) {
     // Compute the node's path ...
     Segment nodeSegment = node.getSegment(cache);
     NodeKey parentKey = node.getParentKey(cache);
     if (parentKey == null) {
       // This is the root node ...
       pathList = Collections.singletonList(node.getPath(cache));
     } else {
       // This is not the root node, so add a path for each of the parent's valid paths ...
       CachedNode parent = cache.getNode(parentKey);
       if (parent == null && removedCache != null) {
         // This is a removed node, so check the removed cache ...
         parent = removedCache.getNode(parentKey);
       }
       pathList = new LinkedList<Path>();
       for (Path parentPath : getPaths(parent)) {
         Path path = pathFactory.create(parentPath, nodeSegment);
         pathList.add(path);
       }
       // Get the additional parents ...
       Set<NodeKey> additionalParentKeys = getAdditionalParentKeys(node, cache);
       // There is at least one additional parent ...
       for (NodeKey additionalParentKey : additionalParentKeys) {
         parent = cache.getNode(additionalParentKey);
         for (Path parentPath : getPaths(parent)) {
           Path path = pathFactory.create(parentPath, nodeSegment);
           pathList.add(path);
         }
       }
     }
     assert pathList != null;
     pathList = Collections.unmodifiableList(pathList);
     paths.put(key, pathList);
   }
   return pathList;
 }