Skip to content

Commit

Permalink
DescriptorLoader: log typo fix, cleanup/reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Jun 2, 2021
1 parent 975d03e commit 1e80b05
Showing 1 changed file with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
/*
* Copyright (c) 2010-2019 Evolveum and contributors
* Copyright (C) 2010-2021 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.web.application;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.function.Consumer;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -62,6 +56,7 @@ public final class DescriptorLoader implements DebugDumpable {
"com.evolveum.midpoint.web.component.prism.show"
};

// All could be final, but then Checkstyle complains about lower-case, although these are not constants.
private static Map<String, DisplayableValue<String>[]> actions = new HashMap<>();
private static List<String> permitAllUrls = new ArrayList<>();
private static List<String> loginPages = new ArrayList<>();
Expand Down Expand Up @@ -94,18 +89,16 @@ public void loadData(MidPointApplication application) {
}
} catch (InstantiationException | IllegalAccessException e) {
LOGGER.error("Error scanning packages for pages: {}", e.getMessage(), e);
throw new SystemException("Error scanning packages for pages: "+e.getMessage(), e);
throw new SystemException("Error scanning packages for pages: " + e.getMessage(), e);
}



}

private void scanPackagesForPages(MidPointApplication application)
throws InstantiationException, IllegalAccessException {

for (String pac : PACKAGES_TO_SCAN) {
LOGGER.debug("Scanning package package {} for page annotations", pac);
LOGGER.debug("Scanning package {} for page annotations", pac);

Set<Class<?>> classes = ClassPathUtil.listClasses(pac);
for (Class<?> clazz : classes) {
Expand All @@ -126,7 +119,7 @@ private void scanPackagesForPages(MidPointApplication application)

private void loadActions(PageDescriptor descriptor) {

if(descriptor.loginPage()) {
if (descriptor.loginPage()) {
foreachUrl(descriptor, url -> loginPages.add(url));
}

Expand Down Expand Up @@ -154,13 +147,11 @@ private void loadActions(PageDescriptor descriptor) {

//add http://.../..#guiAll authorization only for displayable pages, not for pages used for development..
if (canAccess) {

// actions.add(new AuthorizationActionValue(AuthorizationConstants.AUTZ_GUI_ALL_LABEL, AuthorizationConstants.AUTZ_GUI_ALL_DESCRIPTION));
actions.add(new AuthorizationActionValue(AuthorizationConstants.AUTZ_GUI_ALL_URL,
AuthorizationConstants.AUTZ_GUI_ALL_LABEL, AuthorizationConstants.AUTZ_GUI_ALL_DESCRIPTION));
}

foreachUrl(descriptor, url -> this.actions.put(url, actions.toArray(new DisplayableValue[actions.size()])));
foreachUrl(descriptor, url -> DescriptorLoader.actions.put(url, actions.toArray(new DisplayableValue[actions.size()])));
}

private void foreachUrl(PageDescriptor descriptor, Consumer<String> urlConsumer) {
Expand Down

0 comments on commit 1e80b05

Please sign in to comment.