Fixing code
This commit is contained in:
parent
3ff630bbcb
commit
120316d1b2
|
@ -17,8 +17,6 @@ import org.gcube.accounting.accounting.summary.access.model.ScopeDescriptor;
|
|||
import org.gcube.accounting.accounting.summary.access.model.internal.Dimension;
|
||||
import org.gcube.accounting.accounting.summary.access.model.update.AccountingRecord;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.utils.secret.GCubeSecret;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
|
@ -216,17 +214,22 @@ public class AccountingDashboardHarvesterPlugin extends Plugin {
|
|||
Properties properties = getConfigParameters();
|
||||
getProperties().set(properties);
|
||||
|
||||
String oldToken = properties.getProperty("OLD_ROOT_TOKEN");
|
||||
GCubeSecret gCubeSecret = new GCubeSecret(oldToken);
|
||||
Utils.setContext(gCubeSecret);
|
||||
ContextAuthorization contextAuthorization = new ContextAuthorization();
|
||||
|
||||
SortedSet<String> contexts = contextAuthorization.getContexts();
|
||||
|
||||
String root = contexts.first();
|
||||
Utils.setContext(contextAuthorization.getSecretForContext(root));
|
||||
|
||||
AccountingDao dao = AccountingDao.get();
|
||||
|
||||
Set<ScopeDescriptor> scopeDescriptorSet = dao.getContexts();
|
||||
Map<String, ScopeDescriptor> scopeDescriptorMap = new HashMap<>();
|
||||
for (ScopeDescriptor scopeDescriptor : scopeDescriptorSet) {
|
||||
scopeDescriptorMap.put(scopeDescriptor.getId(), scopeDescriptor);
|
||||
}
|
||||
scopeDescriptors.set(scopeDescriptorMap);
|
||||
|
||||
|
||||
Set<Dimension> dimensionSet = dao.getDimensions();
|
||||
Map<String, Dimension> dimensionMap = new HashMap<>();
|
||||
for (Dimension dimension : dimensionSet) {
|
||||
|
@ -234,15 +237,6 @@ public class AccountingDashboardHarvesterPlugin extends Plugin {
|
|||
}
|
||||
|
||||
dimensions.set(dimensionMap);
|
||||
|
||||
ContextAuthorization contextAuthorization = new ContextAuthorization(properties);
|
||||
|
||||
SortedSet<String> contexts = contextAuthorization.getContexts();
|
||||
|
||||
String root = contexts.first();
|
||||
Utils.setContext(contextAuthorization.getSecretForContext(root));
|
||||
|
||||
|
||||
|
||||
ArrayList<AccountingRecord> accountingRecords = new ArrayList<AccountingRecord>();
|
||||
|
||||
|
@ -516,8 +510,7 @@ public class AccountingDashboardHarvesterPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
Utils.setContext(gCubeSecret);
|
||||
// Utils.setContext(rootSecret);
|
||||
Utils.setContext(rootSecret);
|
||||
|
||||
logger.debug("Harvest Measures from {} to {} are {}", DateUtils.format(start), DateUtils.format(end),
|
||||
accountingRecords);
|
||||
|
|
|
@ -22,22 +22,6 @@ public class Utils {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(Utils.class);
|
||||
|
||||
// public static String getJson(String url) throws MalformedURLException, IOException {
|
||||
// URL address = new URL(url);
|
||||
// HttpURLConnection connection = (HttpURLConnection) address.openConnection();
|
||||
// BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
// String json = "";
|
||||
// String line = "";
|
||||
//
|
||||
// while(line != null) {
|
||||
// line = reader.readLine();
|
||||
// if(line != null) {
|
||||
// json += line.trim();
|
||||
// }
|
||||
// }
|
||||
// return json;
|
||||
// }
|
||||
|
||||
public static String getCurrentContext() throws ObjectNotFound, Exception {
|
||||
return SecretManagerProvider.instance.get().getContext();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue