class SoapDocumentService extends AbstractService implements DocumentService {

	@Override
	public WSDocument[] getAliases(String sid, long docId) throws Exception {
		User user = validateSession(sid);
		Collection<Long> folderIds = null;
		if (!user.isMemberOf("admin")) {
			FolderDAO fdao = (FolderDAO) Context.get().getBean(FolderDAO.class);
			folderIds = fdao.findFolderIdByUserId(user.getId(), null, true);
		}

		DocumentDAO docDao = (DocumentDAO) Context.get().getBean(DocumentDAO.class);
		List<Document> docs = new ArrayList<Document>();
		if (user.isMemberOf("admin"))
			docs = docDao.findByWhere("_entity.docRef=" + docId, null, null);
		else {
			String idsStr = folderIds.toString().replace('[', '(').replace(']', ')');
			docs = docDao.findByWhere("_entity.docRef=" + docId + " and _entity.id in " + idsStr, null, null);
		}

		List<WSDocument> wsDocs = new ArrayList<WSDocument>();
		for (int i = 0; i < docs.size(); i++) {
			docDao.initialize(docs.get(i));
			if (user.isMemberOf("admin") || folderIds.contains(docs.get(i).getFolder().getId()))
				wsDocs.add(WSUtil.toWSDocument(docs.get(i)));
		}

		return wsDocs.toArray(new WSDocument[0]);
	}

}