}
@Override
@Transactional(readOnly = false)
public Long saveDocument(DocumentDTO document) throws Exception {
Document doc;
UzerDTO user = (UzerDTO) getSession().getAttribute("user");
if (document.getId() == null) {
doc = new Document();
document.setOwner(user);
} else {
doc = documentDAO.find(document.getId());
}
applyDiffDocument(doc, document);
if (getSession().getAttribute("file") instanceof byte[]) {
doc.setBuffer((byte[]) getSession().getAttribute("file"));
}
alertManagement.alert(user);
return (documentDAO.save(doc).getId());
}