try {
logger.info(this + ".save()");
FileInfo fileInfo = checkHook("PreSave", "save");
FileObject file = fileInfo.getFile();
checkForMigration(file.getParent());
FileContent fileContent = file.getContent();
if (hasContent()) IOUtil.copy(getContent().getInputStream(), true, fileContent.getOutputStream(), true);
Iterator it = deletedAttributes.iterator();
while (it.hasNext()) {
String name = (String) it.next();
if (fileContent.hasAttribute(name)) {
fileContent.removeAttribute(name);
} else {
fileContent.setAttribute(name, null);
}
}
Map defaultAttributes = fileInfo.getDefaultAttributes();
it = attributes.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
String name = (String) entry.getKey();
Object value = entry.getValue();
if (value.equals(defaultAttributes.get(name))) {
fileContent.removeAttribute(name);
} else {
fileContent.setAttribute(name, value);
}
}
refresh(fileInfo);
hook("PostSave", fileInfo);
clear();