Skip to content

Commit 681daee

Browse files
author
FusionAuth Automation
committed
Sync from monorepo f8a632ea9acc
1 parent 15e556d commit 681daee

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

src/main/java/io/fusionauth/domain/Theme.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019-2025, FusionAuth, All Rights Reserved
2+
* Copyright (c) 2019-2026, FusionAuth, All Rights Reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,9 @@
1515
*/
1616
package io.fusionauth.domain;
1717

18+
import java.io.IOException;
19+
import java.io.StringReader;
20+
import java.io.UncheckedIOException;
1821
import java.time.ZoneId;
1922
import java.time.ZonedDateTime;
2023
import java.time.format.DateTimeFormatter;
@@ -23,6 +26,7 @@
2326
import java.util.Locale;
2427
import java.util.Map;
2528
import java.util.Objects;
29+
import java.util.Properties;
2630
import java.util.Set;
2731
import java.util.SortedSet;
2832
import java.util.TreeSet;
@@ -160,6 +164,29 @@ public String message(String key, Object... arguments) {
160164
return "";
161165
}
162166

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+
163190
@JsonIgnore
164191
public boolean missingTemplate() {
165192
if (ThemeType.simple.equals(type)) {

0 commit comments

Comments
 (0)