public static Set<Authorizable> getRestrictedComponentsAuthorizable(final Class<?> configurableComponentClass) { final Set<Authorizable> authorizables = new HashSet<>(); final Restricted restricted = configurableComponentClass.getAnnotation(Restricted.class); if (restricted != null) { final Restriction[] restrictions = restricted.restrictions(); if (restrictions != null && restrictions.length > 0) { Arrays.stream(restrictions).forEach(restriction -> authorizables.add(getRestrictedComponentsAuthorizable(restriction.requiredPermission()))); } else { authorizables.add(getRestrictedComponentsAuthorizable()); } } return authorizables; }
@Override protected void writeRestrictedInfo(final Restricted restricted) throws IOException { writeStartElement("restricted"); if (restricted != null) { writeTextElement("generalRestrictionExplanation", restricted.value()); final Restriction[] restrictions = restricted.restrictions(); if (restrictions != null) { writeArray("restrictions", Arrays.asList(restrictions), this::writeRestriction); } } writeEndElement(); }
final Restriction[] restrictions = restricted.restrictions(); if (restrictions != null && restrictions.length > 0) { xmlStreamWriter.writeStartElement("table");
private Set<ExplicitRestrictionDTO> getExplicitRestrictions(final Class<?> cls) { final Restricted restricted = cls.getAnnotation(Restricted.class); if (restricted == null) { return null; } final Restriction[] restrictions = restricted.restrictions(); if (restrictions == null || restrictions.length == 0) { return null; } return Arrays.stream(restrictions).map(restriction -> { final RequiredPermissionDTO requiredPermission = new RequiredPermissionDTO(); requiredPermission.setId(restriction.requiredPermission().getPermissionIdentifier()); requiredPermission.setLabel(restriction.requiredPermission().getPermissionLabel()); final ExplicitRestrictionDTO usageRestriction = new ExplicitRestrictionDTO(); usageRestriction.setRequiredPermission(requiredPermission); usageRestriction.setExplanation(restriction.explanation()); return usageRestriction; }).collect(Collectors.toSet()); }