// Try to get the MIME type for the binary value ...
org.modeshape.jcr.value.Property dataProp = node.getProperty(JcrLexicon.DATA, cache);
if (dataProp != null) {
Object dataValue = dataProp.getFirstValue();
if (dataValue instanceof Binary) {
Binary binaryValue = (Binary)dataValue;
// Get the name of this node's parent ...
String fileName = null;
NodeKey parentKey = node.getParentKey(cache);
if (parentKey != null) {
CachedNode parent = cache.getNode(parentKey);
Name parentName = parent.getName(cache);
fileName = stringFactory().create(parentName);
}
String mimeType = binaryValue.getMimeType(fileName);
if (mimeType != null) {
node.setProperty(cache, propertyFactory.create(JcrLexicon.MIMETYPE, mimeType));
}
}
}