Fixing internals
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/document-store-lib-couchbase@122617 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7f31514eab
commit
f9f9f69910
2
pom.xml
2
pom.xml
|
@ -37,7 +37,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.couchbase.client</groupId>
|
<groupId>com.couchbase.client</groupId>
|
||||||
<artifactId>java-client</artifactId>
|
<artifactId>java-client</artifactId>
|
||||||
<version>2.2.2</version>
|
<version>2.2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Test Dependency -->
|
<!-- Test Dependency -->
|
||||||
|
|
|
@ -18,6 +18,8 @@ import com.couchbase.client.java.Cluster;
|
||||||
import com.couchbase.client.java.CouchbaseCluster;
|
import com.couchbase.client.java.CouchbaseCluster;
|
||||||
import com.couchbase.client.java.document.JsonDocument;
|
import com.couchbase.client.java.document.JsonDocument;
|
||||||
import com.couchbase.client.java.document.json.JsonObject;
|
import com.couchbase.client.java.document.json.JsonObject;
|
||||||
|
import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||||
|
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||||
|
@ -30,13 +32,12 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
||||||
public static final String PASSWORD_PROPERTY_KEY = "password";
|
public static final String PASSWORD_PROPERTY_KEY = "password";
|
||||||
public static final String BUCKET_NAME_PROPERTY_KEY = "bucketName";
|
public static final String BUCKET_NAME_PROPERTY_KEY = "bucketName";
|
||||||
|
|
||||||
/* The environment configuration
|
/* The environment configuration */
|
||||||
protected static final CouchbaseEnvironment ENV =
|
protected static final CouchbaseEnvironment ENV =
|
||||||
DefaultCouchbaseEnvironment.builder()
|
DefaultCouchbaseEnvironment.builder()
|
||||||
.connectTimeout(8 * 1000) // 8 Seconds in milliseconds
|
.connectTimeout(8 * 1000) // 8 Seconds in milliseconds
|
||||||
.keepAliveInterval(3600 * 1000) // 3600 Seconds in milliseconds
|
.keepAliveInterval(3600 * 1000) // 3600 Seconds in milliseconds
|
||||||
.build();
|
.build();
|
||||||
*/
|
|
||||||
|
|
||||||
protected Cluster cluster;
|
protected Cluster cluster;
|
||||||
protected Bucket bucket;
|
protected Bucket bucket;
|
||||||
|
@ -50,8 +51,9 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
||||||
//String username = configuration.getProperty(USERNAME_PROPERTY_KEY);
|
//String username = configuration.getProperty(USERNAME_PROPERTY_KEY);
|
||||||
String password = configuration.getProperty(PASSWORD_PROPERTY_KEY);
|
String password = configuration.getProperty(PASSWORD_PROPERTY_KEY);
|
||||||
|
|
||||||
cluster = CouchbaseCluster.create(url);
|
cluster = CouchbaseCluster.create(ENV, url);
|
||||||
bucket = cluster.openBucket(configuration.getProperty(BUCKET_NAME_PROPERTY_KEY), password);
|
bucket = cluster.openBucket(
|
||||||
|
configuration.getProperty(BUCKET_NAME_PROPERTY_KEY), password);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JsonDocument createItem(JsonObject jsonObject, String id) throws Exception {
|
protected JsonDocument createItem(JsonObject jsonObject, String id) throws Exception {
|
||||||
|
@ -68,7 +70,7 @@ public class PersistenceCouchBase extends PersistenceBackend {
|
||||||
public static Record jsonNodeToUsageRecord(JsonNode jsonNode) throws Exception {
|
public static Record jsonNodeToUsageRecord(JsonNode jsonNode) throws Exception {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Comparable<? extends Serializable>> result = mapper.convertValue(jsonNode, Map.class);
|
Map<String, ? extends Serializable> result = mapper.convertValue(jsonNode, Map.class);
|
||||||
Record record = RecordUtility.getRecord(result);
|
Record record = RecordUtility.getRecord(result);
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue