private static String getName(Restriction restriction) { return restriction.getDefinition().getName(); } }
@Override public boolean matches() { for (RestrictionPattern pattern : patterns) { if (!pattern.matches()) { return false; } } return true; } }
private static Map<String, RestrictionDefinition> supportedRestrictions() { RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, Type.STRING, false); RestrictionDefinition nts = new RestrictionDefinitionImpl(REP_NT_NAMES, Type.NAMES, false); RestrictionDefinition pfxs = new RestrictionDefinitionImpl(REP_PREFIXES, Type.STRINGS, false); RestrictionDefinition names = new RestrictionDefinitionImpl(REP_ITEM_NAMES, Type.NAMES, false); return ImmutableMap.of(glob.getName(), glob, nts.getName(), nts, pfxs.getName(), pfxs, names.getName(), names); }
@Test(expected = AccessControlException.class) public void testValidateRestrictionsWrongType() throws Exception { Tree aceTree = getAceTree(new RestrictionImpl(PropertyStates.createProperty(MANDATORY_BOOLEAN_RESTRICTION.getDefinition().getName(), "string"), true)); provider.validateRestrictions("/test", aceTree); }
@Override public void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction> restrictions) throws RepositoryException { Sets.newHashSet(restrictions).removeIf(r -> REP_NODE_PATH.equals(r.getDefinition().getName())); base.writeRestrictions(oakPath, aceTree, restrictions); }
@Test public void testReadRestrictions() { Tree aceTree = getAceTree(NT_PREFIXES_RESTRICTION, MANDATORY_BOOLEAN_RESTRICTION, UNKNOWN_RESTRICTION); Set<Restriction> restrictions = provider.readRestrictions("/test", aceTree); assertEquals(2, restrictions.size()); for (Restriction r : restrictions) { String name = r.getDefinition().getName(); if (!supported.contains(name)) { fail("read unsupported restriction"); } } }
@Override public void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction> restrictions) throws RepositoryException { for (Restriction r : restrictions) { RestrictionProvider rp = getProvider(oakPath, getName(r)); rp.writeRestrictions(oakPath, aceTree, Collections.singleton(r)); } }
@Before public void before() { PropertyState property = createProperty(name, value, type); restriction = new RestrictionImpl(property, isMandatory); }
@Test(expected = AccessControlException.class) public void testValidateRestrictionsMissingMandatory() throws Exception { Tree aceTree = getAceTree(GLOB_RESTRICTION); provider.validateRestrictions("/test", aceTree); }
private static String getName(Restriction restriction) { return restriction.getDefinition().getName(); } }
private static Map<String, RestrictionDefinition> supportedRestrictions() { RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, Type.STRING, false); RestrictionDefinition nts = new RestrictionDefinitionImpl(REP_NT_NAMES, Type.NAMES, false); RestrictionDefinition pfxs = new RestrictionDefinitionImpl(REP_PREFIXES, Type.STRINGS, false); RestrictionDefinition names = new RestrictionDefinitionImpl(REP_ITEM_NAMES, Type.NAMES, false); return ImmutableMap.of(glob.getName(), glob, nts.getName(), nts, pfxs.getName(), pfxs, names.getName(), names); }
@Override public void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction> restrictions) throws RepositoryException { for (Restriction r : restrictions) { RestrictionProvider rp = getProvider(oakPath, getName(r)); rp.writeRestrictions(oakPath, aceTree, Collections.singleton(r)); } }
@Override public boolean matches() { for (RestrictionPattern pattern : patterns) { if (!pattern.matches()) { return false; } } return true; } }
private String getJcrName(Restriction restriction) { return namePathMapper.getJcrName(restriction.getDefinition().getName()); } }
private static Map<String, RestrictionDefinition> supportedRestrictions() { RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, Type.STRING, false); RestrictionDefinition nts = new RestrictionDefinitionImpl(REP_NT_NAMES, Type.NAMES, false); RestrictionDefinition pfxs = new RestrictionDefinitionImpl(REP_PREFIXES, Type.STRINGS, false); RestrictionDefinition names = new RestrictionDefinitionImpl(REP_ITEM_NAMES, Type.NAMES, false); return ImmutableMap.of(glob.getName(), glob, nts.getName(), nts, pfxs.getName(), pfxs, names.getName(), names); }
boolean matches() { return restriction == RestrictionPattern.EMPTY || restriction.matches(); }
private String getJcrName(Restriction restriction) { return namePathMapper.getJcrName(restriction.getDefinition().getName()); } }
private static Map<String, RestrictionDefinition> supportedRestrictions() { RestrictionDefinition dates = new RestrictionDefinitionImpl(RESTRICTION_NAME, Type.STRING, false); return Collections.singletonMap(dates.getName(), dates); }
boolean matches() { return restriction == RestrictionPattern.EMPTY || restriction.matches(); }
boolean matches() { return restriction == RestrictionPattern.EMPTY || restriction.matches(); }