Class DirectoryProviderHelper

java.lang.Object
org.hibernate.search.store.DirectoryProviderHelper

public final class DirectoryProviderHelper extends Object
  • Method Details

    • getSourceDirectory

      public static File getSourceDirectory(String directoryProviderName, Properties properties, boolean needWritePermissions)
      Build a directory name out of a root and relative path, guessing the significant part and checking for the file availability
      Parameters:
      directoryProviderName -
      properties - the configuration properties
      needWritePermissions - when true the directory will be tested for read-write permissions.
      Returns:
      The file representing the source directory
    • createFSIndex

      public static FSDirectory createFSIndex(File indexDir, Properties properties) throws IOException
      Creates an FSDirectory in provided directory and initializes an index if not already existing.
      Parameters:
      indexDir - the directory where to write a new index
      properties - the configuration properties
      Returns:
      the created FSDirectory instance
      Throws:
      IOException - if an error
    • initializeIndexIfNeeded

      public static void initializeIndexIfNeeded(Directory directory)
      Initialize the Lucene Directory if it isn't already.
      Parameters:
      directory - the Directory to initialize
      Throws:
      SearchException - in case of lock acquisition timeouts, IOException, or if a corrupt index is found
    • createLockFactory

      public static LockFactory createLockFactory(File indexDir, Properties dirConfiguration)
      Creates a LockFactory as selected in the configuration for the DirectoryProvider. The SimpleFSLockFactory and NativeFSLockFactory need a File to know where to stock the filesystem based locks; other implementations ignore this parameter.
      Parameters:
      indexDir - the directory to use to store locks, if needed by implementation
      dirConfiguration - the configuration of current DirectoryProvider
      Returns:
      the LockFactory as configured, or a SimpleFSLockFactory in case of configuration errors or as a default.
      Throws:
      IOException
    • getVerifiedIndexDir

      public static File getVerifiedIndexDir(String annotatedIndexName, Properties properties, boolean verifyIsWritable)
      Verify the index directory exists and is writable, or creates it if not existing.
      Parameters:
      annotatedIndexName - The index name declared on the @Indexed annotation
      properties - The properties may override the indexname.
      verifyIsWritable - Verify the directory is writable
      Returns:
      the File representing the Index Directory
      Throws:
      SearchException
    • getCopyBufferSize

      public static long getCopyBufferSize(String directoryProviderName, Properties properties)
      Users may configure the number of MB to use as "chunk size" for large file copy operations performed by DirectoryProviders.
      Parameters:
      directoryProviderName -
      properties - the configuration properties
      Returns:
      the number of Bytes to use as "chunk size" in file copy operations.