Search in sources :

Example 1 with ScreenPolicy

use of io.jmix.securityui.role.annotation.ScreenPolicy in project jmix by jmix-framework.

the class ScreenPolicyExtractor method extractResourcePolicies.

@Override
public Collection<ResourcePolicy> extractResourcePolicies(Method method) {
    Set<ResourcePolicy> resourcePolicies = new HashSet<>();
    Set<ScreenPolicy> annotations = AnnotatedElementUtils.findMergedRepeatableAnnotations(method, ScreenPolicy.class, ScreenPolicyContainer.class);
    for (ScreenPolicy screenPolicyAnnotation : annotations) {
        for (String screenId : screenPolicyAnnotation.screenIds()) {
            ResourcePolicy resourcePolicy = ResourcePolicy.builder(ResourcePolicyType.SCREEN, screenId).withPolicyGroup(method.getName()).build();
            resourcePolicies.add(resourcePolicy);
        }
        for (Class screenClass : screenPolicyAnnotation.screenClasses()) {
            UiController uiControllerAnnotation = (UiController) screenClass.getAnnotation(UiController.class);
            String screenId = uiControllerAnnotation.value();
            ResourcePolicy resourcePolicy = ResourcePolicy.builder(ResourcePolicyType.SCREEN, screenId).withPolicyGroup(method.getName()).build();
            resourcePolicies.add(resourcePolicy);
        }
    }
    return resourcePolicies;
}
Also used : ResourcePolicy(io.jmix.security.model.ResourcePolicy) UiController(io.jmix.ui.screen.UiController) ScreenPolicy(io.jmix.securityui.role.annotation.ScreenPolicy) HashSet(java.util.HashSet)

Aggregations

ResourcePolicy (io.jmix.security.model.ResourcePolicy)1 ScreenPolicy (io.jmix.securityui.role.annotation.ScreenPolicy)1 UiController (io.jmix.ui.screen.UiController)1 HashSet (java.util.HashSet)1