Class MongoNodeRepositoryImpl

java.lang.Object
org.saidone.component.BaseComponent
org.saidone.repository.MongoNodeRepositoryImpl
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.data.mongodb.repository.MongoRepository<NodeWrapper,String>, org.springframework.data.repository.CrudRepository<NodeWrapper,String>, org.springframework.data.repository.ListCrudRepository<NodeWrapper,String>, org.springframework.data.repository.ListPagingAndSortingRepository<NodeWrapper,String>, org.springframework.data.repository.PagingAndSortingRepository<NodeWrapper,String>, org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>, org.springframework.data.repository.Repository<NodeWrapper,String>
Direct Known Subclasses:
EncryptedMongoNodeRepositoryImpl

@Repository @ConditionalOnProperty(name="application.service.vault.encryption.enabled", havingValue="false", matchIfMissing=true) public class MongoNodeRepositoryImpl extends BaseComponent implements org.springframework.data.mongodb.repository.MongoRepository<NodeWrapper,String>
Repository implementation for managing NodeWrapper entities in MongoDB.

Implements the MongoRepository interface using MongoOperations to perform database operations.

Activation of this repository is controlled by the application.service.vault.encryption.enabled property: the bean is instantiated when the value is false or the property is missing.

Provides CRUD operations including insertion, saving, batch operations, and queries by Example, Sort or Pageable. It also supports counting and removal of entities.

The findBy(Example, Function) method is not implemented and always throws an UnsupportedOperationException.

This class extends BaseComponent and is intended for scenarios where node encryption is disabled at the application level. It relies on MongoOperations for thread-safe persistence of NodeWrapper documents.

  • Constructor Details

    • MongoNodeRepositoryImpl

      public MongoNodeRepositoryImpl()
  • Method Details

    • init

      @PostConstruct public void init()
      Called after dependency injection is complete. Logs a startup message indicating that the component is ready.

      The method verifies that the MongoDB connection is available at start-up. If the connection cannot be established the application is shut down to avoid running in an inconsistent state.

      Overrides:
      init in class BaseComponent
    • insert

      @NonNull public <S extends NodeWrapper> S insert(@NonNull S entity)
      Specified by:
      insert in interface org.springframework.data.mongodb.repository.MongoRepository<NodeWrapper,String>
    • insert

      @NonNull public <S extends NodeWrapper> @NonNull List<S> insert(@NonNull @NonNull Iterable<S> entities)
      Specified by:
      insert in interface org.springframework.data.mongodb.repository.MongoRepository<NodeWrapper,String>
    • save

      @NonNull public <S extends NodeWrapper> S save(@NonNull S entity)
      Specified by:
      save in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • saveAll

      @NonNull public <S extends NodeWrapper> @NonNull List<S> saveAll(@NonNull @NonNull Iterable<S> entities)
      Specified by:
      saveAll in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
      Specified by:
      saveAll in interface org.springframework.data.repository.ListCrudRepository<NodeWrapper,String>
    • findOne

      @NonNull public <S extends NodeWrapper> @NonNull Optional<S> findOne(@NonNull @NonNull org.springframework.data.domain.Example<S> example)
      Specified by:
      findOne in interface org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>
    • findAll

      @NonNull public <S extends NodeWrapper> @NonNull List<S> findAll(@NonNull @NonNull org.springframework.data.domain.Example<S> example)
      Specified by:
      findAll in interface org.springframework.data.mongodb.repository.MongoRepository<NodeWrapper,String>
      Specified by:
      findAll in interface org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>
    • findAll

      @NonNull public <S extends NodeWrapper> @NonNull List<S> findAll(@NonNull @NonNull org.springframework.data.domain.Example<S> example, @NonNull @NonNull org.springframework.data.domain.Sort sort)
      Specified by:
      findAll in interface org.springframework.data.mongodb.repository.MongoRepository<NodeWrapper,String>
      Specified by:
      findAll in interface org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>
    • findAll

      @NonNull public <S extends NodeWrapper> @NonNull org.springframework.data.domain.Page<S> findAll(@NonNull @NonNull org.springframework.data.domain.Example<S> example, @NonNull @NonNull org.springframework.data.domain.Pageable pageable)
      Specified by:
      findAll in interface org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>
    • findBy

      @NonNull public <S extends NodeWrapper, R> R findBy(@NonNull @NonNull org.springframework.data.domain.Example<S> example, @NonNull @NonNull Function<org.springframework.data.repository.query.FluentQuery.FetchableFluentQuery<S>,R> queryFunction)
      Specified by:
      findBy in interface org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>
      Throws:
      UnsupportedOperationException - always thrown as this method is not implemented
    • findById

      @NonNull public @NonNull Optional<NodeWrapper> findById(@NonNull @NonNull String id)
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • existsById

      public boolean existsById(@NonNull @NonNull String id)
      Specified by:
      existsById in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • findAll

      @NonNull public @NonNull List<NodeWrapper> findAll()
      Specified by:
      findAll in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
      Specified by:
      findAll in interface org.springframework.data.repository.ListCrudRepository<NodeWrapper,String>
    • findByArchiveDateRange

      public org.springframework.data.domain.Page<NodeWrapper> findByArchiveDateRange(Instant from, Instant to, org.springframework.data.domain.Pageable pageable)
      Retrieves node wrappers archived within the specified date range using pagination.

      When both from and to are null, this method delegates to findAll(Pageable).

      If the supplied Pageable does not define a sort order, results are ordered by archive date in ascending order.

      Parameters:
      from - lower bound of the archive date range, inclusive. null for no lower bound.
      to - upper bound of the archive date range, inclusive. null for no upper bound.
      pageable - pagination information
      Returns:
      page of matching nodes
    • findByNtx

      public List<NodeWrapper> findByNtx(String ntx)
      Retrieves node wrappers by notarization transaction ID. A null value matches nodes without a transaction ID.
      Parameters:
      ntx - the transaction ID to filter by
      Returns:
      list of matching nodes
    • findByKv

      public List<NodeWrapper> findByKv(int kv)
      Retrieves node wrappers by encryption key version.
      Parameters:
      kv - the encryption key version to filter by
      Returns:
      list of nodes encrypted with the specified key version
    • findAllById

      @NonNull public @NonNull List<NodeWrapper> findAllById(@NonNull @NonNull Iterable<String> ids)
      Specified by:
      findAllById in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
      Specified by:
      findAllById in interface org.springframework.data.repository.ListCrudRepository<NodeWrapper,String>
    • count

      public long count()
      Specified by:
      count in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • deleteById

      public void deleteById(@NonNull @NonNull String id)
      Specified by:
      deleteById in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • delete

      public void delete(@NonNull @NonNull NodeWrapper entity)
      Specified by:
      delete in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • deleteAllById

      public void deleteAllById(@NonNull @NonNull Iterable<? extends String> ids)
      Specified by:
      deleteAllById in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • deleteAll

      public void deleteAll(@NonNull @NonNull Iterable<? extends NodeWrapper> entities)
      Specified by:
      deleteAll in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • deleteAll

      public void deleteAll()
      Specified by:
      deleteAll in interface org.springframework.data.repository.CrudRepository<NodeWrapper,String>
    • findAll

      @NonNull public @NonNull List<NodeWrapper> findAll(@NonNull @NonNull org.springframework.data.domain.Sort sort)
      Specified by:
      findAll in interface org.springframework.data.repository.ListPagingAndSortingRepository<NodeWrapper,String>
      Specified by:
      findAll in interface org.springframework.data.repository.PagingAndSortingRepository<NodeWrapper,String>
    • findAll

      @NonNull public @NonNull org.springframework.data.domain.Page<NodeWrapper> findAll(@NonNull @NonNull org.springframework.data.domain.Pageable pageable)
      Specified by:
      findAll in interface org.springframework.data.repository.PagingAndSortingRepository<NodeWrapper,String>
    • count

      public <S extends NodeWrapper> long count(@NonNull @NonNull org.springframework.data.domain.Example<S> example)
      Specified by:
      count in interface org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>
    • exists

      public <S extends NodeWrapper> boolean exists(@NonNull @NonNull org.springframework.data.domain.Example<S> example)
      Specified by:
      exists in interface org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>