Skip to content

Commit

Permalink
Fix for building identity-event properties related to sms publisher (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakshan-Banneheke authored Feb 8, 2024
1 parent 30fa24d commit b143dc0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private Properties loadProperties() throws IdentityEventException {
* Build and store per module configuration objects
*/
private void build() {
Properties moduleNames = IdentityEventUtils.getSubProperties("module.name", notificationMgtConfigProperties);
Properties moduleNames = IdentityEventUtils.getModuleNames("module.name", notificationMgtConfigProperties);
Enumeration propertyNames = moduleNames.propertyNames();
// Iterate through events and build event objects
while (propertyNames.hasMoreElements()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static Properties getPropertiesWithPrefix(String prefix, Properties prope
}

/**
* Returns a sub set of properties which has the given prefix key. ie properties which has numbers at the end
* Returns a sub set of properties which has the given prefix key.
*
* @param prefix Prefix of the key
* @param properties Set of properties which needs be filtered for the given prefix
Expand All @@ -81,9 +81,33 @@ public static Properties getSubProperties(String prefix, Properties properties)
throw new IllegalArgumentException("Prefix and Properties should not be null to get sub properties");
}

int i = 1;
Properties subProperties = new Properties();
while (properties.getProperty(prefix + "." + i) != null) {
// Remove from original properties to hold property schema. ie need to get the set of properties which
// remains after consuming all required specific properties.
subProperties.put(prefix + "." + i, properties.remove(prefix + "." + i++));
}
return subProperties;
}

/**
* Returns the module names using a given prefix key. ie properties which has numbers at the end.
*
* @param prefix Prefix of the properties used to define module names.
* @param properties Set of properties which needs be filtered for the given prefix.
* @return Map of module names.
*/
public static Properties getModuleNames(String prefix, Properties properties) {

// Stop proceeding if required arguments are not present.
if (StringUtils.isEmpty(prefix) || properties == null) {
throw new IllegalArgumentException("Prefix and Properties should not be null to get sub properties");
}

Properties subProperties = new Properties();
// Remove from original properties to hold property schema. ie need to get the set of properties which
// remains after consuming all required specific properties
// remains after consuming all required specific properties.
subProperties.putAll(getPropertiesWithPrefix(prefix, properties));
return subProperties;
}
Expand Down

0 comments on commit b143dc0

Please sign in to comment.