*/
@Override
public PropertyInfo getPropertyInfo(SessionInfo sessionInfo, PropertyId propertyId) throws RepositoryException {
Path p = getPath(propertyId, sessionInfo);
String uri = getURI(p, sessionInfo);
PropFindMethod method = null;
try {
method = new PropFindMethod(uri, LAZY_PROPERTY_NAME_SET, DavConstants.DEPTH_0);
getClient(sessionInfo).executeMethod(method);
method.checkSuccess();
MultiStatusResponse[] responses = method.getResponseBodyAsMultiStatus().getResponses();
if (responses.length != 1) {
throw new ItemNotFoundException("Unable to retrieve the PropertyInfo. No such property " + uri);
}
MultiStatusResponse response = responses[0];
DavPropertySet props = response.getProperties(DavServletResponse.SC_OK);
int propertyType = PropertyType.valueFromName(props.get(JCR_TYPE).getValue().toString());
if (propertyType == PropertyType.BINARY) {
DavProperty<?> lengthsProp = props.get(JCR_LENGTHS);
if (lengthsProp != null) {
// multivalued binary property
long[] lengths = ValueUtil.lengthsFromXml(lengthsProp.getValue());
QValue[] qValues = new QValue[lengths.length];
for (int i = 0 ; i < lengths.length ; i ++) {
qValues[i] = getQValueFactory(sessionInfo).create(lengths[i], uri, i);
}
return new PropertyInfoImpl(propertyId, p, propertyType, qValues);
} else {
// single valued binary property
long length = Long.parseLong(props.get(JCR_LENGTH).getValue().toString());
QValue qValue = getQValueFactory(sessionInfo).create(length, uri, QValueFactoryImpl.NO_INDEX) ;
return new PropertyInfoImpl(propertyId, p, propertyType, qValue);
}
} else if (props.contains(JCR_GET_STRING)) {
// single valued non-binary property
Object v = props.get(JCR_GET_STRING).getValue();
String str = (v == null) ? "" : v.toString();
QValue qValue = ValueFormat.getQValue(str, propertyType, getNamePathResolver(sessionInfo), getQValueFactory(sessionInfo));
return new PropertyInfoImpl(propertyId, p, propertyType, qValue);
} else {
// multivalued non-binary property or some other property that
// didn't expose the JCR_GET_STRING dav property.
return super.getPropertyInfo(sessionInfo, propertyId);
}
} catch (IOException e) {
log.error("Internal error while retrieving ItemInfo.",e);
throw new RepositoryException(e.getMessage());
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (method != null) {
method.releaseConnection();
}
}
}