private IndexingContext getIndexingContext() throws ConsumerException {

    if (this.indexingContext == null) {
      try {
        indexingContext = managedRepositoryAdmin.createIndexContext(repository);
      } catch (RepositoryAdminException e) {
        throw new ConsumerException(e.getMessage(), e);
      }
    }
    return indexingContext;
  }
  @Override
  public void beginScan(ManagedRepository repository, Date whenGathered) throws ConsumerException {
    this.repository = repository;
    managedRepository = new File(repository.getLocation());

    try {
      log.info("Creating indexing context for repo : {}", repository.getId());
      indexingContext = managedRepositoryAdmin.createIndexContext(repository);
    } catch (RepositoryAdminException e) {
      throw new ConsumerException(e.getMessage(), e);
    }
  }