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

         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());
      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("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

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.