From c21b7143ddd7894388baaa893337b2d894ae5112 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 10 Jun 2021 12:25:51 +0200 Subject: [PATCH] Fixing plugin --- .../AccountingDashboardHarvesterPlugin.java | 10 ++++++---- .../harvester/sobigdata/SoBigDataHarvester.java | 2 +- .../gcube/dataharvest/utils/ContextAuthorization.java | 4 ++-- .../dataharvest/AccountingDataHarvesterPluginTest.java | 8 ++++---- .../dataharvest/utils/ContextAuthorizationTest.java | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java b/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java index 548972f..939c070 100644 --- a/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java +++ b/src/main/java/org/gcube/dataharvest/AccountingDashboardHarvesterPlugin.java @@ -16,6 +16,7 @@ import org.gcube.accounting.accounting.summary.access.AccountingDao; 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.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean.Type; @@ -78,7 +79,7 @@ public class AccountingDashboardHarvesterPlugin extends Plugin { super(); } - private static final InheritableThreadLocal properties = new InheritableThreadLocal() { + private static final InheritableThreadLocal configProperties = new InheritableThreadLocal() { @Override protected Properties initialValue() { @@ -87,8 +88,8 @@ public class AccountingDashboardHarvesterPlugin extends Plugin { }; - public static InheritableThreadLocal getProperties() { - return properties; + public static InheritableThreadLocal getConfigProperties() { + return configProperties; } public static Dimension getDimension(String key) { @@ -134,6 +135,7 @@ public class AccountingDashboardHarvesterPlugin extends Plugin { }; + @JsonIgnore public Properties getConfigParameters() throws IOException { Properties properties = new Properties(); try { @@ -209,7 +211,7 @@ public class AccountingDashboardHarvesterPlugin extends Plugin { DateUtils.format(end), reRun, getVREUsers, dryRun); Properties properties = getConfigParameters(); - getProperties().set(properties); + getConfigProperties().set(properties); ContextAuthorization contextAuthorization = new ContextAuthorization(); diff --git a/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java b/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java index a99eb52..f7d7403 100644 --- a/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java +++ b/src/main/java/org/gcube/dataharvest/harvester/sobigdata/SoBigDataHarvester.java @@ -77,7 +77,7 @@ public abstract class SoBigDataHarvester extends BasicHarvester { * @throws ObjectNotFound */ protected void initMappingMaps() throws ObjectNotFound, Exception { - Properties properties = AccountingDashboardHarvesterPlugin.getProperties().get(); + Properties properties = AccountingDashboardHarvesterPlugin.getConfigProperties().get(); Set keys = properties.stringPropertyNames(); mapSystemTypeToDBEntry = new HashMap(); diff --git a/src/main/java/org/gcube/dataharvest/utils/ContextAuthorization.java b/src/main/java/org/gcube/dataharvest/utils/ContextAuthorization.java index ff25c00..a3b3324 100644 --- a/src/main/java/org/gcube/dataharvest/utils/ContextAuthorization.java +++ b/src/main/java/org/gcube/dataharvest/utils/ContextAuthorization.java @@ -52,7 +52,7 @@ public class ContextAuthorization { public String generateTokenForContext(String context, Properties properties) throws Exception { if(properties==null) { - properties = AccountingDashboardHarvesterPlugin.getProperties().get(); + properties = AccountingDashboardHarvesterPlugin.getConfigProperties().get(); } logger.info("Going to generate Token for Context {}", context); UserInfo userInfo = new UserInfo(properties.getProperty(USERNAME, DEFAULT_USERNAME), @@ -74,7 +74,7 @@ public class ContextAuthorization { try { - Properties properties = AccountingDashboardHarvesterPlugin.getProperties().get(); + Properties properties = AccountingDashboardHarvesterPlugin.getConfigProperties().get(); LinkedHashMap map = ContextManager.readContexts(); for(String scope : map.keySet()) { diff --git a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java index 18c46a3..5d61b41 100644 --- a/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java +++ b/src/test/java/org/gcube/dataharvest/AccountingDataHarvesterPluginTest.java @@ -225,7 +225,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AccountingDashboardHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDashboardHarvesterPlugin(); Properties properties = accountingDataHarvesterPlugin.getConfigParameters(); - AccountingDashboardHarvesterPlugin.getProperties().set(properties); + AccountingDashboardHarvesterPlugin.getConfigProperties().set(properties); ContextAuthorization contextAuthorization = new ContextAuthorization(); SortedSet contexts = contextAuthorization.getContexts(); @@ -506,7 +506,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AccountingDashboardHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDashboardHarvesterPlugin(); Properties properties = accountingDataHarvesterPlugin.getConfigParameters(); - AccountingDashboardHarvesterPlugin.getProperties().set(properties); + AccountingDashboardHarvesterPlugin.getConfigProperties().set(properties); ContextAuthorization contextAuthorization = new ContextAuthorization(); @@ -711,7 +711,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AccountingDashboardHarvesterPlugin accountingDataHarvesterPlugin = new AccountingDashboardHarvesterPlugin(); Properties properties = accountingDataHarvesterPlugin.getConfigParameters(); - AccountingDashboardHarvesterPlugin.getProperties().set(properties); + AccountingDashboardHarvesterPlugin.getConfigProperties().set(properties); // AccountingDao dao = AccountingDao.get(); @@ -931,7 +931,7 @@ public class AccountingDataHarvesterPluginTest extends ContextTest { AccountingDashboardHarvesterPlugin adhp = new AccountingDashboardHarvesterPlugin(); Properties properties = adhp.getConfigParameters(); - AccountingDashboardHarvesterPlugin.getProperties().set(properties); + AccountingDashboardHarvesterPlugin.getConfigProperties().set(properties); ContextAuthorization contextAuthorization = new ContextAuthorization(); diff --git a/src/test/java/org/gcube/dataharvest/utils/ContextAuthorizationTest.java b/src/test/java/org/gcube/dataharvest/utils/ContextAuthorizationTest.java index d58b959..f9a3719 100644 --- a/src/test/java/org/gcube/dataharvest/utils/ContextAuthorizationTest.java +++ b/src/test/java/org/gcube/dataharvest/utils/ContextAuthorizationTest.java @@ -24,7 +24,7 @@ public class ContextAuthorizationTest extends ContextTest { properties = new Properties(); InputStream input = AccountingDashboardHarvesterPlugin.class.getClassLoader().getResourceAsStream(PROPERTY_FILENAME); properties.load(input); - AccountingDashboardHarvesterPlugin.getProperties().set(properties); + AccountingDashboardHarvesterPlugin.getConfigProperties().set(properties); } @Ignore