String typeName = propSet.get(ItemResourceConstants.JCR_TYPE).getValue().toString();
type = PropertyType.valueFromName(typeName);
// values from jcr-server must be converted to SPI values.
if (propSet.contains(ItemResourceConstants.JCR_VALUE)) {
ValuesProperty vp = new ValuesProperty(propSet.get(ItemResourceConstants.JCR_VALUE), type, valueFactory);
Value jcrValue = vp.getJcrValue(type, valueFactory);
if (jcrValue == null) {
// TODO: should never occur. since 'null' single values are not allowed. rather throw?
values = QValue.EMPTY_ARRAY;
} else {
QValue qv;
if (type == PropertyType.BINARY) {
qv = qValueFactory.create(jcrValue.getStream());
} else {
qv = ValueFormat.getQValue(jcrValue, resolver, qValueFactory);
}
values = new QValue[] {qv};
}
} else {
isMultiValued = true;
ValuesProperty vp = new ValuesProperty(propSet.get(ItemResourceConstants.JCR_VALUES), type, valueFactory);
Value[] jcrValues = vp.getJcrValues(type, valueFactory);
values = new QValue[jcrValues.length];
for (int i = 0; i < jcrValues.length; i++) {
if (type == PropertyType.BINARY) {
values[i] = qValueFactory.create(jcrValues[i].getStream());
} else {