class SoapBookmarkService extends AbstractService implements BookmarkService {

	@Override
	public WSBookmark bookmarkDocument(String sid, long docId) throws Exception {
		User user = validateSession(sid);

		WSDocument doc = checkDocumentAvailable(sid, docId);

		BookmarkDAO bDao = (BookmarkDAO) Context.get().getBean(BookmarkDAO.class);
		Bookmark bmark = bDao.findByUserIdAndDocId(user.getId(), docId);
		if (bmark == null) {
			bmark = new Bookmark();
			bmark.setType(Bookmark.TYPE_DOCUMENT);
			bmark.setFileType(doc.getFileName());
			bmark.setFileType(doc.getType());
			bmark.setUserId(user.getId());
			bmark.setTargetId(docId);
			bDao.store(bmark);
		}

		return WSBookmark.fromBookmark(bmark);
	}

}