1
0
mirror of https://github.com/sismics/docs.git synced 2026-01-10 23:39:40 +00:00

List orphan files

This commit is contained in:
jendib
2015-03-06 21:23:50 +01:00
parent 2347483676
commit d0c259ead2
3 changed files with 29 additions and 11 deletions

View File

@@ -286,18 +286,22 @@ public class FileResource extends BaseResource {
public Response list(
@QueryParam("id") String documentId,
@QueryParam("share") String shareId) throws JSONException {
authenticate();
boolean authenticated = authenticate();
// Check document visibility
try {
DocumentDao documentDao = new DocumentDao();
Document document = documentDao.getDocument(documentId);
ShareDao shareDao = new ShareDao();
if (!shareDao.checkVisibility(document, principal.getId(), shareId)) {
throw new ForbiddenClientException();
if (documentId != null) {
try {
DocumentDao documentDao = new DocumentDao();
Document document = documentDao.getDocument(documentId);
ShareDao shareDao = new ShareDao();
if (!shareDao.checkVisibility(document, principal.getId(), shareId)) {
throw new ForbiddenClientException();
}
} catch (NoResultException e) {
throw new ClientException("DocumentNotFound", MessageFormat.format("Document not found: {0}", documentId));
}
} catch (NoResultException e) {
throw new ClientException("DocumentNotFound", MessageFormat.format("Document not found: {0}", documentId));
} else if (!authenticated) {
throw new ForbiddenClientException();
}
FileDao fileDao = new FileDao();