long modificationTime = -1;
final Node targetNode = promoteNode();
try {
if (targetNode.hasProperty(JCR_LASTMODIFIED)) {
// We don't check node type, so JCR_LASTMODIFIED might not be a long
final Property prop = targetNode.getProperty(JCR_LASTMODIFIED);
try {
modificationTime = prop.getLong();
} catch (final ValueFormatException vfe) {
LOGGER.debug("Property {} cannot be converted to a long, ignored ({})",
prop.getPath(), vfe);
}
}
} catch (final RepositoryException re) {
report(re);
}
internalPut(MODIFICATION_TIME, modificationTime);
return modificationTime;
} else if (CONTENT_LENGTH.equals(key)) {
long contentLength = -1;
final Node targetNode = promoteNode();
try {
// if the node has a jcr:data property, use that property
if (targetNode.hasProperty(JCR_DATA)) {
final Property prop = targetNode.getProperty(JCR_DATA);
contentLength = JcrItemResource.getContentLength(prop);
} else {
// otherwise try to follow default item trail
Item item = getPrimaryItem(targetNode);
while (item != null && item.isNode()) {
item = getPrimaryItem((Node) item);
}
if ( item != null ) {
final Property data = (Property) item;
// set the content length property as a side effect
// for resources which are not nt:file based and whose
// data is not in jcr:content/jcr:data this will lazily
// set the correct content length