if (pds == null || pds.length == 0) {
return QPropertyDefinition.EMPTY_ARRAY;
}
QPropertyDefinition[] declaredPropDefs = new QPropertyDefinition[pds.length];
for (int i = 0; i < pds.length; i++) {
PropertyDefinition propDef = pds[i];
Name name = propDef.getName().equals(NameConstants.ANY_NAME.getLocalName())
? NameConstants.ANY_NAME
: resolver.getQName(propDef.getName());
// check if propDef provides declaring node type and if it matches 'this' one.
if (propDef.getDeclaringNodeType() != null) {
if (!declName.equals(resolver.getQName(propDef.getDeclaringNodeType().getName()))) {
throw new RepositoryException("Property definition specified invalid declaring nodetype: "
+ propDef.getDeclaringNodeType().getName() + ", but should be " + declName);
}
}
QValue[] defVls = propDef.getDefaultValues() == null
? QValue.EMPTY_ARRAY
: ValueFormat.getQValues(propDef.getDefaultValues(), resolver, qValueFactory);
String[] jcrConstraints = propDef.getValueConstraints();
QValueConstraint[] constraints = QValueConstraint.EMPTY_ARRAY;
if (jcrConstraints != null && jcrConstraints.length > 0) {
constraints = new QValueConstraint[jcrConstraints.length];
for (int j=0; j<constraints.length; j++) {
constraints[j] = ValueConstraint.create(propDef.getRequiredType(), jcrConstraints[j], resolver);
}
}
declaredPropDefs[i] = new QPropertyDefinitionImpl(
name, declName,
propDef.isAutoCreated(),
propDef.isMandatory(),
propDef.getOnParentVersion(),
propDef.isProtected(),
defVls,
propDef.isMultiple(),
propDef.getRequiredType(),
constraints,
propDef.getAvailableQueryOperators(),
propDef.isFullTextSearchable(),
propDef.isQueryOrderable());
}
return declaredPropDefs;
}