Improving code

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@117222 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-07-14 13:09:23 +00:00
parent 8872c8a9e5
commit 8e2217c293
1 changed files with 14 additions and 9 deletions

View File

@ -5,6 +5,7 @@ package org.gcube.accounting.persistence;
import java.net.URI;
import java.security.Key;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -52,7 +53,7 @@ public class AccountingPersistenceConfiguration {
public AccountingPersistenceConfiguration(String persistenceClassName) throws Exception {
init();
ServiceEndpoint serviceEndpoint = getServiceEndpoint(SERVICE_ENDPOINT_CATEGORY, SERVICE_ENDPOINT_NAME, persistenceClassName);
setValues(serviceEndpoint);
setValues(serviceEndpoint,persistenceClassName);
}
/**
@ -127,17 +128,21 @@ public class AccountingPersistenceConfiguration {
return StringEncrypter.getEncrypter().decrypt(encrypted);
}
protected void setValues(ServiceEndpoint serviceEndpoint) throws Exception{
protected void setValues(ServiceEndpoint serviceEndpoint, String persistenceClassName) throws Exception{
Group<AccessPoint> accessPoints = serviceEndpoint.profile().accessPoints();
for(AccessPoint accessPoint : accessPoints){
this.uri = new URI(accessPoint.address());
this.username = accessPoint.username();
Collection<Property> properties = accessPoint.propertyMap().values();
String encryptedPassword = accessPoint.password();
String password = decrypt(encryptedPassword);
this.password = password;
this.propertyMap = accessPoint.propertyMap();
if(properties.contains(new ServiceEndpoint.Property().nameAndValue(PERSISTENCE_CLASS_NAME, persistenceClassName))){
this.uri = new URI(accessPoint.address());
this.username = accessPoint.username();
String encryptedPassword = accessPoint.password();
String password = decrypt(encryptedPassword);
this.password = password;
this.propertyMap = accessPoint.propertyMap();
}
}
}