use of com.couchbase.client.java.document.RawJsonDocument in project cas by apereo.
the class CouchbaseServiceRegistryDao method findServiceById.
@Override
public RegisteredService findServiceById(final long id) {
try {
LOGGER.debug("Lookup for service [{}]", id);
final RawJsonDocument document = this.couchbase.bucket().get(String.valueOf(id), RawJsonDocument.class);
if (document != null) {
final String json = document.content();
final StringReader stringReader = new StringReader(json);
return this.registeredServiceJsonSerializer.from(stringReader);
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}
use of com.couchbase.client.java.document.RawJsonDocument in project cas by apereo.
the class CouchbaseServiceRegistryDao method load.
@Override
public List<RegisteredService> load() {
try {
LOGGER.debug("Loading services");
final ViewResult allKeys = executeViewQueryForAllServices();
final List<RegisteredService> services = new LinkedList<>();
for (final ViewRow row : allKeys) {
final RawJsonDocument document = row.document(RawJsonDocument.class);
if (document != null) {
final String json = document.content();
LOGGER.debug("Found service: [{}]", json);
final StringReader stringReader = new StringReader(json);
services.add(this.registeredServiceJsonSerializer.from(stringReader));
}
}
return services;
} catch (final RuntimeException e) {
LOGGER.error(e.getMessage(), e);
return new LinkedList<>();
}
}
use of com.couchbase.client.java.document.RawJsonDocument in project YCSB by brianfrankcooper.
the class BackoffSelectStrategy method readKv.
/**
* Performs the {@link #read(String, String, Set, HashMap)} operation via Key/Value ("get").
*
* @param docId the document ID
* @param fields the fields to be loaded
* @param result the result map where the doc needs to be converted into
* @return The result of the operation.
*/
private Status readKv(final String docId, final Set<String> fields, final HashMap<String, ByteIterator> result) throws Exception {
RawJsonDocument loaded = bucket.get(docId, RawJsonDocument.class);
if (loaded == null) {
return Status.NOT_FOUND;
}
decode(loaded.content(), fields, result);
return Status.OK;
}
Aggregations