public class MongoDBConnectionHelper extends Object
Modifier and Type | Method and Description |
---|---|
static com.mongodb.client.MongoDatabase |
getDatabase(com.mongodb.MongoClient mongoClient,
String dbname) |
protected static SSLContext |
getSSLContext(MongoDBConnectionConfig config) |
static boolean |
hasCollection(com.mongodb.client.MongoDatabase mongoDatabase,
String collection)
Check if the collection exists and if it is not empty
|
protected static KeyStore |
loadKeyStore(String path,
String password,
String type) |
static com.mongodb.MongoClient |
newMongoClient(MongoDBConnectionConfig config)
Initializes a connection to the MongoDB server.
|
static com.mongodb.MongoClient |
newMongoClient(String server)
Initialize a connection to the MongoDB server
|
public static com.mongodb.MongoClient newMongoClient(String server)
server
- the server urlpublic static com.mongodb.MongoClient newMongoClient(MongoDBConnectionConfig config)
config
- the MongoDB connection configprotected static SSLContext getSSLContext(MongoDBConnectionConfig config)
protected static KeyStore loadKeyStore(String path, String password, String type) throws GeneralSecurityException, IOException
GeneralSecurityException
IOException
public static com.mongodb.client.MongoDatabase getDatabase(com.mongodb.MongoClient mongoClient, String dbname)
public static boolean hasCollection(com.mongodb.client.MongoDatabase mongoDatabase, String collection)
mongoDatabase
- the Mongo databasecollection
- the collection nameCopyright © 2019 Nuxeo. All rights reserved.