Class DefaultIndexingContext

    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultIndexingContext​(java.lang.String id, java.lang.String repositoryId, java.io.File repository, java.io.File indexDirectoryFile, java.lang.String repositoryUrl, java.lang.String indexUpdateUrl, java.util.List<? extends IndexCreator> indexCreators, boolean reclaimIndex)  
      DefaultIndexingContext​(java.lang.String id, java.lang.String repositoryId, java.io.File repository, org.apache.lucene.store.Directory indexDirectory, java.lang.String repositoryUrl, java.lang.String indexUpdateUrl, java.util.List<? extends IndexCreator> indexCreators, boolean reclaimIndex)
      Deprecated.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.lucene.search.IndexSearcher acquireIndexSearcher()
      Acquires a fresh instance of IndexSearcher.
      void close​(boolean deleteFiles)
      Shuts down this context.
      void commit()
      Commits changes to context, eventually refreshing readers/searchers too.
      protected org.apache.lucene.document.Document createGroupsDocument​(java.util.Collection<java.lang.String> groups, java.lang.String field, java.lang.String fieldValue, java.lang.String listField)  
      java.util.Set<java.lang.String> getAllGroups()
      Gets all group names stored in the current indexing context
      org.apache.lucene.analysis.Analyzer getAnalyzer()
      Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher.
      GavCalculator getGavCalculator()
      Returns the GavCalculator for this Context.
      protected java.util.Set<java.lang.String> getGroups​(java.lang.String field, java.lang.String filedValue, java.lang.String listField)  
      java.lang.String getId()
      Returns this indexing context id.
      java.util.List<IndexCreator> getIndexCreators()
      List of IndexCreators used in this context.
      org.apache.lucene.store.Directory getIndexDirectory()  
      java.io.File getIndexDirectoryFile()  
      java.lang.String getIndexUpdateUrl()
      Returns url for the index update
      org.apache.lucene.index.IndexWriter getIndexWriter()
      Returns the Lucene IndexWriter (thread safe, shared instance) of this context.
      java.io.File getRepository()
      Returns location for the local repository.
      java.lang.String getRepositoryId()
      Returns repository id.
      java.lang.String getRepositoryUrl()
      Returns public repository url.
      java.util.Set<java.lang.String> getRootGroups()
      Gets root group names stored in the current indexing context
      int getSize()
      Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more data indexed?).
      java.util.Date getTimestamp()
      Returns index update time
      protected org.apache.lucene.index.IndexWriterConfig getWriterConfig()
      Returns new IndexWriterConfig instance
      boolean isSearchable()
      Is the context searchable when doing "non-targeted" searches? Ie.
      void merge​(org.apache.lucene.store.Directory directory)
      Merges content of given Lucene directory with this context.
      void merge​(org.apache.lucene.store.Directory directory, DocumentFilter filter)
      Merges content of given Lucene directory with this context, but filters out the unwanted ones.
      protected void openAndWarmup()  
      void optimize()
      Optimizes index.
      void purge()
      Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.
      void rebuildGroups()
      Rebuilds stored group names from the index
      void releaseIndexSearcher​(org.apache.lucene.search.IndexSearcher is)
      Releases the IndexSearcher instance.
      void replace​(org.apache.lucene.store.Directory directory)
      Replaces the Lucene index with the one from supplied directory.
      void replace​(org.apache.lucene.store.Directory directory, java.util.Set<java.lang.String> allGroups, java.util.Set<java.lang.String> rootGroups)  
      void rollback()
      Rolls back changes to context, eventually refreshing readers/searchers too.
      void setAllGroups​(java.util.Collection<java.lang.String> groups)
      Sets all group names stored in the current indexing context
      protected void setGroups​(java.util.Collection<java.lang.String> groups, java.lang.String groupField, java.lang.String groupFieldValue, java.lang.String groupListField)  
      protected void setIndexDirectoryFile​(java.io.File dir)
      Sets index location.
      void setRootGroups​(java.util.Collection<java.lang.String> groups)
      Sets root group names stored in the current indexing context
      void setSearchable​(boolean searchable)
      Sets is the context searchable when doing "non-targeted" searches.
      java.lang.String toString()  
      void updateTimestamp()  
      void updateTimestamp​(boolean save)  
      void updateTimestamp​(boolean save, java.util.Date timestamp)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DefaultIndexingContext

        public DefaultIndexingContext​(java.lang.String id,
                                      java.lang.String repositoryId,
                                      java.io.File repository,
                                      java.io.File indexDirectoryFile,
                                      java.lang.String repositoryUrl,
                                      java.lang.String indexUpdateUrl,
                                      java.util.List<? extends IndexCreator> indexCreators,
                                      boolean reclaimIndex)
                               throws java.io.IOException,
                                      ExistingLuceneIndexMismatchException
        Throws:
        java.io.IOException
        ExistingLuceneIndexMismatchException
      • DefaultIndexingContext

        @Deprecated
        public DefaultIndexingContext​(java.lang.String id,
                                      java.lang.String repositoryId,
                                      java.io.File repository,
                                      org.apache.lucene.store.Directory indexDirectory,
                                      java.lang.String repositoryUrl,
                                      java.lang.String indexUpdateUrl,
                                      java.util.List<? extends IndexCreator> indexCreators,
                                      boolean reclaimIndex)
                               throws java.io.IOException,
                                      ExistingLuceneIndexMismatchException
        Deprecated.
        Throws:
        java.io.IOException
        ExistingLuceneIndexMismatchException
    • Method Detail

      • getIndexDirectory

        public org.apache.lucene.store.Directory getIndexDirectory()
      • setIndexDirectoryFile

        protected void setIndexDirectoryFile​(java.io.File dir)
                                      throws java.io.IOException
        Sets index location. As usually index is persistent (is on disk), this will point to that value, but in some circumstances (ie, using RAMDisk for index), this will point to an existing tmp directory.
        Throws:
        java.io.IOException
      • getIndexDirectoryFile

        public java.io.File getIndexDirectoryFile()
      • isSearchable

        public boolean isSearchable()
        Description copied from interface: IndexingContext
        Is the context searchable when doing "non-targeted" searches? Ie. Should it take a part when searching without specifying context?
        Returns:
      • setSearchable

        public void setSearchable​(boolean searchable)
        Description copied from interface: IndexingContext
        Sets is the context searchable when doing "non-targeted" searches.
      • getId

        public java.lang.String getId()
        Description copied from interface: IndexingContext
        Returns this indexing context id.
      • updateTimestamp

        public void updateTimestamp()
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • updateTimestamp

        public void updateTimestamp​(boolean save)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • updateTimestamp

        public void updateTimestamp​(boolean save,
                                    java.util.Date timestamp)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getTimestamp

        public java.util.Date getTimestamp()
        Description copied from interface: IndexingContext
        Returns index update time
      • getSize

        public int getSize()
                    throws java.io.IOException
        Description copied from interface: IndexingContext
        Returns a number that represents the "size" useful for doing comparisons between contexts (which one has more data indexed?). The number return does not represent the count of ArtifactInfos, neither other "meaningful" info, it is purely to be used for inter-context comparisons only!
        Returns:
        Throws:
        java.io.IOException
      • getRepositoryId

        public java.lang.String getRepositoryId()
        Description copied from interface: IndexingContext
        Returns repository id.
      • getRepository

        public java.io.File getRepository()
        Description copied from interface: IndexingContext
        Returns location for the local repository.
      • getRepositoryUrl

        public java.lang.String getRepositoryUrl()
        Description copied from interface: IndexingContext
        Returns public repository url.
      • getIndexUpdateUrl

        public java.lang.String getIndexUpdateUrl()
        Description copied from interface: IndexingContext
        Returns url for the index update
      • getAnalyzer

        public org.apache.lucene.analysis.Analyzer getAnalyzer()
        Description copied from interface: IndexingContext
        Returns the Lucene Analyzer of this context used for by IndexWriter and IndexSearcher. Note: this method always creates a new instance of analyzer!
        Returns:
      • openAndWarmup

        protected void openAndWarmup()
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • getWriterConfig

        protected org.apache.lucene.index.IndexWriterConfig getWriterConfig()
        Returns new IndexWriterConfig instance
        Since:
        5.1
      • getIndexWriter

        public org.apache.lucene.index.IndexWriter getIndexWriter()
                                                           throws java.io.IOException
        Description copied from interface: IndexingContext
        Returns the Lucene IndexWriter (thread safe, shared instance) of this context.
        Returns:
        indexWriter
        Throws:
        java.io.IOException
      • acquireIndexSearcher

        public org.apache.lucene.search.IndexSearcher acquireIndexSearcher()
                                                                    throws java.io.IOException
        Description copied from interface: IndexingContext
        Acquires a fresh instance of IndexSearcher. You have to release the received instance with IndexingContext.releaseIndexSearcher(IndexSearcher) otherwise you are about to introduce leak.
        Returns:
        Throws:
        java.io.IOException
      • releaseIndexSearcher

        public void releaseIndexSearcher​(org.apache.lucene.search.IndexSearcher is)
                                  throws java.io.IOException
        Description copied from interface: IndexingContext
        Releases the IndexSearcher instance.
        Throws:
        java.io.IOException
      • commit

        public void commit()
                    throws java.io.IOException
        Description copied from interface: IndexingContext
        Commits changes to context, eventually refreshing readers/searchers too.
        Throws:
        java.io.IOException
      • rollback

        public void rollback()
                      throws java.io.IOException
        Description copied from interface: IndexingContext
        Rolls back changes to context, eventually refreshing readers/searchers too.
        Throws:
        java.io.IOException
      • optimize

        public void optimize()
                      throws org.apache.lucene.index.CorruptIndexException,
                             java.io.IOException
        Description copied from interface: IndexingContext
        Optimizes index. According to Lucene 3.6+ Javadoc, there is no more sense to optimize, so this method might become "noop".
        Throws:
        org.apache.lucene.index.CorruptIndexException
        java.io.IOException
      • close

        public void close​(boolean deleteFiles)
                   throws java.io.IOException
        Description copied from interface: IndexingContext
        Shuts down this context.
        Throws:
        java.io.IOException
      • purge

        public void purge()
                   throws java.io.IOException
        Description copied from interface: IndexingContext
        Purge (cleans) the context, deletes/empties the index and restores the context to new/empty state.
        Throws:
        java.io.IOException
      • replace

        public void replace​(org.apache.lucene.store.Directory directory)
                     throws java.io.IOException
        Description copied from interface: IndexingContext
        Replaces the Lucene index with the one from supplied directory.
        Throws:
        java.io.IOException
      • replace

        public void replace​(org.apache.lucene.store.Directory directory,
                            java.util.Set<java.lang.String> allGroups,
                            java.util.Set<java.lang.String> rootGroups)
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • merge

        public void merge​(org.apache.lucene.store.Directory directory)
                   throws java.io.IOException
        Description copied from interface: IndexingContext
        Merges content of given Lucene directory with this context.
        Parameters:
        directory - - the directory to merge
        Throws:
        java.io.IOException
      • merge

        public void merge​(org.apache.lucene.store.Directory directory,
                          DocumentFilter filter)
                   throws java.io.IOException
        Description copied from interface: IndexingContext
        Merges content of given Lucene directory with this context, but filters out the unwanted ones.
        Parameters:
        directory - - the directory to merge
        Throws:
        java.io.IOException
      • getGavCalculator

        public GavCalculator getGavCalculator()
        Description copied from interface: IndexingContext
        Returns the GavCalculator for this Context. Implies repository layout.
      • getIndexCreators

        public java.util.List<IndexCreator> getIndexCreators()
        Description copied from interface: IndexingContext
        List of IndexCreators used in this context.
        Returns:
        list of index creators.
      • rebuildGroups

        public void rebuildGroups()
                           throws java.io.IOException
        Description copied from interface: IndexingContext
        Rebuilds stored group names from the index
        Throws:
        java.io.IOException
      • getAllGroups

        public java.util.Set<java.lang.String> getAllGroups()
                                                     throws java.io.IOException
        Description copied from interface: IndexingContext
        Gets all group names stored in the current indexing context
        Throws:
        java.io.IOException
      • setAllGroups

        public void setAllGroups​(java.util.Collection<java.lang.String> groups)
                          throws java.io.IOException
        Description copied from interface: IndexingContext
        Sets all group names stored in the current indexing context
        Throws:
        java.io.IOException
      • getRootGroups

        public java.util.Set<java.lang.String> getRootGroups()
                                                      throws java.io.IOException
        Description copied from interface: IndexingContext
        Gets root group names stored in the current indexing context
        Throws:
        java.io.IOException
      • setRootGroups

        public void setRootGroups​(java.util.Collection<java.lang.String> groups)
                           throws java.io.IOException
        Description copied from interface: IndexingContext
        Sets root group names stored in the current indexing context
        Throws:
        java.io.IOException
      • getGroups

        protected java.util.Set<java.lang.String> getGroups​(java.lang.String field,
                                                            java.lang.String filedValue,
                                                            java.lang.String listField)
                                                     throws java.io.IOException,
                                                            org.apache.lucene.index.CorruptIndexException
        Throws:
        java.io.IOException
        org.apache.lucene.index.CorruptIndexException
      • setGroups

        protected void setGroups​(java.util.Collection<java.lang.String> groups,
                                 java.lang.String groupField,
                                 java.lang.String groupFieldValue,
                                 java.lang.String groupListField)
                          throws java.io.IOException,
                                 org.apache.lucene.index.CorruptIndexException
        Throws:
        java.io.IOException
        org.apache.lucene.index.CorruptIndexException
      • createGroupsDocument

        protected org.apache.lucene.document.Document createGroupsDocument​(java.util.Collection<java.lang.String> groups,
                                                                           java.lang.String field,
                                                                           java.lang.String fieldValue,
                                                                           java.lang.String listField)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object