Codota Logo
MongoDBConnectionHelper
Code IndexAdd Codota to your IDE (free)

How to use
MongoDBConnectionHelper
in
org.nuxeo.runtime.mongodb

Best Java code snippets using org.nuxeo.runtime.mongodb.MongoDBConnectionHelper (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
List l =
  • Codota Iconnew LinkedList()
  • Codota IconCollections.emptyList()
  • Codota Iconnew ArrayList()
  • Smart code suggestions by Codota
}
origin: org.nuxeo.runtime/nuxeo-runtime-mongodb

/**
 * Initialize a connection to the MongoDB server
 *
 * @param server the server url
 * @return the MongoDB client
 */
public static MongoClient newMongoClient(String server) {
  MongoDBConnectionConfig config = new MongoDBConnectionConfig();
  config.server = server;
  return newMongoClient(config);
}
origin: org.nuxeo.runtime/nuxeo-runtime-mongodb

/**
 * @return all configured databases
 */
@Override
public Iterable<MongoDatabase> getDatabases() {
  return () -> clients.entrySet().stream().map(e -> {
    MongoDBConnectionConfig c = getDescriptor(XP_CONNECTION, e.getKey());
    return MongoDBConnectionHelper.getDatabase(e.getValue(), c.dbname);
  }).iterator();
}
origin: org.nuxeo.ecm.platform/nuxeo-platform-directory-mongodb

/**
 * Checks if the MongoDB server has the collection.
 *
 * @param collection the collection name
 * @return true if the server has the collection, false otherwise
 */
protected boolean hasCollection(String collection) {
  return MongoDBConnectionHelper.hasCollection(database, collection);
}
origin: org.nuxeo.runtime/nuxeo-runtime-mongodb

protected static SSLContext getSSLContext(MongoDBConnectionConfig config) {
  try {
    KeyStore trustStore = loadKeyStore(config.trustStorePath, config.trustStorePassword, config.trustStoreType);
    KeyStore keyStore = loadKeyStore(config.keyStorePath, config.keyStorePassword, config.keyStoreType);
    if (trustStore == null && keyStore == null) {
      return null;
    }
    SSLContextBuilder sslContextBuilder = SSLContexts.custom();
    if (trustStore != null) {
      sslContextBuilder.loadTrustMaterial(trustStore, null);
    }
    if (keyStore != null) {
      sslContextBuilder.loadKeyMaterial(keyStore, null);
    }
    return sslContextBuilder.build();
  } catch (GeneralSecurityException | IOException e) {
    throw new RuntimeException("Cannot setup SSL context: " + config, e);
  }
}
origin: org.nuxeo.runtime/nuxeo-runtime-mongodb

     .socketTimeout(MONGODB_OPTION_SOCKET_TIMEOUT_MS)
     .description("Nuxeo");
SSLContext sslContext = getSSLContext(config);
if (sslContext == null) {
  if (config.ssl != null) {
origin: org.nuxeo.runtime/nuxeo-runtime-mongodb

@Override
public void start(ComponentContext context) {
  super.start(context);
  Collection<MongoDBConnectionConfig> confs = getDescriptors(XP_CONNECTION);
  confs.forEach(c -> {
    log.debug("Initializing MongoClient with id={}", c::getId);
    clients.put(c.getId(), MongoDBConnectionHelper.newMongoClient(c));
  });
}
origin: org.nuxeo.runtime/nuxeo-runtime-mongodb

/**
 * @param id the connection id to retrieve.
 * @return the database configured by {@link MongoDBConnectionConfig} for the input id, or the default one if it
 *         doesn't exist
 */
@Override
public MongoDatabase getDatabase(String id) {
  MongoDBConnectionConfig config = getDescriptor(XP_CONNECTION, id);
  MongoClient client = clients.get(id);
  if (client == null) {
    config = getDescriptor(XP_CONNECTION, DEFAULT_CONNECTION_ID);
    client = clients.get(DEFAULT_CONNECTION_ID);
  }
  return MongoDBConnectionHelper.getDatabase(client, config.dbname);
}
origin: org.nuxeo.ecm.core/nuxeo-core-test

protected void initMongoDB() {
  String mongoDBServer = defaultProperty(MONGODB_SERVER_PROPERTY, DEFAULT_MONGODB_SERVER);
  String mongoDBDbName = defaultProperty(MONGODB_DBNAME_PROPERTY, DEFAULT_MONGODB_DBNAME);
  try (MongoClient mongoClient = MongoDBConnectionHelper.newMongoClient(mongoDBServer)) {
    MongoDatabase database = mongoClient.getDatabase(mongoDBDbName);
    database.drop();
  }
}
org.nuxeo.runtime.mongodbMongoDBConnectionHelper

Javadoc

Helper for connection to the MongoDB server

Most used methods

  • newMongoClient
    Initializes a connection to the MongoDB server.
  • getDatabase
  • getSSLContext
  • hasCollection
    Check if the collection exists and if it is not empty
  • loadKeyStore

Popular in Java

  • Making http post requests using okhttp
  • putExtra (Intent)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • findViewById (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now