org.ektorp.CouchDbInstance Java Examples

The following examples show how to use org.ektorp.CouchDbInstance. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudantInstanceCreatorTest.java    From bluemix-cloud-connectors with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreate() {
    final CloudantServiceInfo badUrlServiceInfo = new CloudantServiceInfo(
            "id",
            "username",
            "password",
            "hostname",
            443,
            "url"
    );
    assertNull(creator.create(badUrlServiceInfo, new ServiceConnectorConfig() {
    }));

    final CloudantServiceInfo serviceInfo = new CloudantServiceInfo(
            "testId",
            "username",
            "password",
            "username.cloudant.com",
            443,
            "https://username:[email protected]"
    );
    assertTrue(creator.create(serviceInfo, new ServiceConnectorConfig() {
    }) instanceof CouchDbInstance);
}
 
Example #2
Source File: ReplicationDAOImpl.java    From icure-backend with GNU General Public License v2.0 5 votes vote down vote up
@Autowired
  public ReplicationDAOImpl(@SuppressWarnings("SpringJavaAutowiringInspection") @Qualifier("couchdbConfig") CouchDbICureConnector couchdb, @Qualifier("couchdbInstance") CouchDbInstance couchdbInstance, IDGenerator idGenerator, @Qualifier("entitiesCacheManager") CacheManager cacheManager) {
      super(Replication.class, couchdb, idGenerator);

      this.couchdbInstance = couchdbInstance;

initStandardDesignDocument();
  }
 
Example #3
Source File: CouchdbStoreService.java    From open-Autoscaler with Apache License 2.0 5 votes vote down vote up
private CouchDbConnector initConnection() throws MalformedURLException, ProxyInitilizedFailedException {
	
   	String username = ConfigManager.get("couchdbUsername");
   	String password = ConfigManager.get("couchdbPassword");
   	String host = ConfigManager.get("couchdbHost");
   	int port = ConfigManager.getInt("couchdbPort");
   	int timeout = ConfigManager.getInt("couchdbTimeout");
   	boolean enableSSL =  ConfigManager.getBoolean("couchdbEnableSSL", false);
   	String dbName = ConfigManager.get("couchdbDBName");
   
	Builder builder = new StdHttpClient.Builder();
	builder = builder
			.host(host)
			.port(port)
			.connectionTimeout(timeout)
			.enableSSL(enableSSL);

	if (username != null && !username.isEmpty() && password != null && !password.isEmpty() ) {
    	builder = builder.username(username).password(password);
	}
	
	CouchDbInstance dbInstance = new StdCouchDbInstance(builder.build());

       if (!dbInstance.checkIfDbExists(dbName))
       	dbInstance.createDatabase(dbName);
       CouchDbConnector couchDB = dbInstance.createConnector(dbName, true);  
	
	return couchDB;
	
}
 
Example #4
Source File: CloudantInstanceCreator.java    From bluemix-cloud-connectors with Apache License 2.0 5 votes vote down vote up
@Override
public CouchDbInstance create(CloudantServiceInfo serviceInfo,
        ServiceConnectorConfig serviceConnectorConfig) {
    HttpClient httpClient;
    try {
        httpClient = new StdHttpClient.Builder()
                .url(serviceInfo.getUrl())
                .build();
        return new StdCouchDbInstance(httpClient);
    } catch (MalformedURLException e) {
        LOG.logp(Level.WARNING, CloudantInstanceCreator.class.getName(), "create", "Error parsing URL", e);
        return null;
    }
}
 
Example #5
Source File: StdCouchDbICureConnector.java    From icure-backend with GNU General Public License v2.0 4 votes vote down vote up
public StdCouchDbICureConnector(String databaseName, CouchDbInstance dbInstance) {
	super(databaseName, dbInstance);
}
 
Example #6
Source File: StdCouchDbICureConnector.java    From icure-backend with GNU General Public License v2.0 4 votes vote down vote up
public StdCouchDbICureConnector(String databaseName, CouchDbInstance dbi, ObjectMapperFactory om) {
	super(databaseName, dbi, om);
}
 
Example #7
Source File: ICureDAOImpl.java    From icure-backend with GNU General Public License v2.0 4 votes vote down vote up
@Autowired
public void setCouchdbInstance(CouchDbInstance couchdbInstance) {
	this.couchdbInstance = couchdbInstance;
}
 
Example #8
Source File: Config.java    From bluemix-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Bean
public CouchDbInstance couchDbInstance() {
    CouchDbInstance instance = connectionFactory().service(CouchDbInstance.class);
    return instance;
}
 
Example #9
Source File: App.java    From bluemix-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Bean
public CouchDbConnector couchDbConnector(CouchDbInstance couchDbInstance) {
    CouchDbConnector connector = new StdCouchDbConnector("status", couchDbInstance);
    connector.createDatabaseIfNotExists();
    return connector;
}
 
Example #10
Source File: CloudantBean.java    From bluemix-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Produces
public StatusRepository statusRepository() {
    CouchDbInstance db = cloud.getServiceConnector("connectors-sample", CouchDbInstance.class, null /* default config */);
    return new StatusRepository(new StdCouchDbConnector("status", db));
}
 
Example #11
Source File: Config.java    From bluemix-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Bean
public CouchDbInstance couchDbInstance() {
    CouchDbInstance instance = connectionFactory().service(CouchDbInstance.class);
    return instance;
}
 
Example #12
Source File: TestappApplication.java    From bluemix-cloud-connectors with Apache License 2.0 4 votes vote down vote up
@Bean
public CouchDbConnector couchDbConnector(CouchDbInstance couchDbInstance) {
    CouchDbConnector connector = new StdCouchDbConnector("status", couchDbInstance);
    connector.createDatabaseIfNotExists();
    return connector;
}