use of io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider in project jans by JanssenProject.
the class CouchbaseEntryManagerFactory method createEntryManager.
@Override
public CouchbaseEntryManager createEntryManager(Properties conf) {
Properties entryManagerConf = PropertiesHelper.filterProperties(conf, "#");
// Allow proper initialization
if (this.couchbaseConnectionProperties == null) {
this.couchbaseConnectionProperties = entryManagerConf;
}
init();
if (!isInitialized()) {
throw new ConfigurationException("Failed to create Couchbase environment!");
}
CouchbaseConnectionProvider connectionProvider = new CouchbaseConnectionProvider(entryManagerConf, couchbaseEnvironment);
connectionProvider.create();
if (!connectionProvider.isCreated()) {
throw new ConfigurationException(String.format("Failed to create Couchbase connection pool! Result code: '%s'", connectionProvider.getCreationResultCode()));
}
LOG.debug("Created connectionProvider '{}' with code '{}'", connectionProvider, connectionProvider.getCreationResultCode());
CouchbaseEntryManager couchbaseEntryManager = new CouchbaseEntryManager(new CouchbaseOperationServiceImpl(entryManagerConf, connectionProvider));
LOG.info("Created CouchbaseEntryManager: {}", couchbaseEntryManager.getOperationService());
return couchbaseEntryManager;
}
use of io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider in project jans by JanssenProject.
the class CouchbaseConfigurationResource method test.
@POST
@Path(ApiConstants.TEST)
@ProtectedApi(scopes = { ApiAccessConstants.DATABASE_COUCHBASE_READ_ACCESS })
public Response test(@Valid @NotNull CouchbaseConnectionConfiguration conf) {
log.debug("COUCHBASE to be tested - conf = " + conf);
Properties properties = new Properties();
properties.put("couchbase.servers", Joiner.on(",").join(conf.getServers()));
properties.put("couchbase.auth.userName", conf.getUserName());
properties.put("couchbase.auth.userPassword", conf.getUserPassword());
properties.put("couchbase.auth.buckets", Joiner.on(",").join(conf.getBuckets()));
properties.put("couchbase.bucket.default", conf.getDefaultBucket());
properties.put("couchbase.password.encryption.method", conf.getPasswordEncryptionMethod());
CouchbaseConnectionProvider connectionProvider = new CouchbaseConnectionProvider(properties, DefaultCouchbaseEnvironment.create());
return Response.ok(connectionProvider.isConnected()).build();
}
Aggregations