Switching to gcube-jackson

master
Luca Frosini 4 years ago
parent 83820adbcf
commit 5bc7453225

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

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

@ -9,6 +9,7 @@ import java.util.SortedSet;
import org.gcube.accounting.datamodel.validations.annotations.ValidOperationResult;
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.library.AuthorizationEntry;
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.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Luca Frosini (ISTI - CNR)
*/

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

@ -11,6 +11,8 @@ import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractJobUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
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.NotAggregatableRecordsExceptions;
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.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
/**
* This Class is for library internal use only
* @author Luca Frosini (ISTI - CNR)

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

@ -10,6 +10,8 @@ import java.util.Map;
import org.gcube.accounting.datamodel.AggregatedUsageRecord;
import org.gcube.accounting.datamodel.basetypes.AbstractServiceUsageRecord;
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.NotAggregatableRecordsExceptions;
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.validations.annotations.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeName;
/**
* This Class is for library internal use only
* @author Luca Frosini (ISTI - CNR)

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

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

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

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

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

@ -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.ValidDataTypeVolume;
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.records.implementation.RequiredField;
import org.gcube.documentstore.records.implementation.validations.annotations.NotEmpty;
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 Luca Frosini (ISTI - CNR)

@ -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.ValidOperationType;
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.records.implementation.RequiredField;
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.ValidLong;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* @author Luca Frosini (ISTI - CNR)
*/

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

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

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

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

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

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

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

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

@ -4,14 +4,13 @@ import java.io.InputStream;
import java.util.List;
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.testutility.ContextTest;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
public class HarmonizerTest extends ContextTest {
private static final Logger logger = LoggerFactory.getLogger(HarmonizerTest.class);

@ -7,6 +7,7 @@ import java.util.Set;
import org.gcube.accounting.datamodel.usagerecords.ServiceUsageRecord;
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.scope.api.ScopeProvider;
import org.gcube.documentstore.exception.InvalidValueException;
@ -19,8 +20,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
/**
* @author Luca Frosini (ISTI - CNR)
*

@ -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
public void aRegexReplaceTest() throws Exception{
RecordUtility.addRecordPackage(ServiceUsageRecord.class.getPackage());

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

Loading…
Cancel
Save