Package org.hibernate.search.exception

Examples of org.hibernate.search.exception.SearchException


    }
    try {
      filterDef.getImpl().newInstance();
    }
    catch (IllegalAccessException e) {
      throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
    }
    catch (InstantiationException e) {
      throw new SearchException( "Unable to create Filter class: " + filterDef.getImpl().getName(), e );
    }
    for ( Method method : filterDef.getImpl().getMethods() ) {
      if ( method.isAnnotationPresent( Factory.class ) ) {
        if ( filterDef.getFactoryMethod() != null ) {
          throw new SearchException(
              "Multiple @Factory methods found" + defAnn.name() + ": "
                  + filterDef.getImpl().getName() + "." + method.getName()
          );
        }
        ReflectionHelper.setAccessible( method );
        filterDef.setFactoryMethod( method );
      }
      if ( method.isAnnotationPresent( Key.class ) ) {
        if ( filterDef.getKeyMethod() != null ) {
          throw new SearchException(
              "Multiple @Key methods found" + defAnn.name() + ": "
                  + filterDef.getImpl().getName() + "." + method.getName()
          );
        }
        ReflectionHelper.setAccessible( method );
View Full Code Here


    FullTextFilterDef[] filterDefs = (FullTextFilterDef[]) defaults.get( FullTextFilterDefs.class );
    if ( filterDefs != null && filterDefs.length != 0 ) {
      final Map<String, FilterDef> filterDefinitions = factoryState.getFilterDefinitions();
      for ( FullTextFilterDef defAnn : filterDefs ) {
        if ( filterDefinitions.containsKey( defAnn.name() ) ) {
          throw new SearchException( "Multiple definition of @FullTextFilterDef.name=" + defAnn.name() );
        }
        bindFullTextFilterDef( defAnn );
      }
    }
  }
View Full Code Here

  }

  private static String defineIndexingStrategy(SearchConfiguration cfg) {
    String indexingStrategy = cfg.getProperties().getProperty( Environment.INDEXING_STRATEGY, "event" );
    if ( !( "event".equals( indexingStrategy ) || "manual".equals( indexingStrategy ) ) ) {
      throw new SearchException( Environment.INDEXING_STRATEGY + " unknown: " + indexingStrategy );
    }
    return indexingStrategy;
  }
View Full Code Here

    }
    if ( StringHelper.isEmpty( root ) ) {
      log.debug( "No root directory, go with relative " + relative );
      sourceDirectory = new File( relative );
      if ( !sourceDirectory.isDirectory() ) { // this also tests for existence
        throw new SearchException( "Unable to read source directory: " + relative );
      }
      //else keep source as it
    }
    else {
      File rootDir = new File( root );
View Full Code Here

          log.lockingFailureDuringInitialization( directory.toString() );
        }
      }
    }
    catch (IOException e) {
      throw new SearchException( "Could not initialize index", e );
    }
    finally {
      analyzer.close();
    }
  }
View Full Code Here

    //For FS-based indexes default to "native", default to "single" otherwise.
    String defaultStrategy = indexDir == null ? "single" : "native";
    String lockFactoryName = dirConfiguration.getProperty( LOCKING_STRATEGY_PROP_NAME, defaultStrategy );
    if ( "simple".equals( lockFactoryName ) ) {
      if ( indexDir == null ) {
        throw new SearchException( "To use \"simple\" as a LockFactory strategy an indexBase path must be set" );
      }
      return new SimpleFSLockFactory( indexDir );
    }
    else if ( "native".equals( lockFactoryName ) ) {
      if ( indexDir == null ) {
        throw new SearchException( "To use \"native\" as a LockFactory strategy an indexBase path must be set" );
      }
      return new NativeFSLockFactory( indexDir );
    }
    else if ( "single".equals( lockFactoryName ) ) {
      return new SingleInstanceLockFactory();
View Full Code Here

  private static void makeSanityCheckedDirectory(File directory, String indexName, boolean verifyIsWritable) {
    if ( !directory.exists() ) {
      log.indexDirectoryNotFoundCreatingNewOne( directory.getAbsolutePath() );
      //if not existing, create the full path
      if ( !directory.mkdirs() ) {
        throw new SearchException(
            "Unable to create index directory: "
                + directory.getAbsolutePath() + " for index "
                + indexName
        );
      }
    }
    else {
      // else check it is not a file
      if ( !directory.isDirectory() ) {
        throw new SearchException(
            "Unable to initialize index: "
                + indexName + ": "
                + directory.getAbsolutePath() + " is a file."
        );
      }
    }
    // and ensure it's writable
    if ( verifyIsWritable && ( !directory.canWrite() ) ) {
      throw new SearchException(
          "Cannot write into index directory: "
              + directory.getAbsolutePath() + " for index "
              + indexName
      );
    }
View Full Code Here

   */
  static long getRetryInitializePeriod(Properties properties, String directoryProviderName) {
    int retry_period_seconds = ConfigurationParseHelper.getIntValue( properties, RETRY_INITIALIZE_PROP_NAME, 0 );
    log.debugf( "Retry initialize period for Directory %s: %d seconds", directoryProviderName, retry_period_seconds );
    if ( retry_period_seconds < 0 ) {
      throw new SearchException( RETRY_INITIALIZE_PROP_NAME + " for Directory " + directoryProviderName + " must be a positive integer" );
    }
    return retry_period_seconds * 1000; //convert into milliseconds
  }
View Full Code Here

    long period;
    try {
      period = Long.parseLong( refreshPeriod );
    }
    catch (NumberFormatException nfe) {
      throw new SearchException(
          "Unable to initialize index: " + directoryProviderName + "; refresh period is not numeric.", nfe
      );
    }
    log.debugf( "Refresh period: %d seconds", period );
    return period * 1000; //per second
View Full Code Here

    if ( value != null ) {
      try {
        size = Long.parseLong( value ) * 1024 * 1024; //from MB to B.
      }
      catch (NumberFormatException nfe) {
        throw new SearchException(
            "Unable to initialize index " +
                indexName + "; " + COPY_BUFFER_SIZE_PROP_NAME + " is not numeric.", nfe
        );
      }
      if ( size <= 0 ) {
        throw new SearchException(
            "Unable to initialize index " +
                indexName + "; " + COPY_BUFFER_SIZE_PROP_NAME + " needs to be greater than zero."
        );
      }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.search.exception.SearchException

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.