diff --git a/pom.xml b/pom.xml index 1fc0fad..e58fb22 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.accounting accounting-analytics - 1.1.0-SNAPSHOT + 1.2.0-SNAPSHOT accounting-analytics @@ -47,21 +47,6 @@ accounting-lib provided - - org.gcube.resources.discovery - ic-client - provided - - - org.gcube.core - common-scope - provided - - - org.gcube.resources - common-gcore-resources - provided - org.json json @@ -81,11 +66,6 @@ 1.0.13 test - - org.gcube.core - common-encryption - test - diff --git a/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java b/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java index 4fa9a3c..b35445d 100644 --- a/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java +++ b/src/main/java/org/gcube/accounting/analytics/ResourceRecordQuery.java @@ -17,7 +17,6 @@ import org.gcube.accounting.analytics.exception.NoAvailableScopeException; import org.gcube.accounting.analytics.exception.NoUsableAccountingPersistenceQueryFound; import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryFactory; -import org.gcube.common.scope.api.ScopeProvider; import org.gcube.documentstore.records.AggregatedRecord; import org.gcube.documentstore.records.Record; import org.gcube.documentstore.records.RecordUtility; @@ -71,19 +70,6 @@ public class ResourceRecordQuery { this.accountingPersistenceQuery = AccountingPersistenceBackendQueryFactory.getInstance(); } - /** - * Instantiate the ResourceRecord for the provided scope - * @param scope the scope - * @throws NoAvailableScopeException if there is not possible to query in - * that scope - * @throws NoUsableAccountingPersistenceQueryFound if there is no available - * instance which can query in that scope - */ - public ResourceRecordQuery(String scope) throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound { - ScopeProvider.instance.set(scope); - this.accountingPersistenceQuery = AccountingPersistenceBackendQueryFactory.getInstance(); - } - protected static JSONObject getPaddingJSONObject(Map unpaddedResults) throws JSONException{ Info auxInfo = new ArrayList(unpaddedResults.values()).get(0); JSONObject auxJsonObject = auxInfo.getValue(); diff --git a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java index 1d06fd9..5429b0a 100644 --- a/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java +++ b/src/main/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceBackendQueryFactory.java @@ -9,7 +9,7 @@ import java.util.ServiceLoader; import org.gcube.accounting.analytics.exception.NoAvailableScopeException; import org.gcube.accounting.analytics.exception.NoUsableAccountingPersistenceQueryFound; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.accounting.datamodel.BasicUsageRecord; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +34,7 @@ public abstract class AccountingPersistenceBackendQueryFactory { * the #AccountingPersistenceQuery */ public synchronized static AccountingPersistenceBackendQuery getInstance() throws NoAvailableScopeException, NoUsableAccountingPersistenceQueryFound { - String scope = ScopeProvider.instance.get(); + String scope = BasicUsageRecord.getScopeFromToken(); if(scope==null){ throw new NoAvailableScopeException(); } diff --git a/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceConfigurationTest.java b/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceConfigurationTest.java deleted file mode 100644 index bf3664a..0000000 --- a/src/test/java/org/gcube/accounting/analytics/persistence/AccountingPersistenceConfigurationTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - */ -package org.gcube.accounting.analytics.persistence; - -import org.gcube.accounting.persistence.AccountingPersistenceConfiguration; -import org.gcube.common.scope.api.ScopeProvider; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/ - * - */ -public class AccountingPersistenceConfigurationTest { - - private static final Logger logger = LoggerFactory.getLogger(AccountingPersistenceConfigurationTest.class); - - public static final String COUCHDB_CLASS_NAME = "AccountingPersistenceQueryCouchDB"; - - public static final String[] SCOPES = new String[]{"/gcube", "/gcube/devNext", "/gcube/devsec"}; - - public abstract class AccountingPersistenceQueryCouchDB extends AccountingPersistenceBackendQuery {} - - @Test - public void getUsernamePasswordForScopes() throws Exception{ - for(String scope : SCOPES){ - ScopeProvider.instance.set(scope); - try { - AccountingPersistenceBackendQueryConfiguration persitenceConfiguration = new AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryCouchDB.class); - String uri = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.URL_PROPERTY_KEY); - String username = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.USERNAME_PROPERTY_KEY); - String password = persitenceConfiguration.getProperty(AccountingPersistenceConfiguration.PASSWORD_PROPERTY_KEY); - logger.debug("{} {} - {} : {}", scope, uri, username, password); - }catch(IndexOutOfBoundsException e){ - logger.debug("No AccountingPersistenceConfiguration : \n {} {} \n\n", e.getClass().getName(), e.getMessage()); - } catch(Exception e){ - logger.error("Error getting AccountingPersistenceConfiguration", e); - throw e; - } - } - } - -}