mirror of
https://github.com/sismics/docs.git
synced 2024-11-25 15:17:57 +01:00
Document count in GET /app, TODO
This commit is contained in:
parent
4d50b220a2
commit
9e5459cafe
@ -1,2 +1,3 @@
|
|||||||
- Server side reordering files
|
- Reordering files (server)
|
||||||
- GET /app/stats to display general data (server/client)
|
- GET /app/stats to display general data (server/client)
|
||||||
|
- User settings
|
@ -17,9 +17,13 @@ import org.apache.log4j.Logger;
|
|||||||
import org.codehaus.jettison.json.JSONException;
|
import org.codehaus.jettison.json.JSONException;
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
|
||||||
|
import com.sismics.docs.core.dao.jpa.DocumentDao;
|
||||||
|
import com.sismics.docs.core.dao.jpa.criteria.DocumentCriteria;
|
||||||
|
import com.sismics.docs.core.dao.jpa.dto.DocumentDto;
|
||||||
import com.sismics.docs.core.util.ConfigUtil;
|
import com.sismics.docs.core.util.ConfigUtil;
|
||||||
import com.sismics.docs.core.util.jpa.PaginatedList;
|
import com.sismics.docs.core.util.jpa.PaginatedList;
|
||||||
import com.sismics.docs.core.util.jpa.PaginatedLists;
|
import com.sismics.docs.core.util.jpa.PaginatedLists;
|
||||||
|
import com.sismics.docs.core.util.jpa.SortCriteria;
|
||||||
import com.sismics.docs.rest.constant.BaseFunction;
|
import com.sismics.docs.rest.constant.BaseFunction;
|
||||||
import com.sismics.rest.exception.ForbiddenClientException;
|
import com.sismics.rest.exception.ForbiddenClientException;
|
||||||
import com.sismics.rest.exception.ServerException;
|
import com.sismics.rest.exception.ServerException;
|
||||||
@ -42,16 +46,32 @@ public class AppResource extends BaseResource {
|
|||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Response version() throws JSONException {
|
public Response info() throws JSONException {
|
||||||
|
if (!authenticate()) {
|
||||||
|
throw new ForbiddenClientException();
|
||||||
|
}
|
||||||
|
|
||||||
ResourceBundle configBundle = ConfigUtil.getConfigBundle();
|
ResourceBundle configBundle = ConfigUtil.getConfigBundle();
|
||||||
String currentVersion = configBundle.getString("api.current_version");
|
String currentVersion = configBundle.getString("api.current_version");
|
||||||
String minVersion = configBundle.getString("api.min_version");
|
String minVersion = configBundle.getString("api.min_version");
|
||||||
|
|
||||||
JSONObject response = new JSONObject();
|
JSONObject response = new JSONObject();
|
||||||
|
|
||||||
|
// Specific data
|
||||||
|
DocumentDao documentDao = new DocumentDao();
|
||||||
|
PaginatedList<DocumentDto> paginatedList = PaginatedLists.create(1, 0);
|
||||||
|
SortCriteria sortCriteria = new SortCriteria(0, true);
|
||||||
|
DocumentCriteria documentCriteria = new DocumentCriteria();
|
||||||
|
documentCriteria.setUserId(principal.getId());
|
||||||
|
documentDao.findByCriteria(paginatedList, documentCriteria, sortCriteria);
|
||||||
|
response.put("document_count", paginatedList.getResultCount());
|
||||||
|
|
||||||
|
// General data
|
||||||
response.put("current_version", currentVersion.replace("-SNAPSHOT", ""));
|
response.put("current_version", currentVersion.replace("-SNAPSHOT", ""));
|
||||||
response.put("min_version", minVersion);
|
response.put("min_version", minVersion);
|
||||||
response.put("total_memory", Runtime.getRuntime().totalMemory());
|
response.put("total_memory", Runtime.getRuntime().totalMemory());
|
||||||
response.put("free_memory", Runtime.getRuntime().freeMemory());
|
response.put("free_memory", Runtime.getRuntime().freeMemory());
|
||||||
|
|
||||||
return Response.ok().entity(response).build();
|
return Response.ok().entity(response).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Documents list
|
||||||
.table-documents {
|
.table-documents {
|
||||||
thead th {
|
thead th {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -9,6 +10,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// File thumbnails
|
||||||
.thumbnail-file {
|
.thumbnail-file {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@ -21,6 +23,7 @@
|
|||||||
overflow: visible;
|
overflow: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fields bound to datepicker
|
||||||
input[readonly][datepicker-popup] {
|
input[readonly][datepicker-popup] {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@ -29,21 +32,30 @@ input[readonly][datepicker-popup] {
|
|||||||
.inline-edit {
|
.inline-edit {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: block;
|
display: block;
|
||||||
}
|
|
||||||
|
|
||||||
.inline-edit span {
|
span {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-edit input {
|
input {
|
||||||
display: none;
|
display: none;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-edit.active span {
|
&.active {
|
||||||
|
span {
|
||||||
display: none;
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.inline-edit.active input {
|
// Pagination
|
||||||
display: inline-block;
|
.pagination {
|
||||||
|
ul > li {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
@ -26,8 +26,13 @@ public class TestAppResource extends BaseJerseyTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAppResource() throws JSONException {
|
public void testAppResource() throws JSONException {
|
||||||
|
// Login app1
|
||||||
|
clientUtil.createUser("app1");
|
||||||
|
String app1Token = clientUtil.login("app1");
|
||||||
|
|
||||||
// Check the application info
|
// Check the application info
|
||||||
WebResource appResource = resource().path("/app");
|
WebResource appResource = resource().path("/app");
|
||||||
|
appResource.addFilter(new CookieAuthenticationFilter(app1Token));
|
||||||
ClientResponse response = appResource.get(ClientResponse.class);
|
ClientResponse response = appResource.get(ClientResponse.class);
|
||||||
response = appResource.get(ClientResponse.class);
|
response = appResource.get(ClientResponse.class);
|
||||||
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
|
||||||
@ -40,6 +45,7 @@ public class TestAppResource extends BaseJerseyTest {
|
|||||||
Assert.assertTrue(freeMemory > 0);
|
Assert.assertTrue(freeMemory > 0);
|
||||||
Long totalMemory = json.getLong("total_memory");
|
Long totalMemory = json.getLong("total_memory");
|
||||||
Assert.assertTrue(totalMemory > 0 && totalMemory > freeMemory);
|
Assert.assertTrue(totalMemory > 0 && totalMemory > freeMemory);
|
||||||
|
Assert.assertEquals(0, json.getInt("document_count"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user