/** {@inheritDoc} */ public boolean canSetProperty(String name, Value value) throws RemoteException { return type.canSetProperty(name, value); }
/** {@inheritDoc} */ public boolean canSetProperty(String name, Value[] values) throws RemoteException { return type.canSetProperty(name, values); }
Workspace workspace = session.getWorkspace(); NodeTypeManager ntMgr = wsp.getNodeTypeManager(); NodeType nt = ntMgr.getNodeType("nodeTypeName"); boolean canSet = nt.canSetProperty("propName", value);
@Override public void checkSetProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } NodeType nt = definition.getDeclaringNodeType(); if (definition.isMultiple()) { List<Value> values = valueFactory.createValues(property); if (!nt.canSetProperty(property.getName(), values.toArray(new Value[values.size()]))) { throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + values + '\''); } } else { Value v = valueFactory.createValue(property); if (!nt.canSetProperty(property.getName(), v)) { throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + v + '\''); } } }
@Override public void checkSetProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } NodeType nt = definition.getDeclaringNodeType(); if (definition.isMultiple()) { List<Value> values = valueFactory.createValues(property); if (!nt.canSetProperty(property.getName(), values.toArray(new Value[values.size()]))) { throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + values + '\''); } } else { Value v = valueFactory.createValue(property); if (!nt.canSetProperty(property.getName(), v)) { throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + v + '\''); } } }
@Override public void checkSetProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } NodeType nt = definition.getDeclaringNodeType(); if (definition.isMultiple()) { List<Value> values = ValueFactoryImpl.createValues(property, ntMgr.getNamePathMapper()); if (!nt.canSetProperty(property.getName(), values.toArray(new Value[values.size()]))) { throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + values + '\''); } } else { Value v = ValueFactoryImpl.createValue(property, ntMgr.getNamePathMapper()); if (!nt.canSetProperty(property.getName(), v)) { throw new ConstraintViolationException("Cannot set property '" + property.getName() + "' to '" + v + '\''); } } }
@Override protected void setUp() throws Exception { super.setUp(); if (testRootNode.hasProperty(propertyName1)) { testRootNode.getProperty(propertyName1).remove(); testRootNode.save(); } testValue = testRootNode.getSession().getValueFactory().createValue("anyString"); if (!testRootNode.getPrimaryNodeType().canSetProperty(propertyName1, testValue)) { throw new NotExecutableException(""); } }
/** * Tests if canSetProperty(String propertyName, Value value) where value is * null returns the same as canRemoveItem */ public void testValueNull() throws NotExecutableException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, false, false, false, false); if (propDef == null) { throw new NotExecutableException("No not protected property def found."); } NodeType nodeType = propDef.getDeclaringNodeType(); assertEquals("nodeType.canSetProperty(String propertyName, Value value) " + "where value is null must return the same result as " + "nodeType.canRemoveItem(String propertyName).", nodeType.canRemoveItem(propDef.getName()), nodeType.canSetProperty(propDef.getName(), (Value) null)); }
/** * Tests if NodeType.canSetProperty(String propertyName, Value[] values) * returns false if the property is not multiple */ public void testReturnFalseBecauseIsNotMultiple() throws NotExecutableException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, false, false, false, false); if (propDef == null) { throw new NotExecutableException("No not multiple, not protected property def found"); } NodeType nodeType = propDef.getDeclaringNodeType(); Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType()); Value values[] = new Value[] {value}; assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if the property is not multiple", nodeType.canSetProperty(propDef.getName(), values)); }
/** * Tests if NodeType.canSetProperty(String propertyName, Value value) * returns false if the property is multiple */ public void testReturnFalseBecauseIsMultiple() throws NotExecutableException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, true, false, false, false); if (propDef == null) { throw new NotExecutableException("No multiple, not protected property def found."); } NodeType nodeType = propDef.getDeclaringNodeType(); Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType()); assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if the property is multiple.", nodeType.canSetProperty(propDef.getName(), value)); }
@Override protected void setUp() throws Exception { super.setUp(); testValue = testRootNode.getSession().getValueFactory().createValue("anyString"); if (!testRootNode.getPrimaryNodeType().canSetProperty(propertyName1, testValue)) { throw new NotExecutableException(""); } }
/** * Tests if canSetProperty(String propertyName, Value[] values) where values * is null returns the same as canRemoveItem */ public void testMultipleValuesNull() throws NotExecutableException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, true, false, false, false); if (propDef == null) { throw new NotExecutableException("No not protected, multiple property def found"); } NodeType nodeType = propDef.getDeclaringNodeType(); assertEquals("nodeType.canSetProperty(String propertyName, Value[] values) " + "where values is null must return the same result as " + "nodeType.canRemoveItem(String propertyName)", nodeType.canRemoveItem(propDef.getName()), nodeType.canSetProperty(propDef.getName(), (Value[]) null)); }
/** * Tests if NodeType.canSetProperty(String propertyName, Value value) * returns false if the property is protected. */ public void testReturnFalseBecauseIsProtected() throws NotExecutableException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, false, true, false, false); // will never happen since at least jcr:primaryType of nt:base accomplish the request if (propDef == null) { throw new NotExecutableException("No protected property def found."); } NodeType nodeType = propDef.getDeclaringNodeType(); Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType()); assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if the property is protected.", nodeType.canSetProperty(propDef.getName(), value)); }
/** * Tests if canSetProperty(String propertyName, Value value) returns false * if value does not satisfy the value constraints of the property def */ public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.PATH, false, false, true, false); if (propDef == null) { throw new NotExecutableException("No path property def with " + "testable value constraints has been found"); } Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false); if (value == null) { throw new NotExecutableException("No path property def with " + "testable value constraints has been found"); } NodeType nodeType = propDef.getDeclaringNodeType(); assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value)); }
/** * Tests if NodeType.canSetProperty(String propertyName, Value[] values) * returns false if the property is protected. */ public void testReturnFalseBecauseIsProtected() throws NotExecutableException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, NodeTypeUtil.ANY_PROPERTY_TYPE, true, true, false, false); // will never happen since at least jcr:mixinTypes of nt:base accomplish the request if (propDef == null) { throw new NotExecutableException("No protected, multiple property def found"); } NodeType nodeType = propDef.getDeclaringNodeType(); Value value = NodeTypeUtil.getValueOfType(superuser, propDef.getRequiredType()); Value values[] = new Value[] {value, value}; assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return true if the property is protected.", nodeType.canSetProperty(propDef.getName(), values)); }
/** * Tests if canSetProperty(String propertyName, Value value) returns false * if value does not satisfy the value constraints of the property def */ public void testValueConstraintNotSatisfied() throws NotExecutableException, ParseException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, false, false, true, false); if (propDef == null) { throw new NotExecutableException("No binary property def with " + "testable value constraints has been found"); } Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false); if (value == null) { throw new NotExecutableException("No binary property def with " + "testable value constraints has been found"); } NodeType nodeType = propDef.getDeclaringNodeType(); assertFalse("canSetProperty(String propertyName, Value value) must " + "return false if value does not match the value constraints.", nodeType.canSetProperty(propDef.getName(), value)); }
/** * Tests if canSetProperty(String propertyName, Value[] values) returns * false if values do not satisfy the value constraints of the property def */ public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.STRING, true, false, true, false); if (propDef == null) { throw new NotExecutableException("No multiple string property def with " + "testable value constraints has been found"); } Value value = NodeTypeUtil.getValueAccordingToValueConstraints(superuser, propDef, false); if (value == null) { throw new NotExecutableException("No multiple string property def with " + "testable value constraints has been found"); } NodeType nodeType = propDef.getDeclaringNodeType(); Value values[] = new Value[] {value}; assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values)); }
/** * Tests if canSetProperty(String propertyName, Value[] values) returns * false if values do not satisfy the value constraints of the property def */ public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.BINARY, true, false, true, false); if (propDef == null) { throw new NotExecutableException("No multiple binary property def with " + "testable value constraints has been found"); } Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false); if (value == null) { throw new NotExecutableException("No multiple binary property def with " + "testable value constraints has been found"); } NodeType nodeType = propDef.getDeclaringNodeType(); Value values[] = new Value[] {value}; assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values)); }
/** * Tests if canSetProperty(String propertyName, Value[] values) returns * false if values do not satisfy the value constraints of the property def */ public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.BOOLEAN, true, false, true, false); if (propDef == null) { throw new NotExecutableException("No multiple boolean property def with " + "testable value constraints has been found"); } Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false); if (value == null) { throw new NotExecutableException("No multiple boolean property def with " + "testable value constraints has been found"); } NodeType nodeType = propDef.getDeclaringNodeType(); Value values[] = new Value[] {value}; assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values)); } }
/** * Tests if canSetProperty(String propertyName, Value[] values) returns * false if values do not satisfy the value constraints of the property def */ public void testValueConstraintNotSatisfiedMultiple() throws NotExecutableException, ParseException, RepositoryException { PropertyDefinition propDef = NodeTypeUtil.locatePropertyDef(session, PropertyType.DOUBLE, true, false, true, false); if (propDef == null) { throw new NotExecutableException("No multiple double property def with " + "testable value constraints has been found"); } Value value = NodeTypeUtil.getValueAccordingToValueConstraints(session, propDef, false); if (value == null) { throw new NotExecutableException("No multiple double property def with " + "testable value constraints has been found"); } NodeType nodeType = propDef.getDeclaringNodeType(); Value values[] = new Value[] {value}; assertFalse("canSetProperty(String propertyName, Value[] values) must " + "return false if values do not match the value constraints.", nodeType.canSetProperty(propDef.getName(), values)); } }