1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-13 09:46:17 +00:00

Order of files attached to document

This commit is contained in:
jendib
2015-03-06 21:13:09 +01:00
parent 6c976087de
commit 2347483676
4 changed files with 19 additions and 25 deletions

View File

@@ -204,9 +204,9 @@ public class FileResource extends BaseResource {
}
// Update the file
// TODO Reorder files to put the new one at the end
file.setDocumentId(documentId);
fileDao.updateDocument(file);
file.setOrder(fileDao.getByDocumentId(documentId).size());
fileDao.update(file);
// Raise a new file created event (it wasn't sent during file creation)
try {

View File

@@ -238,5 +238,16 @@ public class TestFileResource extends BaseJerseyTest {
response = documentResource.post(ClientResponse.class, postParams);
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
json = response.getEntity(JSONObject.class);
// Get all files from a document
fileResource = resource().path("/file/list");
fileResource.addFilter(new CookieAuthenticationFilter(file2AuthenticationToken));
MultivaluedMapImpl getParams = new MultivaluedMapImpl();
getParams.putSingle("id", document1Id);
response = fileResource.queryParams(getParams).get(ClientResponse.class);
json = response.getEntity(JSONObject.class);
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
JSONArray files = json.getJSONArray("files");
Assert.assertEquals(1, files.length());
}
}