From c8a87abd731968696df227e0f77951be9221c986 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 12 Feb 2020 17:30:04 +0100 Subject: [PATCH] Added harvesting of CatalogueHarvesterPlugin --- .../AccountingDashboardHarvesterPlugin.java | 26 ++++++++++++------- .../harvester/CatalogueAccessesHarvester.java | 1 - .../gcube/dataharvest/utils/ContextTest.java | 2 -- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java b/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java index 5ec3ea6..506588d 100644 --- a/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java +++ b/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java @@ -19,6 +19,7 @@ import org.gcube.accounting.accounting.summary.access.model.update.AccountingRec import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean.Type; +import org.gcube.dataharvest.harvester.CatalogueAccessesHarvester; import org.gcube.dataharvest.harvester.MethodInvocationHarvester; import org.gcube.dataharvest.harvester.SocialInteractionsHarvester; import org.gcube.dataharvest.harvester.VREAccessesHarvester; @@ -213,7 +214,11 @@ public class AccountingDashboardHarvesterPlugin extends Plugin contexts = contextAuthorization.getContexts(); + + String root = contexts.first(); + Utils.setContext(contextAuthorization.getTokenForContext(root)); + AccountingDao dao = AccountingDao.get(); Set scopeDescriptorSet = dao.getContexts(); @@ -232,10 +237,6 @@ public class AccountingDashboardHarvesterPlugin extends Plugin contexts = contextAuthorization.getContexts(); - - // ArrayList data = new ArrayList(); ArrayList accountingRecords = new ArrayList(); String initialToken = SecurityTokenProvider.instance.get(); @@ -255,6 +256,16 @@ public class AccountingDashboardHarvesterPlugin extends Plugin harvested = catalogueHarvester.getAccountingRecords(); + accountingRecords.addAll(harvested); + }catch (Exception e) { + logger.error("Error harvesting {} for {}", CatalogueAccessesHarvester.class.getSimpleName(), context, e); + } + } + if(vreAccessesHarvester == null) { @@ -369,11 +380,6 @@ public class AccountingDashboardHarvesterPlugin extends Plugin harvested = dataMethodDownloadHarvester.getAccountingRecords(); accountingRecords.addAll(harvested); - /* - List harvested = dataMethodDownloadHarvester.getData(); - data.addAll(harvested); - */ - } catch(Exception e) { logger.error("Error harvesting Data Method Download for {}", context, e); } diff --git a/src/main/java/org/gcube/dataharvest/harvester/CatalogueAccessesHarvester.java b/src/main/java/org/gcube/dataharvest/harvester/CatalogueAccessesHarvester.java index 61efd07..086fb91 100644 --- a/src/main/java/org/gcube/dataharvest/harvester/CatalogueAccessesHarvester.java +++ b/src/main/java/org/gcube/dataharvest/harvester/CatalogueAccessesHarvester.java @@ -38,7 +38,6 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Property; import org.gcube.common.resources.gcore.utils.Group; import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.dataharvest.AccountingDashboardHarvesterPlugin; import org.gcube.dataharvest.datamodel.AnalyticsReportCredentials; import org.gcube.dataharvest.datamodel.CatalogueAccessesReportRow; import org.gcube.dataharvest.datamodel.HarvestedDataKey; diff --git a/src/test/java/org/gcube/dataharvest/utils/ContextTest.java b/src/test/java/org/gcube/dataharvest/utils/ContextTest.java index 14b273a..9105bab 100644 --- a/src/test/java/org/gcube/dataharvest/utils/ContextTest.java +++ b/src/test/java/org/gcube/dataharvest/utils/ContextTest.java @@ -15,8 +15,6 @@ import org.gcube.common.authorization.library.provider.ClientInfo; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.utils.Caller; import org.gcube.common.scope.api.ScopeProvider; -import org.junit.AfterClass; -import org.junit.BeforeClass; import org.slf4j.Logger; import org.slf4j.LoggerFactory;