use of org.apache.sling.fsprovider.internal.mapper.valuemap.ValueMapDecorator in project sling by apache.
the class FileResource method getValueMap.
@Override
public ValueMap getValueMap() {
if (valueMap == null) {
// we should simulate the corresponding JCR properties in a value map as well
if (file.exists() && file.canRead()) {
Map<String, Object> props = new HashMap<String, Object>();
props.put("jcr:primaryType", file.isFile() ? RESOURCE_TYPE_FILE : RESOURCE_TYPE_FOLDER);
props.put("jcr:createdBy", "system");
Calendar lastModifed = Calendar.getInstance();
lastModifed.setTimeInMillis(file.lastModified());
props.put("jcr:created", lastModifed);
// overlay properties with those from node descriptor content file, if it exists
ContentFile contentFile = getNodeDescriptorContentFile();
if (contentFile != null) {
for (Map.Entry<String, Object> entry : contentFile.getValueMap().entrySet()) {
// skip primary type if it is the default type assigned by contentparser when none is defined
if (StringUtils.equals(entry.getKey(), "jcr:primaryType") && StringUtils.equals((String) entry.getValue(), ParserOptions.DEFAULT_PRIMARY_TYPE)) {
continue;
}
props.put(entry.getKey(), entry.getValue());
}
}
valueMap = new ValueMapDecorator(props);
}
}
return valueMap;
}
Aggregations