/** * @deprecated Use {@link #AbstractMongoRepository(MongoProperties)} instead. */ @Deprecated public AbstractMongoRepository() { mongoProperties = new MongoProperties(); mongoProperties.setDefaultReadTimeout(2000); mongoProperties.setDefaultWriteTimeout(2000); }
private static String getAuthenticationDb(final MongoProperties mongoProperties) { final String authenticationDb = mongoProperties.getAuthenticationDb(); if (authenticationDb != null && !authenticationDb.isEmpty()) { return authenticationDb; } return mongoProperties.getDb(); }
private static MongoCredential getMongoCredentials(final MongoProperties mongoProperties) { if (useUnauthorizedConnection(mongoProperties)) { return null; } return createCredential( mongoProperties.getUser(), getAuthenticationDb(mongoProperties), mongoProperties.getPassword().toCharArray() ); }
/** * Deletes the document identified by key. * * @param key the identifier of the deleted document */ public void delete(final K key) { delete(key, mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }
/** * Find a single value with the specified key, if existing. * * @param key the key to search for * @return an Optional containing the requested value, or {@code Optional.empty()} if no value with this key exists */ public Optional<V> findOne(final K key) { return findOne(key, mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS); }
public TestRepository(final MongoDatabase mongoDatabase) { super(new MongoProperties()); this.collection = mongoDatabase.getCollection("test"); }
public MongoClientOptions toMongoClientOptions(final CodecRegistry codecRegistry) { return getMongoClientOptionsBuilder(codecRegistry) .build(); }
private static List<MongoCredential> getMongoCredentials(final MongoProperties mongoProperties) { if (useUnauthorizedConnection(mongoProperties)) { return Collections.emptyList(); } return singletonList(createCredential(mongoProperties.getUser(), getAuthenticationDb(mongoProperties), mongoProperties.getPassword().toCharArray())); }
/** * Updates the document if it is already present in the repository. * * @param value the new value * @return true, if the document was updated, false otherwise. */ public boolean update(final V value) { return update(value, mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }
/** * Find a single value with the specified key, if existing. * * @param key the key to search for * @return an Optional containing the requested value, or {@code Optional.empty()} if no value with this key exists */ public Optional<V> findOne(final K key) { return findOne(key, mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS); }
private static String getAuthenticationDb(final MongoProperties mongoProperties) { final String authenticationDb = mongoProperties.getAuthenticationDb(); if (authenticationDb != null && !authenticationDb.isEmpty()) { return authenticationDb; } return mongoProperties.getDb(); }
public MongoClientOptions toMongoClientOptionsWithHighTimeout(final CodecRegistry codecRegistry) { return getMongoClientOptionsBuilder(codecRegistry) .socketTimeout(socketTimeoutForHighTimeoutClient) .build(); }
/** * Updates the document if it is already present in the repository. * * @param value the new value * @return true, if the document was updated, false otherwise. */ public boolean update(final V value) { return update(value, mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }
public Stream<V> findAllAsStream(final int skip, final int limit) { return findAllAsStream(skip, limit, mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS); }
/** * Deletes all documents from this repository. */ public void deleteAll() { deleteAll(mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }
public Stream<V> findAllAsStream() { return findAllAsStream(mongoProperties.getDefaultReadTimeout(), TimeUnit.MILLISECONDS); }
/** * Deletes the document identified by key. * * @param key the identifier of the deleted document */ public void delete(final K key) { delete(key, mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }
/** * Deletes all documents from this repository. */ public void deleteAll() { deleteAll(mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }
public V createOrUpdate(final V value) { return createOrUpdate(value, mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }
public V create(final V value) { return create(value, mongoProperties.getDefaultWriteTimeout(), TimeUnit.MILLISECONDS); }