org.hibernate.search.store
Class DirectoryProviderHelper

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

public class DirectoryProviderHelper
extends java.lang.Object

Author:
Emmanuel Bernard, Sanne Grinovero

Field Summary
static java.lang.String COPYBUFFERSIZE_PROP_NAME
           
 
Constructor Summary
DirectoryProviderHelper()
           
 
Method Summary
static org.apache.lucene.store.FSDirectory createFSIndex(java.io.File indexDir, java.util.Properties dirConfiguration)
          Creates an FSDirectory in provided directory and initializes an index if not already existing.
static org.apache.lucene.store.LockFactory createLockFactory(java.io.File indexDir, java.util.Properties dirConfiguration)
          Creates a LockFactory as selected in the configuration for the DirectoryProvider.
static long getCopyBufferSize(java.lang.String directoryProviderName, java.util.Properties properties)
          Users may configure the number of MB to use as "chunk size" for large file copy operations performed by DirectoryProviders.
static java.io.File getSourceDirectory(java.lang.String directoryProviderName, java.util.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
static java.io.File getVerifiedIndexDir(java.lang.String annotatedIndexName, java.util.Properties properties, boolean verifyIsWritable)
          Verify the index directory exists and is writable, or creates it if not existing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYBUFFERSIZE_PROP_NAME

public static final java.lang.String COPYBUFFERSIZE_PROP_NAME
See Also:
Constant Field Values
Constructor Detail

DirectoryProviderHelper

public DirectoryProviderHelper()
Method Detail

getSourceDirectory

public static java.io.File getSourceDirectory(java.lang.String directoryProviderName,
                                              java.util.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 -
needWritePermissions - when true the directory will be tested for read-write permissions.
Returns:
The file representing the source directory

createFSIndex

public static org.apache.lucene.store.FSDirectory createFSIndex(java.io.File indexDir,
                                                                java.util.Properties dirConfiguration)
                                                         throws java.io.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
Returns:
the created FSDirectory
Throws:
java.io.IOException

createLockFactory

public static org.apache.lucene.store.LockFactory createLockFactory(java.io.File indexDir,
                                                                    java.util.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:
java.io.IOException

getVerifiedIndexDir

public static java.io.File getVerifiedIndexDir(java.lang.String annotatedIndexName,
                                               java.util.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(java.lang.String directoryProviderName,
                                     java.util.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 -
Returns:
the number of Bytes to use as "chunk size" in file copy operations.


Copyright © 2006-2010 Hibernate. All Rights Reserved.