Skip to content

Commit

Permalink
fix: handle proprety being null
Browse files Browse the repository at this point in the history
  • Loading branch information
cleydyr committed May 26, 2024
1 parent 0dde8ba commit 6add0f8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@
@Setter
public class MenuPropertiesService {
private Collection<String> disabled;

public boolean isEnabled(String item) {
if (disabled == null) {
return true;
}

return !disabled.contains(item);
}
}
4 changes: 1 addition & 3 deletions src/main/java/biblivre/login/MenuProviderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ public Map<String, List<String>> getAllowedModules(Predicate<String> filter) {
String item = obj.toString();

if (filter.test(item)
&& !menuPropertiesService
.getDisabled()
.contains(item)) {
&& menuPropertiesService.isEnabled(item)) {
allowedModules
.computeIfAbsent(name, __ -> new ArrayList<>())
.add(item);
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/biblivre/menu/Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,13 @@ public void administrationReports(ExtendedRequest request, ExtendedResponse resp
}

public void administrationCustomReports(ExtendedRequest request, ExtendedResponse response) {
if (menuPropertiesService.getDisabled().contains("administration_custom_reports")) {
throw new IllegalArgumentException("Custom reports are not enabled.");
if (menuPropertiesService.isEnabled("administration_custom_reports")) {
setJspURL("/WEB-INF/jsp/administration/custom_reports.jsp");

return;
}

setJspURL("/WEB-INF/jsp/administration/custom_reports.jsp");
throw new IllegalArgumentException("Custom reports are not enabled.");
}

public void administrationUserTypes(ExtendedRequest request, ExtendedResponse response) {
Expand Down

0 comments on commit 6add0f8

Please sign in to comment.