private static NodePropertyDescriptor getPropertyDescriptor(
ExtendedItemDefinition itemDef, ExtendedNodeType nodeType,
Locale locale) throws RepositoryException {
ExtendedPropertyDefinition propDefExt = (ExtendedPropertyDefinition) itemDef;
PropertyDefinition propDef = JCRContentUtils.getPropertyDefinition(
nodeType, propDefExt.getName());
NodeProperty.Type type = NodeProperty.Type.TEXT;
switch (propDef.getRequiredType()) {
case PropertyType.BOOLEAN:
type = NodeProperty.Type.BOOLEAN;
break;
case PropertyType.DATE:
type = NodeProperty.Type.DATE;
break;
case PropertyType.STRING:
if (SelectorType.CATEGORY == (propDefExt.getSelector())) {
type = NodeProperty.Type.CATEGORY;
}
break;
}
NodePropertyDescriptor descriptor = new NodePropertyDescriptor(itemDef.getName(), itemDef
.getLabel(locale != null ? locale : Locale.ENGLISH, nodeType), type);
descriptor.setMultiple(propDef.isMultiple());
if (propDef.getValueConstraints().length > 0) {
descriptor.setConstrained(true);
descriptor.setAllowedValues(propDef.getValueConstraints());
}
descriptor.setSelectorOptions(propDefExt.getSelectorOptions());
// TODO handle multiple default values
Value[] defaultValues = propDef.getDefaultValues();
if (defaultValues != null && defaultValues.length > 0) {
descriptor.setDefaultValue(defaultValues[0].getString());