From 618f18e331f4bb2cdd0a502a1d67da1df9014154 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Tue, 29 May 2018 09:08:24 +0000 Subject: [PATCH] Code redesign Refs #11756: Refactor DataHArvesterPlugin to support scheduled execution from smart-executor Task-Url: https://support.d4science.org/issues/11756 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-dashboard-harvester-se-plugin@167820 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../dataharvest/AccountingDataHarvesterPlugin.java | 14 +++++++++++--- .../dao/DatabaseParameterRetriever.java | 5 ++--- .../AccountingDataHarvesterPluginTest.java | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java b/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java index 0c8749e..68f0f37 100644 --- a/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java +++ b/src/main/java/org/gcube/dataharvest/AccountingDataHarvesterPlugin.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Properties; import java.util.SortedSet; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.dataharvest.dao.DatabaseManager; import org.gcube.dataharvest.datamodel.HarvestedData; import org.gcube.dataharvest.harvester.MethodInvocationHarvester; @@ -133,6 +134,9 @@ public class AccountingDataHarvesterPlugin extends Plugin data = new ArrayList(); + + String initialToken = SecurityTokenProvider.instance.get(); + for(String context : contexts) { // Setting the token for the context @@ -149,9 +153,11 @@ public class AccountingDataHarvesterPlugin extends Plugin harvested = vreUsersHarvester.getData(); - data.addAll(harvested); + if(!reRun) { + VREUsersHarvester vreUsersHarvester = new VREUsersHarvester(start, end); + List harvested = vreUsersHarvester.getData(); + data.addAll(harvested); + } } catch(Exception e) { logger.error("Error harvesting Context Users for {}", context, e); } @@ -200,6 +206,8 @@ public class AccountingDataHarvesterPlugin extends Plugin