class SoapFolderService extends AbstractService implements FolderService {

	@Override
	public void delete(String sid, long folderId) throws Exception {
		User user = validateSession(sid);
		FolderDAO folderDao = (FolderDAO) Context.get().getBean(FolderDAO.class);
		long rootId = folderDao.findRoot(user.getTenantId()).getTenantId();
		if (folderId == rootId || folderId == rootId)
			throw new Exception("Cannot delete root folder or Default workspace");

		checkPermission(Permission.DELETE, user, folderId);

		try {
			// Add a folder history entry
			FolderHistory transaction = new FolderHistory();
			transaction.setUser(user);
			transaction.setEvent(FolderEvent.DELETED.toString());
			transaction.setSessionId(sid);
			folderDao.deleteTree(folderId, transaction);
		} catch (Throwable t) {
			log.error(t.getMessage(), t);
			throw new RuntimeException(t.getMessage(), t);
		}
	}

}