@Test public void getPathBasedAceMapUsingNaturalOrderedSetTest() { Map<String, Set<AceBean>> groupBasedAceMap = new LinkedHashMap<String, Set<AceBean>>(); Map<String, Set<AceBean>> expectedPathBasedAceMap = new LinkedHashMap<String, Set<AceBean>>(); groupBasedAceMap.put("group-A", new LinkedHashSet<AceBean>()); groupBasedAceMap.get("group-A").add(aceBeanGroupA_1_content_deny); groupBasedAceMap.get("group-A").add(aceBeanGroupA_2_content_allow); groupBasedAceMap.get("group-A").add(aceBeanGroupA_3_contentisp_deny); groupBasedAceMap.put("group-B", new LinkedHashSet<AceBean>()); groupBasedAceMap.get("group-B").add(aceBeanGroupB_1_content_allow); groupBasedAceMap.get("group-B").add(aceBeanGroupB_2_content_deny); groupBasedAceMap.get("group-B").add(aceBeanGroupB_3_contentisp_allow); groupBasedAceMap.put("group-C", new LinkedHashSet<AceBean>()); groupBasedAceMap.get("group-C").add(aceBeanGroupC_1_content_allow); expectedPathBasedAceMap.put("/content", new LinkedHashSet<AceBean>()); expectedPathBasedAceMap.get("/content").add(aceBeanGroupA_1_content_deny); expectedPathBasedAceMap.get("/content").add(aceBeanGroupA_2_content_allow); expectedPathBasedAceMap.get("/content").add(aceBeanGroupB_1_content_allow); expectedPathBasedAceMap.get("/content").add(aceBeanGroupB_2_content_deny); expectedPathBasedAceMap.get("/content").add(aceBeanGroupC_1_content_allow); expectedPathBasedAceMap.put("/content/isp", new LinkedHashSet<AceBean>()); expectedPathBasedAceMap.get("/content/isp").add(aceBeanGroupA_3_contentisp_deny); expectedPathBasedAceMap.get("/content/isp").add(aceBeanGroupB_3_contentisp_allow); Map<String, Set<AceBean>> actualResult = AcHelper.getPathBasedAceMap(groupBasedAceMap, ACE_ORDER_NONE); assertEqualStructures(expectedPathBasedAceMap, actualResult); }
public static Map<String, Set<AceBean>> getPathBasedAceMap(Set<AceBean> aceBeansFromConfig, int sorting) { final Map<String, Set<AceBean>> pathBasedAceMap = new TreeMap<String, Set<AceBean>>(); for (final AceBean bean : aceBeansFromConfig) { if (pathBasedAceMap.get(bean.getJcrPath()) == null) { Set<AceBean> aceSet = null; if (sorting == AcHelper.ACE_ORDER_NONE) { aceSet = new LinkedHashSet<AceBean>(); } else if (sorting == AcHelper.ACE_ORDER_ACTOOL_BEST_PRACTICE) { aceSet = new TreeSet<AceBean>(new AcePermissionComparator()); } aceSet.add(bean); pathBasedAceMap.put(bean.getJcrPath(), aceSet); } else { pathBasedAceMap.get(bean.getJcrPath()).add(bean); } } return pathBasedAceMap; }
AcHelper { public static Map<String, Set<AceBean>> getPathBasedAceMap(Set<AceBean> aceBeansFromConfig, int sorting) { final Map<String, Set<AceBean>> pathBasedAceMap = new TreeMap<String, Set<AceBean>>(); for (final AceBean bean : aceBeansFromConfig) { if (pathBasedAceMap.get(bean.getJcrPath()) == null) { Set<AceBean> aceSet = null; if (sorting == AcHelper.ACE_ORDER_NONE) { aceSet = new LinkedHashSet<AceBean>(); } else if (sorting == AcHelper.ACE_ORDER_ACTOOL_BEST_PRACTICE) { aceSet = new TreeSet<AceBean>(new AcePermissionComparator()); } aceSet.add(bean); pathBasedAceMap.put(bean.getJcrPath(), aceSet); } else { pathBasedAceMap.get(bean.getJcrPath()).add(bean); } } return pathBasedAceMap; } }
AcHelper { public static Map<String, Set<AceBean>> getPathBasedAceMap(Set<AceBean> aceBeansFromConfig, int sorting) { final Map<String, Set<AceBean>> pathBasedAceMap = new TreeMap<String, Set<AceBean>>(); for (final AceBean bean : aceBeansFromConfig) { if (pathBasedAceMap.get(bean.getJcrPath()) == null) { Set<AceBean> aceSet = null; if (sorting == AcHelper.ACE_ORDER_NONE) { aceSet = new LinkedHashSet<AceBean>(); } else if (sorting == AcHelper.ACE_ORDER_ACTOOL_BEST_PRACTICE) { aceSet = new TreeSet<AceBean>(new AcePermissionComparator()); } aceSet.add(bean); pathBasedAceMap.put(bean.getJcrPath(), aceSet); } else { pathBasedAceMap.get(bean.getJcrPath()).add(bean); } } return pathBasedAceMap; } private  AcHelper(); }
AcHelper { public static Map<String, Set<AceBean>> getPathBasedAceMap(Set<AceBean> aceBeansFromConfig, int sorting) { final Map<String, Set<AceBean>> pathBasedAceMap = new TreeMap<String, Set<AceBean>>(); for (final AceBean bean : aceBeansFromConfig) { if (pathBasedAceMap.get(bean.getJcrPath()) == null) { Set<AceBean> aceSet = null; if (sorting == AcHelper.ACE_ORDER_NONE) { aceSet = new LinkedHashSet<AceBean>(); } else if (sorting == AcHelper.ACE_ORDER_ACTOOL_BEST_PRACTICE) { aceSet = new TreeSet<AceBean>(new AcePermissionComparator()); } aceSet.add(bean); pathBasedAceMap.put(bean.getJcrPath(), aceSet); } else { pathBasedAceMap.get(bean.getJcrPath()).add(bean); } } return pathBasedAceMap; } private  AcHelper(); static AceBean getAceBean(AccessControlEntry ace, AccessControlList acl); static AceBean getAceBean(final AceWrapper ace); static String getBlankString(final int nrOfBlanks); static Map<String, Set<AceBean>> getPathBasedAceMap(Set<AceBean> aceBeansFromConfig, int sorting); static Map<String, Set<AceBean>> getPathBasedAceMap(
            final Map<String, Set<AceBean>> groupBasedAceMap, final int sorting); static String valuesToString(Value[] propertyValues); }
AcHelper { public static Map<String, Set<AceBean>> getPathBasedAceMap(Set<AceBean> aceBeansFromConfig, int sorting) { final Map<String, Set<AceBean>> pathBasedAceMap = new TreeMap<String, Set<AceBean>>(); for (final AceBean bean : aceBeansFromConfig) { if (pathBasedAceMap.get(bean.getJcrPath()) == null) { Set<AceBean> aceSet = null; if (sorting == AcHelper.ACE_ORDER_NONE) { aceSet = new LinkedHashSet<AceBean>(); } else if (sorting == AcHelper.ACE_ORDER_ACTOOL_BEST_PRACTICE) { aceSet = new TreeSet<AceBean>(new AcePermissionComparator()); } aceSet.add(bean); pathBasedAceMap.put(bean.getJcrPath(), aceSet); } else { pathBasedAceMap.get(bean.getJcrPath()).add(bean); } } return pathBasedAceMap; } private  AcHelper(); static AceBean getAceBean(AccessControlEntry ace, AccessControlList acl); static AceBean getAceBean(final AceWrapper ace); static String getBlankString(final int nrOfBlanks); static Map<String, Set<AceBean>> getPathBasedAceMap(Set<AceBean> aceBeansFromConfig, int sorting); static Map<String, Set<AceBean>> getPathBasedAceMap(
            final Map<String, Set<AceBean>> groupBasedAceMap, final int sorting); static String valuesToString(Value[] propertyValues); static final Logger LOG; static int ACE_ORDER_ACTOOL_BEST_PRACTICE; static int ACE_ORDER_NONE; static int ACE_ORDER_ALPHABETICAL; static int PRINCIPAL_BASED_ORDER; static int PATH_BASED_ORDER; }