← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21017: Added DhisConfigurationProvider.getProperties( String keyBase )

 

------------------------------------------------------------
revno: 21017
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-10 19:15:10 +0100
message:
  Added DhisConfigurationProvider.getProperties( String keyBase )
modified:
  dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DefaultDhisConfigurationProvider.java
  dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DhisConfigurationProvider.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DefaultDhisConfigurationProvider.java'
--- dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DefaultDhisConfigurationProvider.java	2015-11-10 17:36:28 +0000
+++ dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DefaultDhisConfigurationProvider.java	2015-11-10 18:15:10 +0000
@@ -30,6 +30,8 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 import org.apache.commons.logging.Log;
@@ -37,6 +39,8 @@
 import org.hisp.dhis.external.location.LocationManager;
 import org.hisp.dhis.external.location.LocationManagerException;
 
+import com.google.common.collect.ImmutableMap;
+
 /**
  * @author Lars Helge Overland
  */
@@ -111,6 +115,24 @@
     {
         return properties;
     }
+
+    @Override
+    public Map<String, String> getProperties( String keyBase )
+    {
+        Properties properties = getProperties();
+        
+        Map<String, String> map = new HashMap<>();
+        
+        for ( String key : properties.stringPropertyNames() )
+        {
+            if ( key != null && key.startsWith( keyBase ) )
+            {
+                map.put( key, properties.getProperty( key ) );
+            }
+        }
+        
+        return ImmutableMap.copyOf( map );
+    }
     
     @Override
     public String getProperty( ConfigurationKey key  )

=== modified file 'dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DhisConfigurationProvider.java'
--- dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DhisConfigurationProvider.java	2015-10-27 14:11:44 +0000
+++ dhis-2/dhis-support/dhis-support-external/src/main/java/org/hisp/dhis/external/conf/DhisConfigurationProvider.java	2015-11-10 18:15:10 +0000
@@ -1,5 +1,7 @@
 package org.hisp.dhis.external.conf;
 
+import java.util.Map;
+
 /*
  * Copyright (c) 2004-2015, University of Oslo
  * All rights reserved.
@@ -46,6 +48,15 @@
     Properties getProperties();
     
     /**
+     * Get configuration as an immutable map. The maps contains only properties 
+     * which keys are starting with the given key base.
+     * 
+     * @param keyBase the base for properties to include.
+     * @return an immutable map of the properties.
+     */
+    Map<String, String> getProperties( String keyBase );
+    
+    /**
      * Get the property value for the given key, or the default value for the
      * configuration key if not exists.
      *