add null checks
This commit is contained in:
parent
393284ebdc
commit
5e791af057
1 changed files with 18 additions and 0 deletions
|
|
@ -54,6 +54,10 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
|
|
||||||
Pattern slugPattern = Pattern.compile("^[a-zA-Z0-9_-]*$");
|
Pattern slugPattern = Pattern.compile("^[a-zA-Z0-9_-]*$");
|
||||||
String configAttributeSlug = model.getConfig().getFirst("slug");
|
String configAttributeSlug = model.getConfig().getFirst("slug");
|
||||||
|
if (configAttributeSlug == null) {
|
||||||
|
hasError = true;
|
||||||
|
errorString += " • [Slug] can not be empty\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (!slugPattern.matcher(configAttributeSlug).matches()) {
|
if (!slugPattern.matcher(configAttributeSlug).matches()) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
@ -61,6 +65,11 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
}
|
}
|
||||||
|
|
||||||
String configAuthRole = model.getConfig().getFirst("auth-role");
|
String configAuthRole = model.getConfig().getFirst("auth-role");
|
||||||
|
if (configAuthRole == null) {
|
||||||
|
hasError = true;
|
||||||
|
errorString += " • [Auth Role] can not be empty\n";
|
||||||
|
}
|
||||||
|
|
||||||
RoleModel authRole = realm.getRole(configAuthRole);
|
RoleModel authRole = realm.getRole(configAuthRole);
|
||||||
if (authRole == null) {
|
if (authRole == null) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
@ -68,6 +77,11 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
}
|
}
|
||||||
|
|
||||||
String configMatchRole = model.getConfig().getFirst("match-role");
|
String configMatchRole = model.getConfig().getFirst("match-role");
|
||||||
|
if (configMatchRole == null) {
|
||||||
|
hasError = true;
|
||||||
|
errorString += " • [Match Role] can not be empty\n";
|
||||||
|
}
|
||||||
|
|
||||||
RoleModel matchRole = realm.getRole(configMatchRole);
|
RoleModel matchRole = realm.getRole(configMatchRole);
|
||||||
if (matchRole == null) {
|
if (matchRole == null) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
@ -77,6 +91,10 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
UserProfileProvider profileProvider = session.getProvider(UserProfileProvider.class);
|
UserProfileProvider profileProvider = session.getProvider(UserProfileProvider.class);
|
||||||
UPConfig upconfig = profileProvider.getConfiguration();
|
UPConfig upconfig = profileProvider.getConfiguration();
|
||||||
String configAttributeGroup = model.getConfig().getFirst("attribute-group");
|
String configAttributeGroup = model.getConfig().getFirst("attribute-group");
|
||||||
|
if (configAttributeGroup == null) {
|
||||||
|
hasError = true;
|
||||||
|
errorString += " • [Attribute Group] can not be empty\n";
|
||||||
|
}
|
||||||
if (!upconfig.getGroups().stream().anyMatch(g -> g.getName().equals(configAttributeGroup))) {
|
if (!upconfig.getGroups().stream().anyMatch(g -> g.getName().equals(configAttributeGroup))) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
errorString += " • [Attribute Group] does not exist\n";
|
errorString += " • [Attribute Group] does not exist\n";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue