Fixed method

master
Luca Frosini 3 years ago
parent 2a876e02fa
commit ba75a7787a

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

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