class SoapDocumentService extends AbstractService implements DocumentService {

	@Override
	public void move(String sid, long docId, long folderId) throws Exception {
		User user = validateSession(sid);
		try {
			FolderDAO fdao = (FolderDAO) Context.get().getBean(FolderDAO.class);
			long rootId = fdao.findRoot(user.getTenantId()).getId();

			if (folderId == rootId) {
				log.error("Cannot move documents in the root");
				throw new Exception("Cannot move documents in the root");
			}

			DocumentDAO docDao = (DocumentDAO) Context.get().getBean(DocumentDAO.class);
			Document doc = docDao.findById(docId);
			checkPermission(Permission.MOVE, user, doc.getFolder().getId());

			doc = docDao.findDocument(docId);
			checkPublished(user, doc);

			FolderDAO dao = (FolderDAO) Context.get().getBean(FolderDAO.class);
			Folder folder = dao.findById(folderId);
			checkLocked(user, doc);
			checkWriteEnable(user, folder.getId());

			// Create the document history event
			DocumentHistory transaction = new DocumentHistory();
			transaction.setSessionId(sid);
			transaction.setEvent(DocumentEvent.MOVED.toString());
			transaction.setComment("");
			transaction.setUser(user);

			DocumentManager documentManager = (DocumentManager) Context.get().getBean(DocumentManager.class);
			documentManager.moveToFolder(doc, folder, transaction);
		} catch (Throwable t) {
			logAndRethrow(log, t);
		}
	}

}