1 /*******************************************************************************
2 * Copyright � Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
3 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
4 * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
6 * This file is part of the work and learning management system Pentila Nero.
8 * Pentila Nero is free software. You can redistribute it and/or modify since
9 * you respect the terms of either (at least one of the both license) :
10 * - under the terms of the GNU Affero General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 * - the CeCILL-C as published by CeCILL-C; either version 1 of the
14 * License, or any later version
15 * - the GNU Lesser General Public License as published by the
16 * Free Software Foundation, either version 3 of the license,
17 * or (at your option) any later version.
19 * There are special exceptions to the terms and conditions of the
20 * licenses as they are applied to this software. View the full text of
21 * the exception in file LICENSE-PROJECT.txt in the directory of this software
24 * Pentila Nero is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * Licenses for more details.
29 * You should have received a copy of the GNU Affero General Public License
30 * and the CeCILL-C and the GNU Lesser General Public License along with
31 * Pentila Nero. If not, see :
32 * <http://www.gnu.org/licenses/> and
33 * <http://www.cecill.info/licences.fr.html>.
34 ******************************************************************************/
35 package com.pentila.entSavoie.utils;
37 import java.awt.image.RenderedImage;
38 import java.util.ArrayList;
39 import java.util.Date;
40 import java.util.List;
42 import com.liferay.portal.kernel.bean.PortletBeanLocatorUtil;
43 import com.liferay.portal.kernel.dao.orm.Criterion;
44 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
45 import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
46 import com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil;
47 import com.liferay.portal.kernel.exception.PortalException;
48 import com.liferay.portal.kernel.exception.SystemException;
49 import com.liferay.portal.kernel.image.ImageToolUtil;
50 import com.liferay.portal.kernel.json.JSONArray;
51 import com.liferay.portal.kernel.json.JSONFactoryUtil;
52 import com.liferay.portal.kernel.json.JSONObject;
53 import com.liferay.portal.kernel.log.Log;
54 import com.liferay.portal.kernel.log.LogFactoryUtil;
55 import com.liferay.portal.kernel.repository.model.FileEntry;
56 import com.liferay.portal.kernel.repository.model.Folder;
57 import com.liferay.portal.kernel.util.FileUtil;
58 import com.liferay.portal.kernel.util.MimeTypesOverrideUtil;
59 import com.liferay.portal.model.Group;
60 import com.liferay.portal.model.Organization;
61 import com.liferay.portal.model.User;
62 import com.liferay.portal.service.GroupLocalServiceUtil;
63 import com.liferay.portal.service.OrganizationLocalServiceUtil;
64 import com.liferay.portal.service.ServiceContext;
65 import com.liferay.portal.service.UserLocalServiceUtil;
66 import com.liferay.portal.theme.ThemeDisplay;
67 import com.liferay.portlet.documentlibrary.FolderNameException;
68 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
69 import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
70 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
71 import com.liferay.portlet.documentlibrary.model.DLFolder;
72 import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
73 import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
74 import com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor;
75 import com.pentila.entSavoie.amis.model.FriendFolder;
76 import com.pentila.entSavoie.amis.service.FriendFolderLocalServiceUtil;
77 import com.pentila.entSavoie.casier.Constants;
78 import com.pentila.entSavoie.userManagement.service.ClpSerializer;
80 public class FoldersUtil {
82 private static Log logger = LogFactoryUtil.getLog(FoldersUtil.class);
84 public static Folder getRootFolder(long userId, long groupId) throws PortalException, SystemException {
85 return getRootFolder(userId, groupId, true);
88 public static Folder getRootFolder(long userId, long groupId, boolean createIt) throws PortalException, SystemException {
89 final Group group = GroupLocalServiceUtil.getGroup(groupId);
90 Folder rootFolder = null;
91 //Selon s'il s'agit d'un group d'organizatoin ou d'utilisateur, le nom
96 rootFolder = DLAppLocalServiceUtil.getFolder(groupId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.SCHOOL_BAG_FOLDER_NAME);
97 } catch (NoSuchFolderException e) {
99 // signifie une mauvaise initialisation du portail. Cree le dossier
100 rootFolder = DLAppLocalServiceUtil.addFolder(
103 DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
104 Constants.SCHOOL_BAG_FOLDER_NAME,
105 "Cartable personnel.",
106 new ServiceContext());
111 rootFolder = DLAppLocalServiceUtil.getFolder(groupId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.GROUP_FOLDER_NAME);
113 catch (Exception ex) {
115 // signifie une mauvaise initialisation du portail. Cree le dossier
116 rootFolder = DLAppLocalServiceUtil.addFolder(
117 group.getCreatorUserId(),
119 DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
120 Constants.GROUP_FOLDER_NAME,
122 new ServiceContext());
123 PermissionsUtils.addDefaultPermissionsFolder(rootFolder);
130 public static Folder getDropBox(long userid) throws PortalException, SystemException {
131 final User user = UserLocalServiceUtil.getUser(userid);
134 fol = DLAppLocalServiceUtil.getFolder(user.getGroup().getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.DROP_BOX_FOLDER_NAME);
135 } catch (NoSuchFolderException e) {
136 fol = DLAppLocalServiceUtil.addFolder(
138 user.getGroup().getGroupId(),
139 DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
140 Constants.DROP_BOX_FOLDER_NAME,
142 new ServiceContext());
147 public static Folder getSendingBox(long userid) throws PortalException, SystemException {
148 final User user = UserLocalServiceUtil.getUser(userid);
151 fol = DLAppLocalServiceUtil.getFolder(user.getGroup().getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.SENDING_BOX_FOLDER_NAME);
152 } catch (NoSuchFolderException e) {
153 fol = DLAppLocalServiceUtil.addFolder(
155 user.getGroup().getGroupId(),
156 DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
157 Constants.SENDING_BOX_FOLDER_NAME,
159 new ServiceContext());
161 PermissionsUtils.setViewPermissionForRessources(fol);
165 public static Folder getIMBox(long userid) throws PortalException, SystemException {
166 final User user = UserLocalServiceUtil.getUser(userid);
169 fol = DLAppLocalServiceUtil.getFolder(user.getGroup().getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.IM_BOX_FOLDER_NAME);
170 } catch (NoSuchFolderException e) {
171 fol = DLAppLocalServiceUtil.addFolder(user.getUserId(), user.getGroup().getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.IM_BOX_FOLDER_NAME, "Boite Instant Message", new ServiceContext());
173 PermissionsUtils.setViewPermissionForRessources(fol);
177 public static Folder getCDTEventsBox(long userId, long groupId) throws PortalException, SystemException {
178 // il s'agit d'un folder stockant les objs attaches aux evt dans le cdt d'un group ou user
179 // --> ceci est l'espace dans lequel est entreposé ces documents
182 fol = DLAppLocalServiceUtil.getFolder(groupId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.CDT_EVENT_FOLDER_NAME);
183 } catch (NoSuchFolderException e) {
184 fol = DLAppLocalServiceUtil.addFolder(
187 DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
188 Constants.CDT_EVENT_FOLDER_NAME,
190 new ServiceContext());
196 public static Folder getTmpFileFolderBox(long userId, long groupId) throws PortalException, SystemException {
197 return getTmpFileFolderBox(userId, groupId, true);
200 public static Folder getTmpFileFolderBox(long userId, long groupId, boolean createIt) throws PortalException, SystemException {
201 // il s'agit d'un folder temporaire stockant des fichier proveneant du disk de l'utilisateur
202 // --> ceci est l'espace dans lequel est entreposé ces documents
205 fol = DLAppLocalServiceUtil.getFolder(groupId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, Constants.TMP_IMG_FOLDER_NAME);
206 } catch (NoSuchFolderException e) {
208 fol = DLAppLocalServiceUtil.addFolder(
211 DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
212 Constants.TMP_IMG_FOLDER_NAME,
213 "Fichier provenant du disk",
214 new ServiceContext());
223 public static JSONArray getTreeViewAsJSON(long folderId) {
224 JSONArray ret = JSONFactoryUtil.createJSONArray();
226 final Folder currFolder = DLAppLocalServiceUtil.getFolder(folderId);
227 for (Folder f : DLAppLocalServiceUtil.getFolders(currFolder.
228 getGroupId(), currFolder.getFolderId())) {
229 if (!f.getName().startsWith(".")){
231 JSONObject ob = JSONFactoryUtil.createJSONObject();
232 ob.put("id", f.getFolderId());
233 ob.put("text", f.getName());
234 ob.put("leaf", false);
238 } catch (Exception e) {}
242 public static JSONArray getCartableTreeViewAsJSON(long folderId) {
243 JSONArray ret = JSONFactoryUtil.createJSONArray();
245 final Folder currFolder = DLAppLocalServiceUtil.getFolder(folderId);
246 for (Folder f : DLAppLocalServiceUtil.getFolders(currFolder.
247 getGroupId(), currFolder.getFolderId())) {
248 if (!f.getName().startsWith(".")){
249 JSONObject ob = JSONFactoryUtil.createJSONObject();
250 ob.put("id", f.getFolderId());
251 ob.put("text", f.getName());
252 ob.put("draggable", true);
253 ob.put("leaf", false);
257 for (FileEntry f : DLAppLocalServiceUtil.getFileEntries(currFolder.getGroupId(), folderId)) {
258 if (!f.getTitle().startsWith(".")){
259 boolean isSignet = false;
260 String extension = f.getExtension();
261 if(extension.contains("html")){
262 isSignet = DLEntryUtil.isSignetFile(f);
264 JSONObject ob = JSONFactoryUtil.createJSONObject();
265 ob.put("id", f.getFileEntryId());
266 ob.put("text", f.getTitle());
267 ob.put("leaf", true);
268 ob.put("draggable", true);
269 ob.put("iconCls", isSignet?"file-signet":"file-" + f.getExtension());
270 ob.put("isSignet", isSignet);
274 } catch (Exception e) {}
278 public static JSONArray getCartableTreeViewWithDragNDropAsJSON(long folderId) {
279 JSONArray ret = JSONFactoryUtil.createJSONArray();
281 final Folder currFolder = DLAppLocalServiceUtil.getFolder(folderId);
282 for (Folder f : DLAppLocalServiceUtil.getFolders(currFolder.
283 getGroupId(), currFolder.getFolderId())) {
284 if (!f.getName().startsWith(".")){
285 JSONObject ob = JSONFactoryUtil.createJSONObject();
286 ob.put("id", f.getFolderId());
287 ob.put("text", f.getName());
288 ob.put("draggable", true);
289 ob.put("leaf", false);
293 for (FileEntry f : DLAppLocalServiceUtil.getFileEntries(currFolder.getGroupId(), folderId)) {
294 if (!f.getTitle().startsWith(".")){
295 boolean isSignet = false;
296 String extension = f.getExtension();
297 if(extension.contains("html")){
298 isSignet = DLEntryUtil.isSignetFile(f);
300 JSONObject ob = JSONFactoryUtil.createJSONObject();
301 ob.put("id", f.getFileEntryId());
302 ob.put("text", f.getTitle());
303 ob.put("leaf", true);
304 ob.put("draggable", true);
305 ob.put("iconCls", isSignet?"file-signet":"file-" + f.getExtension());
306 ob.put("isSignet", isSignet);
310 } catch (Exception e) {}
314 public static JSONArray getCartableTreeViewWithDragNDropAndPermissionsAsJSON(long folderId, ThemeDisplay themeDisplay) {
315 JSONArray ret = JSONFactoryUtil.createJSONArray();
317 final Folder currFolder = DLAppLocalServiceUtil.getFolder(folderId);
318 for (Folder f : DLAppLocalServiceUtil.getFolders(currFolder.
319 getGroupId(), currFolder.getFolderId())) {
320 //if has the view permission
321 if (PermissionsUtils.checkFolderPermission(themeDisplay.getPermissionChecker(), f, "VIEW")){
322 if (!f.getName().startsWith(".")){
323 JSONObject ob = JSONFactoryUtil.createJSONObject();
324 ob.put("id", f.getFolderId());
325 ob.put("text", f.getName());
326 ob.put("draggable", true);
327 ob.put("leaf", false);
328 if (PermissionsUtils.checkFolderPermission(themeDisplay.getPermissionChecker(), f, "PASTE")){
329 ob.put("hasPermission", true);
331 ob.put("hasPermission", false);
338 for (FileEntry f : DLAppLocalServiceUtil.getFileEntries(currFolder.getGroupId(), folderId)) {
339 //if has the view permission
340 if (PermissionsUtils.checkFilePermission(themeDisplay.getPermissionChecker(), f, "VIEW")){
341 if (!f.getTitle().startsWith(".")){
342 boolean isSignet = false;
343 String extension = f.getExtension();
344 if(extension.contains("html")){
345 isSignet = DLEntryUtil.isSignetFile(f);
347 JSONObject ob = JSONFactoryUtil.createJSONObject();
348 ob.put("id", f.getFileEntryId());
349 ob.put("text", f.getTitle());
350 ob.put("leaf", true);
351 ob.put("draggable", true);
352 ob.put("iconCls", isSignet?"file-signet":"file-" + f.getExtension());
353 ob.put("isSignet", isSignet);
358 } catch (Exception e) {}
362 public static JSONArray getCartableTreeViewAsJSONWithoutFolderSelection(long folderId) {
363 JSONArray ret = JSONFactoryUtil.createJSONArray();
365 final Folder currFolder = DLAppLocalServiceUtil.getFolder(folderId);
366 for (Folder f : DLAppLocalServiceUtil.getFolders(currFolder.
367 getGroupId(), currFolder.getFolderId())) {
368 if (!f.getName().startsWith(".")){
369 JSONObject ob = JSONFactoryUtil.createJSONObject();
370 ob.put("id", f.getFolderId());
371 ob.put("text", f.getName());
372 ob.put("draggable", false);
373 ob.put("leaf", false);
377 for (FileEntry f : DLAppLocalServiceUtil.getFileEntries(currFolder.getGroupId(), folderId)) {
378 if (!f.getTitle().startsWith(".")){
379 boolean isSignet = false;
380 String extension = f.getExtension();
381 if(extension.contains("html")){
382 isSignet = DLEntryUtil.isSignetFile(f);
384 JSONObject ob = JSONFactoryUtil.createJSONObject();
385 ob.put("id", f.getFileEntryId());
386 ob.put("text", f.getTitle());
387 ob.put("leaf", true);
388 ob.put("draggable", true);
389 ob.put("iconCls", isSignet?"file-signet":"file-" + f.getExtension());
390 ob.put("isSignet", isSignet);
394 } catch (Exception e) {}
398 public static JSONArray getCartableTreeViewAsJSON(long folderId, String extensions) {
399 return getCartableTreeViewAsJSON(folderId, extensions, false);
402 public static JSONArray getCartableTreeViewAsJSON(long folderId, String extensions, boolean leafFilter) {
403 JSONArray ret = JSONFactoryUtil.createJSONArray();
406 //enable select sur treeElt seulement sur ces extension
407 String[] extensionsArray = extensions.split(",");
409 final Folder currFolder = DLAppLocalServiceUtil.getFolder(folderId);
410 for (Folder f : DLAppLocalServiceUtil.getFolders(currFolder.
411 getGroupId(), currFolder.getFolderId())) {
412 if (!f.getName().startsWith(".")){
413 JSONObject ob = JSONFactoryUtil.createJSONObject();
414 ob.put("id", f.getFolderId());
415 ob.put("text", f.getName());
416 ob.put("draggable", !leafFilter);
417 ob.put("leaf", false);
421 for (FileEntry f : DLAppLocalServiceUtil.getFileEntries(currFolder.getGroupId(), folderId)) {
422 for (int i=0; i < extensionsArray.length; i++) {
423 String ext = extensionsArray[i];
424 if(f.getTitle().toLowerCase().endsWith("."+ext)){
425 if (!f.getTitle().startsWith(".")){
426 boolean isSignet = false;
427 String extension = f.getExtension();
428 if(extension.contains("html")){
429 isSignet = DLEntryUtil.isSignetFile(f);
431 JSONObject ob = JSONFactoryUtil.createJSONObject();
432 ob.put("id", f.getFileEntryId());
433 ob.put("text", f.getTitle());
434 ob.put("leaf", true);
435 ob.put("draggable", true);
436 ob.put("iconCls", isSignet?"file-signet":"file-" + f.getExtension());
437 ob.put("isSignet", isSignet);
443 } catch (Exception e) {}
447 public static JSONArray getCartableTreeViewAsJSON(long folderId, String extensions, boolean leafFilter, ThemeDisplay themeDisplay) {
448 JSONArray ret = JSONFactoryUtil.createJSONArray();
451 //enable select sur treeElt seulement sur ces extension
452 String[] extensionsArray = extensions.split(",");
454 final Folder currFolder = DLAppLocalServiceUtil.getFolder(folderId);
455 for (Folder f : DLAppLocalServiceUtil.getFolders(currFolder.
456 getGroupId(), currFolder.getFolderId())) {
457 if (!f.getName().startsWith(".")){
458 JSONObject ob = JSONFactoryUtil.createJSONObject();
459 ob.put("id", f.getFolderId());
460 ob.put("text", f.getName());
461 ob.put("draggable", !leafFilter);
462 ob.put("leaf", false);
466 for (FileEntry f : DLAppLocalServiceUtil.getFileEntries(currFolder.getGroupId(), folderId)) {
467 for (int i=0; i < extensionsArray.length; i++) {
468 String ext = extensionsArray[i];
469 if(f.getTitle().toLowerCase().endsWith("."+ext)){
470 if (!f.getTitle().startsWith(".")){
471 boolean isSignet = false;
472 String extension = f.getExtension();
473 if(extension.contains("html")){
474 isSignet = DLEntryUtil.isSignetFile(f);
476 JSONObject ob = JSONFactoryUtil.createJSONObject();
477 ob.put("id", f.getFileEntryId());
478 ob.put("text", f.getTitle());
479 ob.put("leaf", true);
480 ob.put("draggable", true);
481 ob.put("iconCls", isSignet?"file-signet":"file-" + f.getExtension());
482 ob.put("isSignet", isSignet);
483 String contentType = MimeTypesOverrideUtil.getContentType(f.getTitle().toLowerCase());
484 if(contentType.contains("image")){
486 ob.put("url", themeDisplay.getPathMain() + "/document_library/get_file?p_l_id=" + themeDisplay.getPlid() + "&fileEntryId=" + f.getFileEntryId() + "&token=" + d.getTime() + "&contentDispo=inline&imageThumbnail=true");
487 byte[] image = FileUtil.getBytes(f.getContentStream());
488 RenderedImage renderedImage = ImageToolUtil.read(image).getRenderedImage();
489 ob.put("imageWidth", renderedImage.getWidth());
490 ob.put("imageHeight", renderedImage.getHeight());
497 } catch (Exception e) {}
502 public static JSONArray getListesAmisViewAsJSON(long userId, long parentId) {
503 JSONArray ret = JSONFactoryUtil.createJSONArray();
506 final List<FriendFolder> listFF = FriendFolderLocalServiceUtil.getFriendFolderByUserIDParentFolderId(userId, parentId);
507 for (FriendFolder f : listFF) {
508 JSONObject ob = JSONFactoryUtil.createJSONObject();
511 ob.put("id", f.getFriendFolderId());
512 ob.put("text", f.getName());
515 ob.put("folderId", f.getFriendFolderId());
516 ob.put("listName", f.getName());
517 ob.put("isDisplayed", true);
518 ob.put("leaf", false);
521 } catch (Exception e) {}
526 * This method get the subfolder of the folder in parameter
527 * @param pParentFolder Folder the method get the subfolder
528 * @return Return LIst of DLFolder which are contains in pParentFolder
530 public static List<DLFolder> getSubFolders(Folder pParentFolder){
531 List<DLFolder> subFolder = new ArrayList<DLFolder>();
533 //We want to return all the organizations and the org roots. So we search for then as well without taking all their tree path.
534 ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(),"portletClassLoader");
535 DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(DLFolder.class,classLoader);
536 Criterion criterionParentFolder = null;
537 Criterion criterionRepository = null;
538 Criterion criterionAnd = null;
540 criterionParentFolder = RestrictionsFactoryUtil.eq("parentFolderId",pParentFolder.getFolderId());
541 criterionRepository = RestrictionsFactoryUtil.eq("repositoryId",pParentFolder.getRepositoryId());
542 criterionAnd = RestrictionsFactoryUtil.and(criterionParentFolder, criterionRepository);
544 dynamicQuery.add(criterionAnd);
546 subFolder = DLFolderLocalServiceUtil.dynamicQuery(dynamicQuery);
547 } catch (SystemException e1) {
551 if(subFolder == null || subFolder.size() == 0){
552 return new ArrayList<DLFolder>();
555 // dynamic query returns unmodifiedList, need to cas it
556 return new ArrayList<DLFolder>(subFolder);
560 * This method get file in folder in parameter
561 * @param pParentFolder Folder wherein the method search the file entry
562 * @return List<DLFileEntry> of file in pParentFOlder
564 public static List<DLFileEntry> getFilesEntriesInFolder(Folder pParentFolder){
565 List<DLFileEntry> filesEntries = new ArrayList<DLFileEntry>();
566 //We want to return all the organizations and the org roots. So we search for then as well without taking all their tree path.
567 ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(),"portletClassLoader");
568 DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(DLFileEntry.class,classLoader);
569 Criterion criterionFolder = null;
570 Criterion criterionRepository = null;
571 Criterion criterionAnd = null;
572 // filter on folderId and repository id
573 criterionFolder = RestrictionsFactoryUtil.eq("folderId",pParentFolder.getFolderId());
574 criterionRepository = RestrictionsFactoryUtil.eq("repositoryId",pParentFolder.getRepositoryId());
575 criterionAnd = RestrictionsFactoryUtil.and(criterionFolder, criterionRepository);
577 dynamicQuery.add(criterionAnd);
580 filesEntries = DLFolderLocalServiceUtil.dynamicQuery(dynamicQuery);
581 } catch (SystemException e1) {
585 if(filesEntries == null || filesEntries.size() == 0){
586 return new ArrayList<DLFileEntry>();
589 // dynamic query returns unmodifiedList, need to cas it
590 return new ArrayList<DLFileEntry>(filesEntries);