class SoapDocumentService extends AbstractService implements DocumentService {

	@Override
	public WSNote addNote(String sid, long docId, String note) throws Exception {
		User user = validateSession(sid);
		WSDocument document = getDocument(sid, docId);
		if (document == null)
			throw new Exception("Document with ID " + docId + " not found or not accessible");

		DocumentNote newNote = new DocumentNote();
		newNote.setDocId(document.getId());
		newNote.setMessage(note);
		newNote.setUserId(user.getId());
		newNote.setUsername(user.getFullName());

		DocumentDAO ddao = (DocumentDAO) Context.get().getBean(DocumentDAO.class);
		Document doc = ddao.findDocument(docId);
		newNote.setFileName(doc.getFileName());

		DocumentHistory transaction = new DocumentHistory();
		transaction.setSessionId(sid);
		transaction.setUser(user);

		DocumentNoteDAO dao = (DocumentNoteDAO) Context.get().getBean(DocumentNoteDAO.class);
		dao.store(newNote, transaction);

		return WSNote.fromDocumentNote(newNote);
	}

}