aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2022-03-16 14:39:49 +0100
committerGitHub <noreply@github.com>2022-03-16 14:39:49 +0100
commit89c00be86b2de199ab125d0bc662e6b429dc662d (patch)
treecb7c0ccca16a37d20bb75771b07702efdfdd6c5d /controller-api
parent795e37de11ddad1a8d0f6641849f5a2e7a9b8e68 (diff)
parentdf8005e4cab1b1b8b1df2072a9d1e5bd2d2fe296 (diff)
Merge pull request #21704 from vespa-engine/ldalves/disallow-duplicated-email
disallow duplicate contact
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TenantContacts.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TenantContacts.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TenantContacts.java
index 14635a3bb30..bd8671d814f 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TenantContacts.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/tenant/TenantContacts.java
@@ -18,6 +18,13 @@ public class TenantContacts {
public TenantContacts(List<? extends Contact> contacts) {
this.contacts = List.copyOf(contacts);
+ for (int i = 0; i < contacts.size(); i++) {
+ for (int j = 0; j < i; j++) {
+ if (contacts.get(i).equals(contacts.get(j))) {
+ throw new IllegalArgumentException("Duplicate contact: " + contacts.get(i));
+ }
+ }
+ }
}
public static TenantContacts empty() {
@@ -57,7 +64,7 @@ public class TenantContacts {
public Contact(List<Audience> audiences) {
this.audiences = List.copyOf(audiences);
- if (audiences.isEmpty()) throw new IllegalArgumentException("at least one notification activity must be enabled");
+ if (audiences.isEmpty()) throw new IllegalArgumentException("At least one notification activity must be enabled");
}
public List<Audience> audiences() { return audiences; }
@@ -99,9 +106,7 @@ public class TenantContacts {
@Override
public String toString() {
- return "EmailContact{" +
- "email='" + email + '\'' +
- '}';
+ return "email '" + email + '\'';
}
}