String username = endpoint.substring(7);
if (Utils.getRegistryService() != null) {
UserRegistry registry = Utils.getRegistryService().getConfigSystemRegistry();
if (registry != null && registry.getUserRealm() != null &&
registry.getUserRealm().getUserStoreManager() != null) {
UserStoreManager reader = registry.getUserRealm().getUserStoreManager();
email = "mailto:" + reader.getUserClaimValue(username,
UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS,
UserCoreConstants.DEFAULT_PROFILE);
}
}
} catch (Exception e) {
log.error("Failed Sending Notification to: " + endpoint);
return;
}
log.debug("Sending Notification to: " + email);
publishEvent(event, subscription, email, true);
} else if (endpoint.toLowerCase().startsWith("role://")) {
List<String> emails = new LinkedList<String>();
try {
String roleName = endpoint.substring(7);
if (Utils.getRegistryService() != null) {
UserRegistry registry = Utils.getRegistryService().getConfigSystemRegistry();
if (registry != null && registry.getUserRealm() != null &&
registry.getUserRealm().getUserStoreManager() != null) {
UserStoreManager reader = registry.getUserRealm().getUserStoreManager();
for (String username : reader.getUserListOfRole(roleName)) {
String temp = reader.getUserClaimValue(username,
UserCoreConstants.ClaimTypeURIs.EMAIL_ADDRESS,
UserCoreConstants.DEFAULT_PROFILE);
if (temp != null && temp.length() > 0) {
emails.add("mailto:" + temp);
}