Package org.hibernate.search.exception

Examples of org.hibernate.search.exception.SearchException


  }

  private String objectIdInString(Class<?> entityClass, Serializable id, ConversionContext conversionContext) {
    EntityIndexBinding indexBindingForEntity = searchFactory.getIndexBinding( entityClass );
    if ( indexBindingForEntity == null ) {
      throw new SearchException( "Unable to find entity type metadata while deserializing: " + entityClass );
    }
    DocumentBuilderIndexedEntity documentBuilder = indexBindingForEntity.getDocumentBuilder();
    return documentBuilder.objectToString( documentBuilder.getIdKeywordName(), id, conversionContext );
  }
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

        IndexWriter iw = new IndexWriter( directory, iwriterConfig );
        iw.close();
      }
    }
    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

        member,
        reflectionManager,
        configContext.getServiceManager()
    );
    if ( !( idBridge instanceof TwoWayFieldBridge ) ) {
      throw new SearchException(
          "Bridge for document id does not implement TwoWayFieldBridge: " + member.getName()
      );
    }

    Field.TermVector termVector = AnnotationProcessingHelper.getTermVector( TermVector.NO );
View Full Code Here

        Class<? extends Annotation> jpaIdClass =
            ClassLoaderHelper.classForName( "javax.persistence.Id", configContext.getServiceManager() );
        jpaId = member.getAnnotation( jpaIdClass );
      }
      catch (ClassLoadingException e) {
        throw new SearchException( "Unable to load @Id.class even though it should be present ?!" );
      }
      if ( jpaId != null ) {
        typeMetadataBuilder.jpaProperty( member );
        if ( documentIdAnnotation == null ) {
          log.debug( "Found JPA id and using it as document id" );
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.