--- /dev/null
+<% /**
+*Copyright © Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+*
+*This file is part of the work and learning management system Pentila Nero.
+*
+*Pentila Nero is free software. You can redistribute it and/or modify since
+*you respect the terms of either (at least one of the both license) :
+*- under the terms of the GNU Affero General Public License as
+*published by the Free Software Foundation, either version 3 of the
+*License, or (at your option) any later version.
+*- the CeCILL-C as published by CeCILL-C; either version 1 of the
+*License, or any later version
+*- the GNU Lesser General Public License as published by the
+*Free Software Foundation, either version 3 of the license,
+*or (at your option) any later version.
+*
+*There are special exceptions to the terms and conditions of the
+*licenses as they are applied to this software. View the full text of
+*the exception in file LICENSE-PROJECT.txt in the directory of this software
+*distribution.
+*
+*Pentila Nero is distributed in the hope that it will be useful,
+*but WITHOUT ANY WARRANTY; without even the implied warranty of
+*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+*Licenses for more details.
+*
+*You should have received a copy of the GNU Affero General Public License
+*and the CeCILL-C and the GNU Lesser General Public License along with
+*Pentila Nero. If not, see :
+*<http://www.gnu.org/licenses/> and
+*<http://www.cecill.info/licences.fr.html>.
+*/ %>
+<%@page import="com.liferay.portal.kernel.workflow.WorkflowConstants"%>
+<%@page import="com.liferay.portlet.documentlibrary.model.DLFileEntry"%>
+<%@page import="com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil"%>
+<%@page import="com.liferay.portlet.documentlibrary.service.DLFileEntryServiceUtil"%>
+<%@page import="com.pentila.entSavoie.cartable.service.FileVersionLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.cartable.service.DlLinkLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.portlets.cartable.JSPPortlet"%>
+<%@page import="com.liferay.portal.kernel.util.TextFormatter"%>
+<%@page import="com.liferay.portlet.documentlibrary.service.DLFileVersionLocalServiceUtil"%>
+<%@page import="com.liferay.portlet.documentlibrary.model.DLFileVersion"%><%@page import="com.liferay.portal.service.GroupLocalServiceUtil"%>
+<%@page import="com.liferay.portal.model.Group"%>
+<%@page import="com.pentila.entSavoie.utils.ENTWebDAVUtil"%>
+<%@page import="com.liferay.portal.theme.ThemeDisplay"%>
+<%@page import="com.pentila.entSavoie.utils.PermissionsUtils"%>
+<%@page import="java.util.List"%>
+
+<%@page import="com.liferay.portlet.documentlibrary.model.DLFolder"%>
+<%@page import="com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil"%>
+
+<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
+
+<%@ include file="./initAjax.jsp" %>
+
+<%
+
+
+final JSONObject ret = JSONFactoryUtil.createJSONObject();
+final JSONArray versionItems = JSONFactoryUtil.createJSONArray();
+
+final long folderId = ParamUtil.getLong(renderRequest, "folderId");
+final double version = ParamUtil.getDouble(renderRequest, "version");
+final long fileId = ParamUtil.getLong(renderRequest, "fileId");
+DLFileEntry file = DLFileEntryLocalServiceUtil.getDLFileEntry(fileId);
+final String fileName = ParamUtil.getString(renderRequest, "fileName");
+
+String versionComment = "";
+long versionDownloadCount = 0;
+long versionViewCount = 0;
+try {
+ versionComment = FileVersionLocalServiceUtil.getFileVersionByFileEntryId(fileId, version).getComment();
+ versionDownloadCount = FileVersionLocalServiceUtil.getFileVersionByFileEntryId(fileId, version).getDownloadCount();
+ versionViewCount = FileVersionLocalServiceUtil.getFileVersionByFileEntryId(fileId, version).getViewCount();
+} catch (Exception e) {}
+ret.put("currentComment", versionComment);
+ret.put("downloadCount", versionDownloadCount);
+ret.put("viewCount", versionViewCount);
+
+List<DLFileVersion> listVersion = DLFileVersionLocalServiceUtil.getFileVersions(file.getFileEntryId(), WorkflowConstants.STATUS_ANY);
+
+for (DLFileVersion dlfv: listVersion) {
+ JSONObject curr = JSONFactoryUtil.createJSONObject();
+ curr.put("id", dlfv.getFileVersionId());
+ curr.put("size", dlfv.getSize());
+ curr.put("date", JSPPortlet.returnDF.format(dlfv.getCreateDate()));
+ curr.put("userName", dlfv.getUserName());
+ curr.put("statusByUserName", dlfv.getStatusByUserName());
+ curr.put("version", dlfv.getVersion());
+ versionComment = "";
+ versionDownloadCount = 0;
+ versionViewCount = 0;
+ try {
+ versionComment = FileVersionLocalServiceUtil.getFileVersionByFileEntryId(fileId, dlfv.getVersion()).getComment();
+ versionDownloadCount = FileVersionLocalServiceUtil.getFileVersionByFileEntryId(fileId, dlfv.getVersion()).getDownloadCount();
+ versionViewCount = FileVersionLocalServiceUtil.getFileVersionByFileEntryId(fileId, dlfv.getVersion()).getViewCount();
+ } catch (Exception e) {}
+
+ try {
+ if (dlfv.getSize() == 0)
+ curr.put("size", DLFileEntryServiceUtil.getFileEntry(DlLinkLocalServiceUtil.getDlFileLinkByTarget(fileId).getSourceId()).getSize());
+ } catch (Exception e) {}
+
+ curr.put("currentComment", versionComment);
+ curr.put("downloadCount", versionDownloadCount);
+ curr.put("viewCount", versionViewCount);
+ versionItems.put(curr);
+}
+
+ret.put("versionItems", versionItems);
+%>
+<%= ret.toString() %>