Fixed method

This commit is contained in:
Luca Frosini 2021-03-22 12:00:41 +01:00
parent 2a876e02fa
commit ba75a7787a
2 changed files with 7 additions and 4 deletions

View File

@ -45,6 +45,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
import org.gcube.documentstore.records.AggregatedRecord;
import org.gcube.documentstore.records.Record;
import org.gcube.documentstore.records.RecordUtility;
import org.json.JSONArray;
import org.json.JSONException;
@ -1510,12 +1511,13 @@ public class AccountingPersistenceQueryCouchBase implements AccountingPersistenc
}
@Override
public String getRecord(String recordId, String recordType) throws Exception {
public Record getRecord(String recordId, String recordType) throws Exception {
try {
Bucket bucket = getBucket(recordType);
JsonDocument recordJson = bucket.get(recordId);
return recordJson.content().toString();
String recordJsonString = recordJson.content().toString();
return RecordUtility.getRecord(recordJsonString);
} catch(Exception e) {
return null;
}

View File

@ -24,6 +24,7 @@ import org.gcube.accounting.datamodel.aggregation.AggregatedStorageStatusRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedStorageUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.documentstore.records.Record;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Before;
@ -523,8 +524,8 @@ public class AccountingPersistenceQueryCouchBaseTest extends ScopedTest {
String recordId = "91e1c339-d811-45d7-a13f-7385af59e3c8";
String type = "service";
String document = accountingPersistenceQueryCouchBase.getRecord(recordId, type);
logger.debug("document:{}", document);
Record record = accountingPersistenceQueryCouchBase.getRecord(recordId, type);
logger.debug("document:{}", record);
}