Search in sources :

Example 1 with CouchbaseConnectionProvider

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;
}
Also used : ConfigurationException(io.jans.orm.exception.operation.ConfigurationException) CouchbaseConnectionProvider(io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider) Properties(java.util.Properties) CouchbaseOperationServiceImpl(io.jans.orm.couchbase.operation.impl.CouchbaseOperationServiceImpl)

Example 2 with CouchbaseConnectionProvider

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();
}
Also used : CouchbaseConnectionProvider(io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider) Properties(java.util.Properties) ProtectedApi(io.jans.configapi.core.rest.ProtectedApi)

Aggregations

CouchbaseConnectionProvider (io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider)2 Properties (java.util.Properties)2 ProtectedApi (io.jans.configapi.core.rest.ProtectedApi)1 CouchbaseOperationServiceImpl (io.jans.orm.couchbase.operation.impl.CouchbaseOperationServiceImpl)1 ConfigurationException (io.jans.orm.exception.operation.ConfigurationException)1