aboutsummaryrefslogtreecommitdiffstats
path: root/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java
diff options
context:
space:
mode:
Diffstat (limited to 'config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java')
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java
index 04f8594d18e..8ee1d05df21 100644
--- a/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java
+++ b/config-model-api/src/main/java/com/yahoo/config/application/api/xml/DeploymentSpecXmlReader.java
@@ -21,7 +21,9 @@ import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -118,11 +120,20 @@ public class DeploymentSpecXmlReader {
if (notificationsElement == null)
return DeploymentSpec.Notifications.none();
- List<String> staticEmails = XML.getChildren(notificationsElement, "email").stream()
- .map(XML::getValue)
- .collect(Collectors.toList());
- boolean includeAuthor = XML.getChild(notificationsElement, "author") != null;
- return DeploymentSpec.Notifications.of(staticEmails, includeAuthor);
+ Optional<String> when = stringAttribute("when", notificationsElement);
+ Map<String, Optional<String>> staticEmails = new HashMap<>();
+ Map<String, Optional<String>> roleEmails = new HashMap<>();
+
+ for (Element emailElement : XML.getChildren(notificationsElement, "email")) {
+ Optional<String> addressAttribute = stringAttribute("address", emailElement);
+ Optional<String> roleAttribute = stringAttribute("role", emailElement);
+ if (addressAttribute.isPresent() == roleAttribute.isPresent())
+ throw new IllegalArgumentException("Exactly one of 'role' and 'address' must be present in 'email' elements.");
+
+ addressAttribute.ifPresent(address -> staticEmails.put(address, stringAttribute("when", emailElement)));
+ roleAttribute.ifPresent(role -> roleEmails.put(role, stringAttribute("when", emailElement)));
+ }
+ return DeploymentSpec.Notifications.of(when, staticEmails, roleEmails);
}
/** Imposes some constraints on tag order which are not expressible in the schema */