Skip to content
Snippets Groups Projects
Commit e7fa041f authored by srosse's avatar srosse
Browse files

OO-4768: use the method in DAO to calculate revisions size

parent 995f092d
No related branches found
No related tags found
No related merge requests found
......@@ -19,8 +19,6 @@
*/
package org.olat.restapi.system;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
......@@ -28,6 +26,7 @@ import javax.ws.rs.core.Response;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.persistence.DB;
import org.olat.core.commons.services.vfs.manager.VFSRevisionDAO;
import org.olat.restapi.system.vo.VFSStatsVO;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -42,6 +41,8 @@ public class VFSStatsWebService {
@Autowired
private DB dbInstance;
@Autowired
private VFSRevisionDAO vfsRevisionDAO;
public VFSStatsWebService() {
CoreSpringFactory.autowireObject(this);
......@@ -50,19 +51,10 @@ public class VFSStatsWebService {
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response getRevisionSizeXML() {
StringBuilder sb = new StringBuilder(256);
sb.append("select SUM(size) from vfsrevision");
List<Long> revisionsSize = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Long.class)
.getResultList();
Long size = revisionsSize == null || revisionsSize.isEmpty() ? Long.valueOf(0) : revisionsSize.get(0);
long size = vfsRevisionDAO.calculateRevisionsSize();
dbInstance.commitAndCloseSession();
VFSStatsVO vo = new VFSStatsVO(size);
return Response.ok(vo).build();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment