/** {@inheritDoc} */ public String[] getValueConstraints() throws RemoteException { return def.getValueConstraints(); }
public PropertyDefinitionValue(PropertyDefinition propertyDefinition) throws RepositoryException { super(propertyDefinition); this.defaultValueStrings = convert(propertyDefinition.getDefaultValues()); this.multiple = propertyDefinition.isMultiple(); this.requiredType = propertyDefinition.getRequiredType(); this.valueConstraints = propertyDefinition.getValueConstraints() != null ? Arrays.asList(propertyDefinition.getValueConstraints()) : new ArrayList<String>();; }
private void processPropertyDefinition( Node nodeTypeNode, PropertyDefinition propertyDefinition ) throws RepositoryException { Node propertyDefinitionNode = nodeTypeNode.addNode(PROPERTY_DEFINITION, PROPERTY_DEFINITION); if (!RESIDUAL_ITEM_NAME.equals(propertyDefinition.getName())) { propertyDefinitionNode.setProperty(NAME, propertyDefinition.getName()); } propertyDefinitionNode.setProperty(AUTO_CREATED, propertyDefinition.isAutoCreated()); propertyDefinitionNode.setProperty(MANDATORY, propertyDefinition.isMandatory()); propertyDefinitionNode.setProperty(MULTIPLE, propertyDefinition.isMultiple()); propertyDefinitionNode.setProperty(PROTECTED, propertyDefinition.isProtected()); propertyDefinitionNode.setProperty(ON_PARENT_VERSION, OnParentVersionAction.nameFromValue(propertyDefinition.getOnParentVersion())); propertyDefinitionNode.setProperty(REQUIRED_TYPE, org.modeshape.jcr.api.PropertyType.nameFromValue(propertyDefinition.getRequiredType()) .toUpperCase()); String[] availableQueryOperators = propertyDefinition.getAvailableQueryOperators(); propertyDefinitionNode.setProperty(AVAILABLE_QUERY_OPERATORS, availableQueryOperators != null ? availableQueryOperators : new String[0]); Value[] defaultValues = propertyDefinition.getDefaultValues(); propertyDefinitionNode.setProperty(DEFAULT_VALUES, defaultValues != null ? defaultValues : new Value[0]); String[] valueConstraints = propertyDefinition.getValueConstraints(); propertyDefinitionNode.setProperty(VALUE_CONSTRAINTS, valueConstraints != null ? valueConstraints : new String[0]); propertyDefinitionNode.setProperty(IS_FULL_TEXT_SEARCHABLE, propertyDefinition.isFullTextSearchable()); propertyDefinitionNode.setProperty(IS_QUERY_ORDERABLE, propertyDefinition.isQueryOrderable()); }
private void processPropertyDefinition( Node nodeTypeNode, PropertyDefinition propertyDefinition ) throws RepositoryException { Node propertyDefinitionNode = nodeTypeNode.addNode(PROPERTY_DEFINITION, PROPERTY_DEFINITION); if (!RESIDUAL_ITEM_NAME.equals(propertyDefinition.getName())) { propertyDefinitionNode.setProperty(NAME, propertyDefinition.getName()); } propertyDefinitionNode.setProperty(AUTO_CREATED, propertyDefinition.isAutoCreated()); propertyDefinitionNode.setProperty(MANDATORY, propertyDefinition.isMandatory()); propertyDefinitionNode.setProperty(MULTIPLE, propertyDefinition.isMultiple()); propertyDefinitionNode.setProperty(PROTECTED, propertyDefinition.isProtected()); propertyDefinitionNode.setProperty(ON_PARENT_VERSION, OnParentVersionAction.nameFromValue(propertyDefinition.getOnParentVersion())); propertyDefinitionNode.setProperty(REQUIRED_TYPE, org.modeshape.jcr.api.PropertyType.nameFromValue(propertyDefinition.getRequiredType()) .toUpperCase()); String[] availableQueryOperators = propertyDefinition.getAvailableQueryOperators(); propertyDefinitionNode.setProperty(AVAILABLE_QUERY_OPERATORS, availableQueryOperators != null ? availableQueryOperators : new String[0]); Value[] defaultValues = propertyDefinition.getDefaultValues(); propertyDefinitionNode.setProperty(DEFAULT_VALUES, defaultValues != null ? defaultValues : new Value[0]); String[] valueConstraints = propertyDefinition.getValueConstraints(); propertyDefinitionNode.setProperty(VALUE_CONSTRAINTS, valueConstraints != null ? valueConstraints : new String[0]); propertyDefinitionNode.setProperty(IS_FULL_TEXT_SEARCHABLE, propertyDefinition.isFullTextSearchable()); propertyDefinitionNode.setProperty(IS_QUERY_ORDERABLE, propertyDefinition.isQueryOrderable()); }
private PropertyDefinitionImpl(PropertyDefinition definition) { super(definition); type = definition.getRequiredType(); valueConstraints = definition.getValueConstraints(); defaultValues = definition.getDefaultValues(); isMultiple = definition.isMultiple(); availableQueryOperators = definition.getAvailableQueryOperators(); isFullTextSearchable = definition.isFullTextSearchable(); isQueryOrderable = definition.isQueryOrderable(); }
private void checkConstraints( NodeType nodeType, Name propertyName, String[] expectedConstraints ) { PropertyDefinition propertyDefs[] = nodeType.getPropertyDefinitions(); String property = propertyName.getString(context.getNamespaceRegistry()); String[] constraints = null; for (int i = 0; i < propertyDefs.length; i++) { if (propertyDefs[i].getName().equals(property)) { constraints = propertyDefs[i].getValueConstraints(); break; } } if (!Arrays.equals(constraints, expectedConstraints)) { throw new IllegalStateException("Unexpected constraints for property: " + property); } }
@Override public boolean canSetProperty(String propertyName, Value value) { if (value == null) { return canRemoveProperty(propertyName); } try { EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, false, value.getType(), false); return !def.isProtected() && meetsTypeConstraints(value, def.getRequiredType()) && meetsValueConstraints(value, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
@Override public boolean canSetProperty(String propertyName, Value[] values) { if (values == null) { return canRemoveProperty(propertyName); } try { int type = (values.length == 0) ? PropertyType.STRING : values[0].getType(); EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, true, type, false); return !def.isProtected() && meetsTypeConstraints(values, def.getRequiredType()) && meetsValueConstraints(values, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
/** * Package private constructor * * @param def * @param resolver * @throws javax.jcr.nodetype.ConstraintViolationException */ PropertyDefinitionTemplateImpl(PropertyDefinition def, NamePathResolver resolver) throws ConstraintViolationException { super(def, resolver); type = def.getRequiredType(); defaultValues = def.getDefaultValues(); multiple = def.isMultiple(); fullTextSearchable = def.isFullTextSearchable(); queryOrderable = def.isQueryOrderable(); queryOperators = def.getAvailableQueryOperators(); setValueConstraints(def.getValueConstraints()); }
/** * Package private constructor * * @param def * @param resolver * @throws javax.jcr.nodetype.ConstraintViolationException */ PropertyDefinitionTemplateImpl(PropertyDefinition def, NamePathResolver resolver) throws ConstraintViolationException { super(def, resolver); type = def.getRequiredType(); defaultValues = def.getDefaultValues(); multiple = def.isMultiple(); fullTextSearchable = def.isFullTextSearchable(); queryOrderable = def.isQueryOrderable(); queryOperators = def.getAvailableQueryOperators(); setValueConstraints(def.getValueConstraints()); }
@Override public boolean canSetProperty(String propertyName, Value value) { if (value == null) { return canRemoveProperty(propertyName); } try { EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, false, value.getType(), false); return !def.isProtected() && meetsTypeConstraints(value, def.getRequiredType()) && meetsValueConstraints(value, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
@Override public boolean canSetProperty(String propertyName, Value[] values) { if (values == null) { return canRemoveProperty(propertyName); } try { int type = (values.length == 0) ? PropertyType.STRING : values[0].getType(); EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, true, type, false); return !def.isProtected() && meetsTypeConstraints(values, def.getRequiredType()) && meetsValueConstraints(values, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
@Override public boolean canSetProperty(String propertyName, Value value) { if (value == null) { return canRemoveProperty(propertyName); } try { EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, false, value.getType(), false); return !def.isProtected() && meetsTypeConstraints(value, def.getRequiredType()) && meetsValueConstraints(value, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
@Override public boolean canSetProperty(String propertyName, Value[] values) { if (values == null) { return canRemoveProperty(propertyName); } try { int type = (values.length == 0) ? PropertyType.STRING : values[0].getType(); EffectiveNodeTypeImpl effective = new EffectiveNodeTypeImpl(this, getManager()); PropertyDefinition def = effective.getPropertyDefinition( propertyName, true, type, false); return !def.isProtected() && meetsTypeConstraints(values, def.getRequiredType()) && meetsValueConstraints(values, def.getValueConstraints()); } catch (RepositoryException e) { // TODO don't use exceptions for flow control. Use internal method in ReadOnlyNodeTypeManager instead. log.debug(e.getMessage()); return false; } }
PropertyDefinitionTemplateImpl( NameMapper mapper, PropertyDefinition definition) throws ConstraintViolationException { super(mapper, definition); setRequiredType(definition.getRequiredType()); setMultiple(definition.isMultiple()); setFullTextSearchable(definition.isFullTextSearchable()); setQueryOrderable(definition.isQueryOrderable()); setAvailableQueryOperators(definition.getAvailableQueryOperators()); setValueConstraints(definition.getValueConstraints()); setDefaultValues(definition.getDefaultValues()); }
PropertyDefinitionTemplateImpl( NameMapper mapper, PropertyDefinition definition) throws ConstraintViolationException { super(mapper, definition); setRequiredType(definition.getRequiredType()); setMultiple(definition.isMultiple()); setFullTextSearchable(definition.isFullTextSearchable()); setQueryOrderable(definition.isQueryOrderable()); setAvailableQueryOperators(definition.getAvailableQueryOperators()); setValueConstraints(definition.getValueConstraints()); setDefaultValues(definition.getDefaultValues()); }
PropertyDefinitionTemplateImpl( NameMapper mapper, PropertyDefinition definition) throws ConstraintViolationException { super(mapper, definition); setRequiredType(definition.getRequiredType()); setMultiple(definition.isMultiple()); setFullTextSearchable(definition.isFullTextSearchable()); setQueryOrderable(definition.isQueryOrderable()); setAvailableQueryOperators(definition.getAvailableQueryOperators()); setValueConstraints(definition.getValueConstraints()); setDefaultValues(definition.getDefaultValues()); }
/** * Creates a new property definition based on <code>propDef</code>. * * @param propDef the JCR property definition. * @param resolver the name/path resolver of the session that provided * the property definition. * @param qValueFactory the QValue factory. * @throws RepositoryException if an error occurs while reading from * <code>propDef</code>. */ public QPropertyDefinitionImpl(PropertyDefinition propDef, NamePathResolver resolver, QValueFactory qValueFactory) throws RepositoryException { this(propDef.getName().equals(NameConstants.ANY_NAME.getLocalName()) ? NameConstants.ANY_NAME : resolver.getQName(propDef.getName()), resolver.getQName(propDef.getDeclaringNodeType().getName()), propDef.isAutoCreated(), propDef.isMandatory(), propDef.getOnParentVersion(), propDef.isProtected(), convertValues(propDef.getDefaultValues(), resolver, qValueFactory), propDef.isMultiple(), propDef.getRequiredType(), ValueConstraint.create(propDef.getRequiredType(), propDef.getValueConstraints(), resolver), propDef.getAvailableQueryOperators(), propDef.isFullTextSearchable(), propDef.isQueryOrderable()); }
/** * Creates a new property definition based on <code>propDef</code>. * * @param propDef the JCR property definition. * @param resolver the name/path resolver of the session that provided * the property definition. * @param qValueFactory the QValue factory. * @throws RepositoryException if an error occurs while reading from * <code>propDef</code>. */ public QPropertyDefinitionImpl(PropertyDefinition propDef, NamePathResolver resolver, QValueFactory qValueFactory) throws RepositoryException { this(propDef.getName().equals(NameConstants.ANY_NAME.getLocalName()) ? NameConstants.ANY_NAME : resolver.getQName(propDef.getName()), resolver.getQName(propDef.getDeclaringNodeType().getName()), propDef.isAutoCreated(), propDef.isMandatory(), propDef.getOnParentVersion(), propDef.isProtected(), convertValues(propDef.getDefaultValues(), resolver, qValueFactory), propDef.isMultiple(), propDef.getRequiredType(), ValueConstraint.create(propDef.getRequiredType(), propDef.getValueConstraints(), resolver), propDef.getAvailableQueryOperators(), propDef.isFullTextSearchable(), propDef.isQueryOrderable()); }
private JcrPropertyDefinition propertyDefinitionFrom( PropertyDefinition propDefn ) throws RepositoryException { Name propertyName = nameFactory.create(propDefn.getName()); int onParentVersionBehavior = propDefn.getOnParentVersion(); int requiredType = propDefn.getRequiredType(); boolean mandatory = propDefn.isMandatory(); boolean multiple = propDefn.isMultiple(); boolean autoCreated = propDefn.isAutoCreated(); boolean isProtected = propDefn.isProtected(); boolean fullTextSearchable = propDefn.isFullTextSearchable(); boolean queryOrderable = propDefn.isQueryOrderable(); Value[] defaultValues = propDefn.getDefaultValues(); JcrValue[] jcrDefaultValues = null; if (defaultValues != null) { jcrDefaultValues = new JcrValue[defaultValues.length]; for (int i = 0; i != defaultValues.length; ++i) { Value value = defaultValues[i]; jcrDefaultValues[i] = new JcrValue(this.context.getValueFactories(), value); } } String[] valueConstraints = propDefn.getValueConstraints(); String[] queryOperators = propDefn.getAvailableQueryOperators(); if (valueConstraints == null) valueConstraints = new String[0]; NodeKey prototypeKey = repository.repositoryCache().getSystemKey(); return new JcrPropertyDefinition(this.context, null, prototypeKey, propertyName, onParentVersionBehavior, autoCreated, mandatory, isProtected, jcrDefaultValues, requiredType, valueConstraints, multiple, fullTextSearchable, queryOrderable, queryOperators); }