refs #2194: Remove the use of ScopeProvider if any from accounting-analytics

https://support.d4science.org/issues/2194

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-analytics@124011 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-02-09 16:48:08 +00:00
parent c766e6e93f
commit ceebe58946
4 changed files with 3 additions and 82 deletions

22
pom.xml
View File

@ -9,7 +9,7 @@
<groupId>org.gcube.accounting</groupId>
<artifactId>accounting-analytics</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
<name>accounting-analytics</name>
<scm>
@ -47,21 +47,6 @@
<artifactId>accounting-lib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources</groupId>
<artifactId>common-gcore-resources</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
@ -81,11 +66,6 @@
<version>1.0.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -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<Calendar, Info> unpaddedResults) throws JSONException{
Info auxInfo = new ArrayList<Info>(unpaddedResults.values()).get(0);
JSONObject auxJsonObject = auxInfo.getValue();

View File

@ -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();
}

View File

@ -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;
}
}
}
}