Package fr.gouv.vitam.common.database.server.mongodb

# Class MongoDbAccess

java.lang.Object
fr.gouv.vitam.common.database.server.mongodb.MongoDbAccess

All Implemented Interfaces:
  `DatabaseConnection`

Direct Known Subclasses:
  `LogbookMongoDbAccessImpl`, `MongoDbAccessAdminImpl`, `MongoDbAccessMetadataImpl`, `SimpleMongoDBAccess`

public abstract class MongoDbAccess extends Object implements DatabaseConnection
MongoDbAccess interface

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MongoDbAccess(com.mongodb.client.MongoClient mongoClient, String dbname)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `checkConnection()`
  Check the connection of the database
  `void`
  `close()`
  Close database access
  `static com.mongodb.client.MongoClient`
  `createMongoClient(DbConfiguration configuration)`
  Create a mongoDB client according to the configuration and using the MongoClientOptions specific to the sub-systems (ex: metadata,logbook)
  `static com.mongodb.client.MongoClient`
  `createMongoClient(DbConfiguration configuration, List<Class<?>> classList)`
  `String`
  `getInfo()`
  Get information on a Database
  `com.mongodb.client.MongoDatabase`
  `getMongoAdmin()`
  `com.mongodb.client.MongoClient`
  `getMongoClient()`
  `static com.mongodb.MongoClientSettings.Builder`
  `getMongoClientSettingsBuilder(Class<?>... classes)`
  `static com.mongodb.MongoClientSettings.Builder`
  `getMongoClientSettingsBuilder(List<Class<?>> classList)`
  `com.mongodb.client.MongoDatabase`
  `getMongoDatabase()`
  `void`
  `setDatabase(String dbname)`
  Change the target database
  `MongoDbAccess`
  `setMongoAdmin(com.mongodb.client.MongoDatabase mongoAdmin)`
  `MongoDbAccess`
  `setMongoClient(com.mongodb.client.MongoClient mongoClient)`
  `MongoDbAccess`
  `setMongoDatabase(com.mongodb.client.MongoDatabase mongoDatabase)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### MongoDbAccess

    public MongoDbAccess(com.mongodb.client.MongoClient mongoClient, String dbname)
    Parameters:
      `mongoClient` - MongoClient
      `dbname` - MongoDB database name
    Throws:
      `IllegalArgumentException` - if mongoClient or dbname is null

- ## Method Details

  - ### checkConnection

    public boolean checkConnection()
    Description copied from interface: `DatabaseConnection`
    Check the connection of the database
    Specified by:
      `checkConnection` in interface `DatabaseConnection`
    Returns:
      True if the connection is active

  - ### getMongoClient

    public com.mongodb.client.MongoClient getMongoClient()
    Returns:
      MongoClient

  - ### setMongoClient

    public MongoDbAccess setMongoClient(com.mongodb.client.MongoClient mongoClient)
    Parameters:
      `mongoClient` - MongoClient
    Returns:
      MongoDbAccess

  - ### getMongoDatabase

    public com.mongodb.client.MongoDatabase getMongoDatabase()
    Returns:
      MongoDatabase

  - ### setMongoDatabase

    public MongoDbAccess setMongoDatabase(com.mongodb.client.MongoDatabase mongoDatabase)
    Parameters:
      `mongoDatabase` - MongoDatabase
    Returns:
      MongoDbAccess

  - ### getMongoAdmin

    public com.mongodb.client.MongoDatabase getMongoAdmin()
    Returns:
      MongoDatabase

  - ### setMongoAdmin

    public MongoDbAccess setMongoAdmin(com.mongodb.client.MongoDatabase mongoAdmin)
    Parameters:
      `mongoAdmin` - MongoDatabase
    Returns:
      MongoDbAccess

  - ### close

    public void close()
    Close database access

  - ### getInfo

    public String getInfo()
    Description copied from interface: `DatabaseConnection`
    Get information on a Database
    Specified by:
      `getInfo` in interface `DatabaseConnection`
    Returns:
      information on the database

  - ### createMongoClient

    public static com.mongodb.client.MongoClient createMongoClient(DbConfiguration configuration)
    Create a mongoDB client according to the configuration and using the MongoClientOptions specific to the sub-systems (ex: metadata,logbook)
    Parameters:
      `configuration` - the configuration of mongo client (host/port to connect)
    Returns:
      the MongoClient

  - ### createMongoClient

    public static com.mongodb.client.MongoClient createMongoClient(DbConfiguration configuration, List<Class<?>> classList)

  - ### getMongoClientSettingsBuilder

    public static com.mongodb.MongoClientSettings.Builder getMongoClientSettingsBuilder(Class<?>... classes)

  - ### getMongoClientSettingsBuilder

    public static com.mongodb.MongoClientSettings.Builder getMongoClientSettingsBuilder(List<Class<?>> classList)

  - ### setDatabase

    public void setDatabase(String dbname)
    Change the target database
    Parameters:
      `dbname` - Name of the target database