diff --git a/CHANGELOG.md b/CHANGELOG.md
index 92d1d84..5b359f2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,15 +2,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for Accounting Library
-## [v5.0.0]
+## [v5.0.0-SNAPSHOT]
- removed old Providers
+- Added compatibility between smartgears 3 and smartgears 4 component
-## [v4.2.0-SNAPSHOT]
-
--
-
## [v4.1.0]
- Deprecated not needed properties to reduce data and improve aggregation
diff --git a/pom.xml b/pom.xml
index 7b0c56e..450461b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,11 +5,11 @@
org.gcube.tools
maven-parent
- 1.1.0
+ 1.2.0
org.gcube.accounting
accounting-lib
- 5.0.0
+ 5.0.0-SNAPSHOT
Accounting Library
Accounting Library
@@ -53,12 +53,16 @@
org.gcube.common
gcube-jackson-databind
+
+ org.gcube.common
+ common-utility-sg4
+
+
org.gcube.common.security
gcube-secrets
test
-
junit
junit
diff --git a/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java
index e331d9a..e73ef59 100644
--- a/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java
+++ b/src/main/java/org/gcube/accounting/datamodel/BasicUsageRecord.java
@@ -10,8 +10,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.security.providers.SecretManagerProvider;
-import org.gcube.common.security.secrets.Secret;
+import org.gcube.common.context.ContextUtility;
import org.gcube.documentstore.exception.InvalidValueException;
import org.gcube.documentstore.records.implementation.AbstractRecord;
import org.gcube.documentstore.records.implementation.RequiredField;
@@ -51,9 +50,9 @@ public abstract class BasicUsageRecord extends AbstractRecord implements UsageRe
super.init();
// Backward compatibility
try {
- Secret secret = SecretManagerProvider.instance.get();
- this.setScope(secret.getContext());
- } catch (Exception e) {
+ String context = ContextUtility.getCurrentContextFullName();
+ this.setScope(context);
+ } catch (Throwable t) {
logger.warn(
"Unable to automaticcally set the scope using scope provider. The record will not be valid if the scope will not be explicitly set.");
}
diff --git a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceConfiguration.java b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceConfiguration.java
index bba86c1..4b9028e 100644
--- a/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceConfiguration.java
+++ b/src/main/java/org/gcube/accounting/persistence/AccountingPersistenceConfiguration.java
@@ -6,12 +6,12 @@ package org.gcube.accounting.persistence;
import java.util.List;
import java.util.Map;
+import org.gcube.common.context.ContextUtility;
import org.gcube.common.encryption.encrypter.StringEncrypter;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
import org.gcube.common.resources.gcore.utils.Group;
-import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.documentstore.persistence.PersistenceBackendConfiguration;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
@@ -41,7 +41,7 @@ public class AccountingPersistenceConfiguration extends PersistenceBackendConfig
public AccountingPersistenceConfiguration(Class> clz) throws Exception {
super();
- String context = SecretManagerProvider.instance.get().getContext();
+ String context = ContextUtility.getCurrentContextFullName();
try {
ServiceEndpoint serviceEndpoint = getServiceEndpoint(SERVICE_ENDPOINT_CATEGORY, SERVICE_ENDPOINT_NAME, clz);
setValues(serviceEndpoint, clz);
@@ -66,7 +66,7 @@ public class AccountingPersistenceConfiguration extends PersistenceBackendConfig
DiscoveryClient client = ICFactory.clientFor(ServiceEndpoint.class);
List serviceEndpoints = client.submit(query);
if(serviceEndpoints.size()>1){
- String scope = SecretManagerProvider.instance.get().getContext();
+ String scope = ContextUtility.getCurrentContextFullName();
query.addCondition(String.format("$resource/Profile/AccessPoint/Properties/Property/Name/text() eq '%s'", TARGET_SCOPE));
query.addCondition(String.format("$resource/Profile/AccessPoint/Properties/Property/Value/text() eq '%s'", scope));
serviceEndpoints = client.submit(query);