Package org.exoplatform.services.jcr.impl.core.query

Examples of org.exoplatform.services.jcr.impl.core.query.QueryHandlerContext


    * @throws RepositoryException
    */
   @Override
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      final File indexDirectory;
      if (path != null)
      {
         indexDirectory = new File(path);
         SecurityHelper.doPriviledgedRepositoryExceptionAction(new PrivilegedExceptionAction<Object>()
         {
            public Object run() throws Exception
            {
               if (!indexDirectory.exists())
               {
                  if (!indexDirectory.mkdirs())
                  {
                     throw new RepositoryException("fail to create index dir " + path);
                  }
               }
               return null;
            }
         });
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("path=" + path);

      // Set excludedIDs = new HashSet();
      // if (context.getExcludedNodeId() != null)
      // {
      // excludedIDs.add(context.getExcludedNodeId());
      // }

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();//queryHandlerConfig.createSynonymProvider(cfm);
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         final File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         boolean fileExists = SecurityHelper.doPriviledgedAction(new PrivilegedAction<Boolean>()
         {
            public Boolean run()
            {
               return mapFile.exists();
            }
         });
         if (fileExists)
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         if (index.numDocs() == 0 && context.isCreateInitialIndex())
         {
            index.createInitialIndex(context.getItemStateManager());
         }
         if (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck))
         {
            log.info("Running consistency check...");
            try
            {
               ConsistencyCheck check = ConsistencyCheck.run(index, context.getItemStateManager());
               if (autoRepair)
               {
                  check.repair(true);
               }
               else
View Full Code Here


    * @throws RepositoryException
    */
   @Override
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      final File indexDirectory;
      if (path != null)
      {
         indexDirectory = new File(path);

         if (!indexDirectory.exists())
         {
            if (!indexDirectory.mkdirs())
            {
               throw new RepositoryException("fail to create index dir " + path);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("path=" + path);

      // Set excludedIDs = new HashSet();
      // if (context.getExcludedNodeId() != null)
      // {
      // excludedIDs.add(context.getExcludedNodeId());
      // }

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();//queryHandlerConfig.createSynonymProvider(cfm);
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         if (mapFile.exists())
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         // set true if indexRecoveryFilters are required and some filter gives positive flag
         final boolean doReindexing = (index.numDocs() == 0 && context.isCreateInitialIndex());
         // if existing index should be removed
         final boolean doForceReindexing = (context.isRecoveryFilterUsed() && isIndexRecoveryRequired());

         final boolean doCheck = (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck));
         final ItemDataConsumer itemStateManager = context.getItemStateManager();

         if (isAsyncReindexing() && doReindexing)
         {
            log.info("Launching reindexing in asynchronous mode.");
            new Thread(new Runnable()
            {
               public void run()
               {
                  try
                  {
                     reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
                  }
                  catch (IOException e)
                  {
                     log
                        .error(
                           "Error while reindexing the workspace. Please fix the problem, delete index and restart server.",
                           e);
                  }
               }
            }, "Reindexing-" + context.getRepositoryName() + "-" + context.getContainer().getWorkspaceName()).start();
         }
         else
         {
            reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
         }
View Full Code Here

    * @throws RepositoryException
    */
   @Override
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      final File indexDirectory;
      if (path != null)
      {
         indexDirectory = new File(path);

         if (!indexDirectory.exists())
         {
            if (!indexDirectory.mkdirs())
            {
               throw new RepositoryException("fail to create index dir " + path);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("Index created: " + path);

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         if (mapFile.exists())
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldComparatorSource(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      sics =
         new SharedFieldInsensitiveComparatorSource(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
     
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         // set true if indexRecoveryFilters are required and some filter gives positive flag
         final boolean doReindexing = (index.numDocs() == 0 && context.isCreateInitialIndex());
         // if existing index should be removed
         final boolean doForceReindexing = (context.isRecoveryFilterUsed() && isIndexRecoveryRequired());

         final boolean doCheck = (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck));
         final ItemDataConsumer itemStateManager = context.getItemStateManager();

         if (isAsyncReindexing() && doReindexing)
         {
            log.info("Launching reindexing in asynchronous mode.");
            new Thread(new Runnable()
            {
               public void run()
               {
                  try
                  {
                     reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
                  }
                  catch (IOException e)
                  {
                     log.error(
                        "Error while reindexing the workspace. Please fix the problem, delete index and restart server.",
                        e);
                  }
               }
            }, "Reindexing-" + context.getRepositoryName() + "-" + context.getContainer().getWorkspaceName()).start();
         }
         else
         {
            reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
         }
View Full Code Here

    *             if an error occurs while initializing this handler.
    * @throws RepositoryException
    */
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      File indexDirectory;
      if (path != null)
      {

         indexDirectory = new File(path);
         if (!indexDirectory.exists())
         {
            if (!indexDirectory.mkdirs())
            {
               throw new RepositoryException("fail to create index dir " + path);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("path=" + path);

      // Set excludedIDs = new HashSet();
      // if (context.getExcludedNodeId() != null)
      // {
      // excludedIDs.add(context.getExcludedNodeId());
      // }

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();//queryHandlerConfig.createSynonymProvider(cfm);
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         if (mapFile.exists())
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         if (index.numDocs() == 0 && context.isCreateInitialIndex())
         {
            index.createInitialIndex(context.getItemStateManager());
         }
         if (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck))
         {
            log.info("Running consistency check...");
            try
            {
               ConsistencyCheck check = ConsistencyCheck.run(index, context.getItemStateManager());
               if (autoRepair)
               {
                  check.repair(true);
               }
               else
View Full Code Here

    * @throws RepositoryException
    */
   @Override
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      final File indexDirectory;
      if (path != null)
      {
         indexDirectory = new File(path);

         try
         {
            SecurityHelper.doPrivilegedExceptionAction((new PrivilegedExceptionAction<Object>()
            {
               public Object run() throws Exception
               {
                  if (!indexDirectory.exists())
                  {
                     if (!indexDirectory.mkdirs())
                     {
                        throw new RepositoryException("fail to create index dir " + path);
                     }
                  }
                  return null;
               }
            }));
         }
         catch (PrivilegedActionException pae)
         {
            Throwable cause = pae.getCause();
            if (cause instanceof RepositoryException)
            {
               throw (RepositoryException)cause;
            }
            else if (cause instanceof RuntimeException)
            {
               throw (RuntimeException)cause;
            }
            else
            {
               throw new RuntimeException(cause);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("path=" + path);

      // Set excludedIDs = new HashSet();
      // if (context.getExcludedNodeId() != null)
      // {
      // excludedIDs.add(context.getExcludedNodeId());
      // }

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();//queryHandlerConfig.createSynonymProvider(cfm);
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         final File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         boolean fileExists = SecurityHelper.doPrivilegedAction(new PrivilegedAction<Boolean>()
         {
            public Boolean run()
            {
               return mapFile.exists();
            }
         });
         if (fileExists)
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         final boolean doReindexing = (index.numDocs() == 0 && context.isCreateInitialIndex());
         final boolean doCheck = (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck));
         final ItemDataConsumer itemStateManager = context.getItemStateManager();

         if (isAsyncReindexing() && doReindexing)
         {
            log.info("Launching reindexing in asynchronous mode.");
            new Thread(new Runnable()
            {
               public void run()
               {
                  try
                  {
                     reindex(doReindexing, doCheck, itemStateManager);
                  }
                  catch (IOException e)
                  {
                     log
                        .error(
                           "Error while reindexing the workspace. Please fix the problem, delete index and restart server.",
                           e);
                  }
               }
            }, "Reindexing-" + context.getRepositoryName() + "-" + context.getContainer().getWorkspaceName()).start();
         }
         else
         {
            reindex(doReindexing, doCheck, itemStateManager);
         }
View Full Code Here

    *             if an error occurs while initializing this handler.
    * @throws RepositoryException
    */
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      File indexDirectory;
      if (path != null)
      {

         indexDirectory = new File(path);
         if (!indexDirectory.exists())
         {
            if (!indexDirectory.mkdirs())
            {
               throw new RepositoryException("fail to create index dir " + path);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("path=" + path);

      // Set excludedIDs = new HashSet();
      // if (context.getExcludedNodeId() != null)
      // {
      // excludedIDs.add(context.getExcludedNodeId());
      // }

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();//queryHandlerConfig.createSynonymProvider(cfm);
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         if (mapFile.exists())
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         if (index.numDocs() == 0 && context.isCreateInitialIndex())
         {
            index.createInitialIndex(context.getItemStateManager());
         }
         if (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck))
         {
            log.info("Running consistency check...");
            try
            {
               ConsistencyCheck check = ConsistencyCheck.run(index, context.getItemStateManager());
               if (autoRepair)
               {
                  check.repair(true);
               }
               else
View Full Code Here

    * @throws RepositoryException
    */
   @Override
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      final File indexDirectory;
      if (path != null)
      {
         indexDirectory = new File(path);

         if (!indexDirectory.exists())
         {
            if (!indexDirectory.mkdirs())
            {
               throw new RepositoryException("fail to create index dir " + path);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("path=" + path);

      // Set excludedIDs = new HashSet();
      // if (context.getExcludedNodeId() != null)
      // {
      // excludedIDs.add(context.getExcludedNodeId());
      // }

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();//queryHandlerConfig.createSynonymProvider(cfm);
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         if (mapFile.exists())
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         // set true if indexRecoveryFilters are required and some filter gives positive flag
         final boolean doReindexing = (index.numDocs() == 0 && context.isCreateInitialIndex());
         // if existing index should be removed
         final boolean doForceReindexing = (context.isRecoveryFilterUsed() && isIndexRecoveryRequired());

         final boolean doCheck = (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck));
         final ItemDataConsumer itemStateManager = context.getItemStateManager();

         if (isAsyncReindexing() && doReindexing)
         {
            log.info("Launching reindexing in asynchronous mode.");
            new Thread(new Runnable()
            {
               public void run()
               {
                  try
                  {
                     reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
                  }
                  catch (IOException e)
                  {
                     log
                        .error(
                           "Error while reindexing the workspace. Please fix the problem, delete index and restart server.",
                           e);
                  }
               }
            }, "Reindexing-" + context.getRepositoryName() + "-" + context.getContainer().getWorkspaceName()).start();
         }
         else
         {
            reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
         }
View Full Code Here

    * @throws RepositoryException
    */
   @Override
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      final File indexDirectory;
      if (path != null)
      {
         indexDirectory = new File(path);

         if (!indexDirectory.exists())
         {
            if (!indexDirectory.mkdirs())
            {
               throw new RepositoryException("fail to create index dir " + path);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("path=" + path);

      // Set excludedIDs = new HashSet();
      // if (context.getExcludedNodeId() != null)
      // {
      // excludedIDs.add(context.getExcludedNodeId());
      // }

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();//queryHandlerConfig.createSynonymProvider(cfm);
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         if (mapFile.exists())
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         // set true if indexRecoveryFilters are required and some filter gives positive flag
         final boolean doReindexing = (index.numDocs() == 0 && context.isCreateInitialIndex());
         // if existing index should be removed
         final boolean doForceReindexing = (context.isRecoveryFilterUsed() && isIndexRecoveryRequired());

         final boolean doCheck = (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck));
         final ItemDataConsumer itemStateManager = context.getItemStateManager();

         if (isAsyncReindexing() && doReindexing)
         {
            log.info("Launching reindexing in asynchronous mode.");
            new Thread(new Runnable()
            {
               public void run()
               {
                  try
                  {
                     reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
                  }
                  catch (IOException e)
                  {
                     log
                        .error(
                           "Error while reindexing the workspace. Please fix the problem, delete index and restart server.",
                           e);
                  }
               }
            }, "Reindexing-" + context.getRepositoryName() + "-" + context.getContainer().getWorkspaceName()).start();
         }
         else
         {
            reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
         }
View Full Code Here

    * @throws RepositoryException
    */
   @Override
   public void doInit() throws IOException, RepositoryException
   {
      QueryHandlerContext context = getContext();
      setPath(context.getIndexDirectory());
      if (path == null)
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }

      final File indexDirectory;
      if (path != null)
      {
         indexDirectory = new File(path);

         if (!indexDirectory.exists())
         {
            if (!indexDirectory.mkdirs())
            {
               throw new RepositoryException("fail to create index dir " + path);
            }
         }
      }
      else
      {
         throw new IOException("SearchIndex requires 'path' parameter in configuration!");
      }
      log.info("Index created: " + path);

      extractor = context.getExtractor();
      synProvider = createSynonymProvider();
      directoryManager = createDirectoryManager();

      if (context.getParentHandler() instanceof SearchIndex)
      {
         // use system namespace mappings
         SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
         nsMappings = sysIndex.getNamespaceMappings();
      }
      else
      {
         // read local namespace mappings
         File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
         if (mapFile.exists())
         {
            // be backward compatible and use ns_mappings.properties from
            // index folder
            nsMappings = new FileBasedNamespaceMappings(mapFile);
         }
         else
         {
            // otherwise use repository wide stable index prefix from
            // namespace registry
            nsMappings = new NSRegistryBasedNamespaceMappings(context.getNamespaceRegistry());
         }
      }

      scs = new SharedFieldComparatorSource(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
      sics =
         new SharedFieldInsensitiveComparatorSource(FieldNames.PROPERTIES, context.getItemStateManager(), nsMappings);
     
      npResolver = new LocationFactory(nsMappings);

      indexingConfig = createIndexingConfiguration(nsMappings);
      analyzer.setIndexingConfig(indexingConfig);

      index = new MultiIndex(this, context.getIndexingTree(), modeHandler, getIndexInfos(), getIndexUpdateMonitor());
      // if RW mode, create initial index and start check
      if (modeHandler.getMode() == IndexerIoMode.READ_WRITE)
      {
         // set true if indexRecoveryFilters are required and some filter gives positive flag
         final boolean doReindexing = (index.numDocs() == 0 && context.isCreateInitialIndex());
         // if existing index should be removed
         final boolean doForceReindexing = (context.isRecoveryFilterUsed() && isIndexRecoveryRequired());

         final boolean doCheck = (consistencyCheckEnabled && (index.getRedoLogApplied() || forceConsistencyCheck));
         final ItemDataConsumer itemStateManager = context.getItemStateManager();

         if (isAsyncReindexing() && doReindexing)
         {
            log.info("Launching reindexing in asynchronous mode.");
            new Thread(new Runnable()
            {
               public void run()
               {
                  try
                  {
                     reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
                  }
                  catch (IOException e)
                  {
                     log.error(
                        "Error while reindexing the workspace. Please fix the problem, delete index and restart server.",
                        e);
                  }
               }
            }, "Reindexing-" + context.getRepositoryName() + "-" + context.getContainer().getWorkspaceName()).start();
         }
         else
         {
            reindex(doReindexing, doForceReindexing, doCheck, itemStateManager);
         }
View Full Code Here

     * @throws IOException
     *             if an error occurs while initializing this handler.
     * @throws RepositoryException
     */
    public void doInit() throws IOException, RepositoryException {
  QueryHandlerContext context = getContext();
  setPath(context.getIndexDirectory());
  if (path == null) {
      throw new IOException(
        "SearchIndex requires 'path' parameter in configuration!");
  }

  File indexDirectory;
  if (path != null) {

      indexDirectory = new File(path);
      if (!indexDirectory.exists())
    if (!indexDirectory.mkdirs())
        throw new RepositoryException("fail to create index dir "
          + path);
  } else {
      throw new IOException(
        "SearchIndex requires 'path' parameter in configuration!");
  }
  log.info("path=" + path);

  // Set excludedIDs = new HashSet();
  // if (context.getExcludedNodeId() != null)
  // {
  // excludedIDs.add(context.getExcludedNodeId());
  // }

  extractor = context.getExtractor();
  // synProvider = queryHandlerConfig.createSynonymProvider(cfm);
  directoryManager = createDirectoryManager();

  if (context.getParentHandler() instanceof SearchIndex) {
      // use system namespace mappings
      SearchIndex sysIndex = (SearchIndex) context.getParentHandler();
      nsMappings = sysIndex.getNamespaceMappings();
  } else {
      // read local namespace mappings
      File mapFile = new File(indexDirectory, NS_MAPPING_FILE);
      if (mapFile.exists()) {
    // be backward compatible and use ns_mappings.properties from
    // index folder
    nsMappings = new FileBasedNamespaceMappings(mapFile);
      } else {
    // otherwise use repository wide stable index prefix from
    // namespace registry
    nsMappings = new NSRegistryBasedNamespaceMappings(context
      .getNamespaceRegistry());
      }
  }

  scs = new SharedFieldSortComparator(FieldNames.PROPERTIES, context
    .getItemStateManager(), nsMappings);
  npResolver = new LocationFactory(nsMappings);

  indexingConfig = createIndexingConfiguration(nsMappings);
  analyzer.setIndexingConfig(indexingConfig);

  index = new MultiIndex(this, context.getIndexingTree());
  if (index.numDocs() == 0 && context.isCreateInitialIndex()) {

      index.createInitialIndex(context.getItemStateManager());
  }
  if (consistencyCheckEnabled
    && (index.getRedoLogApplied() || forceConsistencyCheck)) {
      log.info("Running consistency check...");
      try {
    ConsistencyCheck check = ConsistencyCheck.run(index, context
      .getItemStateManager());
    if (autoRepair) {
        check.repair(true);
    } else {
        List errors = check.getErrors();
View Full Code Here

TOP

Related Classes of org.exoplatform.services.jcr.impl.core.query.QueryHandlerContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.