package org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration; ***REMOVED*** import java.util.ArrayList; import java.util.Iterator; ***REMOVED*** import java.util.Properties; ***REMOVED*** import org.gcube.dataanalysis.dataminer.poolmanager.clients.ScopedCacheMap; import org.gcube.dataanalysis.dataminer.poolmanager.clients.configuration.ConfigurationImpl.CONFIGURATIONS; ***REMOVED*** ***REMOVED*** ***REMOVED*** public class DMPMClientConfiguratorManager ***REMOVED*** ***REMOVED*** private Properties defaultAdmins; static DMPMClientConfiguratorManager instance; private ScopedCacheMap cacheMap; private DMPMClientConfiguratorManager() ***REMOVED*** this.cacheMap = new ScopedCacheMap(); this.logger = LoggerFactory.getLogger(DMPMClientConfiguratorManager.class); this.defaultAdmins = new Properties(); try ***REMOVED*** this.defaultAdmins.load(this.getClass().getResourceAsStream("/default.admins")); this.logger.debug("Default users successfully loaded"); ***REMOVED*** catch (Exception e) ***REMOVED*** this.logger.error("Unable to get default users", e); ***REMOVED*** ***REMOVED*** private ClientConfigurationCache getCurrentCache() ***REMOVED*** String currentScope = ScopeProvider.instance.get(); this.logger.debug("Current scope = " + currentScope); this.logger.debug("Getting current configuration cache"); ClientConfigurationCache cache = this.cacheMap.get(currentScope); if (cache == null) ***REMOVED*** this.logger.debug("Cache not created yet, creating..."); cache = new ClientConfigurationCache(); this.cacheMap.put(currentScope, cache); ***REMOVED*** return cache; ***REMOVED*** public static DMPMClientConfiguratorManager getInstance() ***REMOVED*** if (instance == null) instance = new DMPMClientConfiguratorManager(); return instance; ***REMOVED*** public Configuration getProductionConfiguration() ***REMOVED*** return new ConfigurationImpl(CONFIGURATIONS.PROD, getCurrentCache()); ***REMOVED*** public Configuration getStagingConfiguration() ***REMOVED*** return new ConfigurationImpl(CONFIGURATIONS.STAGE, getCurrentCache()); ***REMOVED*** public List getDefaultAdmins() ***REMOVED*** List admins = new ArrayList(); if (defaultAdmins == null || defaultAdmins.isEmpty()) ***REMOVED*** admins.add("statistical.manager"); ***REMOVED*** else ***REMOVED*** Iterator keys = this.defaultAdmins.keySet().iterator(); while (keys.hasNext()) ***REMOVED*** String key = (String) keys.next(); admins.add(defaultAdmins.getProperty(key)); ***REMOVED*** ***REMOVED*** this.logger.debug("Default admins list: " + admins); return admins; ***REMOVED*** public static void main(String[] args) throws IOException, SVNException ***REMOVED*** DMPMClientConfiguratorManager a = new DMPMClientConfiguratorManager(); ScopeProvider.instance.set("/gcube/devNext/NextNext"); ***REMOVED*** SecurityTokenProvider.instance.set("***REMOVED***"); System.out.println("RESULT 1" + a.getStagingConfiguration().getSVNCRANDepsList()); System.out.println("RESULT 2" + a.getProductionConfiguration().getRepository()); System.out.println("RESULT 3" + a.getStagingConfiguration().getSVNRepository().getPath()); ***REMOVED*** System.out.println(a.getRepo()); ***REMOVED*** System.out.println(a.getAlgoRepo()); ***REMOVED*** System.out.println(a.getSVNRepo()); ***REMOVED*** ***REMOVED***