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); }
@NotNull @Override public Set<RestrictionDefinition> getSupportedRestrictions(@Nullable String oakPath) { Set<RestrictionDefinition> definitions = new HashSet<>(base.getSupportedRestrictions(oakPath)); definitions.add(new RestrictionDefinitionImpl(REP_NODE_PATH, Type.PATH, true)); return definitions; }
@NotNull @Override public Set<RestrictionDefinition> getSupportedRestrictions(@Nullable String oakPath) { Set<RestrictionDefinition> definitions = new HashSet<>(base.getSupportedRestrictions(oakPath)); definitions.add(new RestrictionDefinitionImpl(REP_NODE_PATH, Type.PATH, true)); return definitions; }
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); }
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); }
@Nonnull @Override public Set<RestrictionDefinition> getSupportedRestrictions(@Nullable String oakPath) { Set<RestrictionDefinition> definitions = new HashSet<RestrictionDefinition>(base.getSupportedRestrictions(oakPath)); definitions.add(new RestrictionDefinitionImpl(REP_NODE_PATH, Type.PATH, true)); return definitions; }
@NotNull @Override public RestrictionDefinition getDefinition() { return new RestrictionDefinitionImpl(name, type, isMandatory); }
@NotNull @Override public RestrictionDefinition getDefinition() { return new RestrictionDefinitionImpl(name, type, isMandatory); }
public RestrictionImpl(@NotNull PropertyState property, boolean isMandatory) { this.definition = new RestrictionDefinitionImpl(property.getName(), property.getType(), isMandatory); this.property = property; }
public RestrictionImpl(@Nonnull PropertyState property, boolean isMandatory) { this.definition = new RestrictionDefinitionImpl(property.getName(), property.getType(), isMandatory); this.property = property; }
private TestRestrictionProvider(String name, Type type, boolean isMandatory) { super(Collections.singletonMap(name, new RestrictionDefinitionImpl(name, type, isMandatory))); }
protected RestrictionProvider getRestrictionProvider() { Map<String, RestrictionDefinition> rDefs = new HashMap<>(); rDefs.put("r1", new RestrictionDefinitionImpl("r1", Type.STRING, true)); rDefs.put("r2", new RestrictionDefinitionImpl("r2", Type.LONGS, false)); return new AbstractRestrictionProvider(rDefs) { @NotNull @Override public RestrictionPattern getPattern(@Nullable String oakPath, @NotNull Tree tree) { throw new UnsupportedOperationException(); } @NotNull @Override public RestrictionPattern getPattern(@Nullable String oakPath, @NotNull Set<Restriction> restrictions) { throw new UnsupportedOperationException(); } }; }
@Before public void before() { name = "test:defName"; definition = new RestrictionDefinitionImpl(name, Type.NAME, true); }
private static Map<String, RestrictionDefinition> supportedRestrictions() { RestrictionDefinition dates = new RestrictionDefinitionImpl(RESTRICTION_NAME, Type.STRING, false); return Collections.singletonMap(dates.getName(), dates); }
@Test public void testInvalid() { try { new RestrictionDefinitionImpl(null, Type.BOOLEAN, false); fail("Creating RestrictionDefinition with null name should fail."); } catch (NullPointerException e) { // success } try { new RestrictionDefinitionImpl(name, Type.UNDEFINED, false); fail("Creating RestrictionDefinition with undefined required type should fail."); } catch (IllegalArgumentException e) { // success } }
@Test public void testEquals() { // same definition assertEquals(definition, new RestrictionDefinitionImpl(name, Type.NAME, true)); }
@NotNull @Override public Set<Restriction> readRestrictions(String oakPath, @NotNull Tree aceTree) { if (nonValidatingRead) { Set<Restriction> restrictions = new HashSet(); for (PropertyState propertyState : getRestrictionsTree(aceTree).getProperties()) { String name = propertyState.getName(); if (!JcrConstants.JCR_PRIMARYTYPE.equals(name)) { restrictions.add(new RestrictionImpl(propertyState, new RestrictionDefinitionImpl(name, propertyState.getType(), false))); } } return restrictions; } else { return super.readRestrictions(oakPath, aceTree); } }
@Test public void testGetDefinition() { assertEquals(new RestrictionDefinitionImpl(name, type, isMandatory), restriction.getDefinition()); }
@Before public void before() throws Exception { valueFactory = new PartialValueFactory(namePathMapper); globValue = valueFactory.createValue("*"); nameValue = valueFactory.createValue("nt:file", PropertyType.NAME); nameValues = new Value[] { valueFactory.createValue("nt:folder", PropertyType.NAME), valueFactory.createValue("nt:file", PropertyType.NAME) }; RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, Type.STRING, false); RestrictionDefinition nts = new RestrictionDefinitionImpl(REP_NT_NAMES, Type.NAMES, false); RestrictionDefinition mand = new RestrictionDefinitionImpl("mandatory", Type.BOOLEAN, true); supported = ImmutableMap.of(glob.getName(), glob, nts.getName(), nts, mand.getName(), mand); restrictionProvider = new AbstractRestrictionProvider(supported) { @NotNull @Override public RestrictionPattern getPattern(@Nullable String oakPath, @NotNull Tree tree) { throw new UnsupportedOperationException(); } @NotNull @Override public RestrictionPattern getPattern(@Nullable String oakPath, @NotNull Set<Restriction> restrictions) { throw new UnsupportedOperationException(); } }; }
@Before @Override public void before() throws Exception { super.before(); valueFactory = new ValueFactoryImpl(root, namePathMapper); globValue = valueFactory.createValue("*"); nameValue = valueFactory.createValue("nt:file", PropertyType.NAME); nameValues = new Value[] { valueFactory.createValue("nt:folder", PropertyType.NAME), valueFactory.createValue("nt:file", PropertyType.NAME) }; RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, Type.STRING, false); RestrictionDefinition nts = new RestrictionDefinitionImpl(REP_NT_NAMES, Type.NAMES, false); RestrictionDefinition mand = new RestrictionDefinitionImpl("mandatory", Type.BOOLEAN, true); supported = ImmutableMap.of(glob.getName(), glob, nts.getName(), nts, mand.getName(), mand); restrictionProvider = new TestProvider(supported); }