Switching to gcube-jackson

This commit is contained in:
Luca Frosini 2020-07-10 18:30:52 +02:00
parent 83820adbcf
commit 5bc7453225
26 changed files with 50 additions and 57 deletions

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-lib</artifactId> <artifactId>accounting-lib</artifactId>
<version>3.6.0-SNAPSHOT</version> <version>4.0.0-SNAPSHOT</version>
<name>Accounting Library</name> <name>Accounting Library</name>
<description>Accounting Library</description> <description>Accounting Library</description>
@ -30,7 +30,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId> <artifactId>gcube-bom</artifactId>
<version>1.4.0</version> <version>2.0.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -59,8 +59,8 @@
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>org.gcube.common</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>gcube-jackson-databind</artifactId>
</dependency> </dependency>
<!-- Test Dependencies --> <!-- Test Dependencies -->
<dependency> <dependency>

View File

@ -10,14 +10,13 @@ import java.util.concurrent.TimeUnit;
import org.gcube.accounting.datamodel.validations.validators.MatcherReplace; import org.gcube.accounting.datamodel.validations.validators.MatcherReplace;
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration; import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
import org.gcube.com.fasterxml.jackson.databind.JavaType;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.documentstore.persistence.ExecutorUtils; import org.gcube.documentstore.persistence.ExecutorUtils;
import org.gcube.documentstore.records.DSMapper; import org.gcube.documentstore.records.DSMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
public class RegexRulesAggregator implements Runnable { public class RegexRulesAggregator implements Runnable {
private static final Logger logger = LoggerFactory.getLogger(RegexRulesAggregator.class); private static final Logger logger = LoggerFactory.getLogger(RegexRulesAggregator.class);

View File

@ -9,6 +9,7 @@ import java.util.SortedSet;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult; import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult;
import org.gcube.accounting.datamodel.validations.validators.ValidOperationResultValidator; import org.gcube.accounting.datamodel.validations.validators.ValidOperationResultValidator;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.common.authorization.client.Constants; import org.gcube.common.authorization.client.Constants;
import org.gcube.common.authorization.library.AuthorizationEntry; import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
@ -20,8 +21,6 @@ import org.gcube.documentstore.records.implementation.validations.annotations.No
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -2,11 +2,10 @@ package org.gcube.accounting.datamodel;
import java.io.Serializable; import java.io.Serializable;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.Record; import org.gcube.documentstore.records.Record;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -11,6 +11,8 @@ import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord; import org.gcube.accounting.datamodel.usagerecords.JobUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.records.aggregation.AggregationUtility; import org.gcube.documentstore.records.aggregation.AggregationUtility;
@ -18,9 +20,6 @@ import org.gcube.documentstore.records.implementation.AggregatedField;
import org.gcube.documentstore.records.implementation.RequiredField; import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong; import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* This Class is for library internal use only * This Class is for library internal use only
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)

View File

@ -10,12 +10,11 @@ import java.util.Map;
import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord; import org.gcube.accounting.datamodel.usagerecords.PortletUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.records.aggregation.AggregationUtility; import org.gcube.documentstore.records.aggregation.AggregationUtility;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* This Class is for library internal use only * This Class is for library internal use only
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)

View File

@ -10,6 +10,8 @@ import java.util.Map;
import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.records.aggregation.AggregationUtility; import org.gcube.documentstore.records.aggregation.AggregationUtility;
@ -17,9 +19,6 @@ import org.gcube.documentstore.records.implementation.AggregatedField;
import org.gcube.documentstore.records.implementation.RequiredField; import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong; import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* This Class is for library internal use only * This Class is for library internal use only
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)

View File

@ -10,13 +10,12 @@ import java.util.Map;
import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord; import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord; import org.gcube.accounting.datamodel.usagerecords.StorageStatusRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.records.aggregation.AggregationUtility; import org.gcube.documentstore.records.aggregation.AggregationUtility;
import org.gcube.documentstore.records.implementation.AggregatedField; import org.gcube.documentstore.records.implementation.AggregatedField;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* This Class is for library internal use only * This Class is for library internal use only
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it * @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it

View File

@ -10,13 +10,12 @@ import java.util.Map;
import org.gcube.accounting.datamodel.AggregatedUsageRecord; import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord; import org.gcube.accounting.datamodel.usagerecords.StorageUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.records.aggregation.AggregationUtility; import org.gcube.documentstore.records.aggregation.AggregationUtility;
import org.gcube.documentstore.records.implementation.AggregatedField; import org.gcube.documentstore.records.implementation.AggregatedField;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* This Class is for library internal use only * This Class is for library internal use only
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)

View File

@ -7,13 +7,12 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord; import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.RequiredField; import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty; import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong; import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -7,13 +7,12 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord; import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.RequiredField; import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty; import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull; import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -8,13 +8,12 @@ import java.util.Map;
import org.gcube.accounting.datamodel.BasicUsageRecord; import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.validations.annotations.Harmonize; import org.gcube.accounting.datamodel.validations.annotations.Harmonize;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.RequiredField; import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty; import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong; import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -11,13 +11,12 @@ import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign; import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
import org.gcube.accounting.datamodel.validations.annotations.ValidDataTypeVolume; import org.gcube.accounting.datamodel.validations.annotations.ValidDataTypeVolume;
import org.gcube.accounting.datamodel.validations.annotations.ValidURI; import org.gcube.accounting.datamodel.validations.annotations.ValidURI;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.RequiredField; import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty; import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong; import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it * @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)

View File

@ -12,14 +12,13 @@ import org.gcube.accounting.datamodel.validations.annotations.FixDataVolumeSign;
import org.gcube.accounting.datamodel.validations.annotations.ValidDataType; import org.gcube.accounting.datamodel.validations.annotations.ValidDataType;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationType; import org.gcube.accounting.datamodel.validations.annotations.ValidOperationType;
import org.gcube.accounting.datamodel.validations.annotations.ValidURI; import org.gcube.accounting.datamodel.validations.annotations.ValidURI;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.RequiredField; import org.gcube.documentstore.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty; import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull; import org.gcube.documentstore.records.implementation.validations.annotations.NotEmptyIfNotNull;
import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong; import org.gcube.documentstore.records.implementation.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -4,10 +4,9 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -4,10 +4,9 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractPortletUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -4,10 +4,9 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -4,9 +4,8 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord; import org.gcube.accounting.datamodel.basetypes.AbstractStorageStatusRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it * @author Alessandro Pieve (ISTI - CNR) alessandro.pieve@isti.cnr.it
* *

View File

@ -4,10 +4,9 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord; import org.gcube.accounting.datamodel.basetypes.AbstractStorageUsageRecord;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import com.fasterxml.jackson.annotation.JsonTypeName;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*/ */

View File

@ -2,11 +2,10 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.DSMapper; import org.gcube.documentstore.records.DSMapper;
import com.fasterxml.jackson.annotation.JsonSetter;
public class MatcherReplace { public class MatcherReplace {
protected MultiMatcher multiMatcher; protected MultiMatcher multiMatcher;

View File

@ -2,7 +2,7 @@ package org.gcube.accounting.datamodel.validations.validators;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.fasterxml.jackson.annotation.JsonIgnore; import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
public class MultiMatcher { public class MultiMatcher {

View File

@ -3,12 +3,9 @@
*/ */
package org.gcube.accounting.persistence; package org.gcube.accounting.persistence;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.gcube.accounting.aggregator.RegexRulesAggregator; import org.gcube.accounting.aggregator.RegexRulesAggregator;
import org.gcube.accounting.datamodel.BasicUsageRecord;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.documentstore.persistence.PersistenceBackendFactory; import org.gcube.documentstore.persistence.PersistenceBackendFactory;
@ -20,7 +17,10 @@ public class AccountingPersistenceFactory {
private AccountingPersistenceFactory(){} private AccountingPersistenceFactory(){}
protected final static Map<String, AccountingPersistence> persistences; //protected final static Map<String, AccountingPersistence> persistences;
protected final static AccountingPersistence accountingPersistence;
public static void initAccountingPackages(){ public static void initAccountingPackages(){
PersistenceBackendFactory.addRecordPackage(ServiceUsageRecord.class.getPackage()); PersistenceBackendFactory.addRecordPackage(ServiceUsageRecord.class.getPackage());
@ -28,7 +28,8 @@ public class AccountingPersistenceFactory {
} }
static { static {
persistences = new HashMap<String, AccountingPersistence>(); //persistences = new HashMap<String, AccountingPersistence>();
accountingPersistence = new AccountingPersistence(null);
initAccountingPackages(); initAccountingPackages();
} }
@ -37,12 +38,14 @@ public class AccountingPersistenceFactory {
} }
public synchronized static AccountingPersistence getPersistence() { public synchronized static AccountingPersistence getPersistence() {
/*
String context = BasicUsageRecord.getContextFromToken(); String context = BasicUsageRecord.getContextFromToken();
AccountingPersistence accountingPersistence = persistences.get(context); AccountingPersistence accountingPersistence = persistences.get(context);
if(accountingPersistence==null){ if(accountingPersistence==null){
accountingPersistence = new AccountingPersistence(context); accountingPersistence = new AccountingPersistence(context);
persistences.put(context, accountingPersistence); persistences.put(context, accountingPersistence);
} }
*/
return accountingPersistence; return accountingPersistence;
} }

View File

@ -4,14 +4,13 @@ import java.io.InputStream;
import java.util.List; import java.util.List;
import org.gcube.accounting.datamodel.validations.validators.MatcherReplace; import org.gcube.accounting.datamodel.validations.validators.MatcherReplace;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.documentstore.records.DSMapper; import org.gcube.documentstore.records.DSMapper;
import org.gcube.testutility.ContextTest; import org.gcube.testutility.ContextTest;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
public class HarmonizerTest extends ContextTest { public class HarmonizerTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(HarmonizerTest.class); private static final Logger logger = LoggerFactory.getLogger(HarmonizerTest.class);

View File

@ -7,6 +7,7 @@ import java.util.Set;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecordTest; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecordTest;
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.documentstore.exception.InvalidValueException; import org.gcube.documentstore.exception.InvalidValueException;
@ -19,8 +20,6 @@ import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
* *

View File

@ -126,6 +126,18 @@ public class ServiceUsageRecordTest extends ContextTest {
} }
@Test
public void testDeserialization2() throws Exception{
RecordUtility.addRecordPackage(ServiceUsageRecord.class.getPackage());
RecordUtility.addRecordPackage(AggregatedServiceUsageRecord.class.getPackage());
String line = "{\"recordType\":\"ServiceUsageRecord\",\"operationCount\":1,\"creationTime\":1591043453061,\"serviceClass\":\"DataAnalysis\",\"callerHost\":\"80.134.224.170\",\"callerQualifier\": \"TOKEN\",\"consumerId\":\"lisa.chong8594\",\"aggregated\":true,\"serviceName\":\"RConnector\",\"duration\":5328,\"maxInvocationTime\":5328,\"scope\":\"/d4science.research-infrastructures.eu/gCubeApps/StockAssessment\",\"host\":\"rstudio.d4science.org:80\",\"startTime\":1591043453058,\"id\":\"ec925c66-a7e9-4b2a-b0bd-8896ba24edab\",\"calledMethod\":\"/gcube/service/connect\",\"endTime\":1591043453058,\"minInvocationTime\":5328,\"operationResult\":\"SUCCESS\"}";
Record record = RecordUtility.getRecord(line);
logger.debug("{}", record);
}
@Test @Test
public void aRegexReplaceTest() throws Exception{ public void aRegexReplaceTest() throws Exception{
RecordUtility.addRecordPackage(ServiceUsageRecord.class.getPackage()); RecordUtility.addRecordPackage(ServiceUsageRecord.class.getPackage());

View File

@ -14,6 +14,7 @@ import java.util.Map;
import org.gcube.accounting.aggregator.RegexRulesAggregator; import org.gcube.accounting.aggregator.RegexRulesAggregator;
import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord; import org.gcube.accounting.datamodel.aggregation.AggregatedServiceUsageRecord;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord; import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions; import org.gcube.documentstore.exception.NotAggregatableRecordsExceptions;
import org.gcube.documentstore.records.DSMapper; import org.gcube.documentstore.records.DSMapper;
import org.gcube.testutility.ContextTest; import org.gcube.testutility.ContextTest;
@ -23,8 +24,6 @@ import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
public class TestRules extends ContextTest { public class TestRules extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(TestRules.class); private static final Logger logger = LoggerFactory.getLogger(TestRules.class);