|
1 | 1 | /* |
2 | | - * Copyright (c) 2019-2025, FusionAuth, All Rights Reserved |
| 2 | + * Copyright (c) 2019-2026, FusionAuth, All Rights Reserved |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
15 | 15 | */ |
16 | 16 | package io.fusionauth.domain; |
17 | 17 |
|
| 18 | +import java.io.IOException; |
| 19 | +import java.io.StringReader; |
| 20 | +import java.io.UncheckedIOException; |
18 | 21 | import java.time.ZoneId; |
19 | 22 | import java.time.ZonedDateTime; |
20 | 23 | import java.time.format.DateTimeFormatter; |
|
23 | 26 | import java.util.Locale; |
24 | 27 | import java.util.Map; |
25 | 28 | import java.util.Objects; |
| 29 | +import java.util.Properties; |
26 | 30 | import java.util.Set; |
27 | 31 | import java.util.SortedSet; |
28 | 32 | import java.util.TreeSet; |
@@ -160,6 +164,29 @@ public String message(String key, Object... arguments) { |
160 | 164 | return ""; |
161 | 165 | } |
162 | 166 |
|
| 167 | + /** |
| 168 | + * Checks whether this theme is missing any required message keys. |
| 169 | + * |
| 170 | + * @param expectedKeys The set of expected message keys |
| 171 | + * @return true if this theme is missing one or more message keys |
| 172 | + */ |
| 173 | + public boolean missingMessages(Set<String> expectedKeys) { |
| 174 | + if (type != ThemeType.advanced || FUSIONAUTH_THEME_ID.equals(id) || expectedKeys == null || expectedKeys.isEmpty()) { |
| 175 | + return false; |
| 176 | + } |
| 177 | + |
| 178 | + Properties defined = new Properties(); |
| 179 | + if (defaultMessages != null) { |
| 180 | + try { |
| 181 | + defined.load(new StringReader(defaultMessages)); |
| 182 | + } catch (IOException e) { |
| 183 | + throw new UncheckedIOException(e); |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + return expectedKeys.stream().anyMatch(key -> !defined.containsKey(key)); |
| 188 | + } |
| 189 | + |
163 | 190 | @JsonIgnore |
164 | 191 | public boolean missingTemplate() { |
165 | 192 | if (ThemeType.simple.equals(type)) { |
|
0 commit comments