This is an automated email from the git hooks/post-receive script. New commit to branch develop-1.1.x in repository faxtomail. See http://git.codelutin.com/faxtomail.git commit 5e36803ef3b38a0ac39d23403cca1e6eb5d00775 Author: Kevin Morin <morin@codelutin.com> Date: Fri Oct 30 15:52:04 2015 +0100 enregistrement de tous les droits de lecture sur les dossiers (même ceux des parents) pour plus de rapidité dans les recherches (fixes #7683) --- .../services/service/ConfigurationServiceImpl.java | 6 +++ .../services/service/EmailServiceImpl.java | 49 +--------------------- .../services/service/MailFolderService.java | 2 + .../services/service/MailFolderServiceImpl.java | 15 ++++--- .../src/main/webapp/js/configuration.js | 15 +++++++ .../src/main/webapp/js/configuration.js | 2 +- 6 files changed, 35 insertions(+), 54 deletions(-) diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java index 4a10c85..9a2e02b 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/ConfigurationServiceImpl.java @@ -312,6 +312,12 @@ public class ConfigurationServiceImpl extends FaxToMailServiceSupport implements currentMailFolder.setCompany(parent.getCompany()); } + // set the reading rights on all the children for the search to be easier + if (parent != null) { + currentMailFolder.addAllReadRightUsers(parent.getReadRightUsers()); + currentMailFolder.addAllReadRightGroups(parent.getReadRightGroups()); + } + if (!currentMailFolder.isPersisted()) { currentMailFolder = dao.create(currentMailFolder); } diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java index a4b418a..300aad0 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java @@ -943,37 +943,10 @@ public class EmailServiceImpl extends FaxToMailServiceSupport implements EmailSe } } - /** - * Calcule recursivement l'ensemble des répertoires lisible par un utilisateur récursivement. - * - * @param readMailFolders result mail folders - * @param mailFolders mail folder to allow - */ - protected void computeUserReadableFolder(Set<MailFolder> readMailFolders, Iterable<MailFolder> mailFolders) { - if (mailFolders != null) { - for (MailFolder mailFolder : mailFolders) { - readMailFolders.add(mailFolder); - computeUserReadableFolder(readMailFolders, mailFolder.getChildren()); - } - } - } - @Override public PaginationResult<Email> search(SearchFilter emailFilter, FaxToMailUser user, PaginationParameter pagination) { - // compute rigths - MailFolderTopiaDao mailFolderDao = getPersistenceContext().getMailFolderDao(); - Set<MailFolder> readMailFolders = new HashSet<MailFolder>(); - // read rights for user - Iterable<MailFolder> mailFolders = mailFolderDao.forReadRightUsersContains(user).findAll(); - computeUserReadableFolder(readMailFolders, mailFolders); - // read rigths for groups - if (user.getUserGroups() != null) { - for (FaxToMailUserGroup group : user.getUserGroups()) { - mailFolders = mailFolderDao.forReadRightGroupsContains(group).findAll(); - computeUserReadableFolder(readMailFolders, mailFolders); - } - } + Set<MailFolder> readMailFolders = getMailFolderService().getAllMailFoldersWithReadingRights(user); // compute search EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); @@ -989,31 +962,11 @@ public class EmailServiceImpl extends FaxToMailServiceSupport implements EmailSe MailFolderTopiaDao mailFolderDao = getPersistenceContext().getMailFolderDao(); Collection<MailFolder> companyFolders = mailFolderDao.forCompanyEquals(company).findAll(); Set<MailFolder> archiveFolders = new HashSet<>(companyFolders); -// for (MailFolder folder : companyFolders) { -// Collection<MailFolder> children = folder.getChildren(); -// if (children != null) { -// for (MailFolder child : children) { -// findCompanyFoldersChildren(child, archiveFolders); -// } -// } -// } EmailTopiaDao emailDao = getPersistenceContext().getEmailDao(); return emailDao.findArchivedEmails(commandQuotationNumber, archiveFolders); } - protected void findCompanyFoldersChildren(MailFolder folder, Set<MailFolder> archiveFolders) { - if (!folder.isUseCurrentLevelCompany()) { - archiveFolders.add(folder); - Collection<MailFolder> children = folder.getChildren(); - if (children != null) { - for (MailFolder child : children) { - findCompanyFoldersChildren(child, archiveFolders); - } - } - } - } - @Override public Email groupEmails(String email1Id, String email2Id, FaxToMailUser user) { EmailGroupTopiaDao groupDao = getPersistenceContext().getEmailGroupDao(); diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java index 94d126c..69789fe 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderService.java @@ -53,6 +53,8 @@ public interface MailFolderService extends FaxToMailService { List<MailFolder> getRootMailFoldersWithReadingRights(FaxToMailUser user); + Set<MailFolder> getAllMailFoldersWithReadingRights(FaxToMailUser user); + List<MailFolder> getRootMailFoldersWithMoveRights(FaxToMailUser user); List<MailFolder> getMailFolders(Collection<String> ids); diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java index c00ed91..1ace3ec 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/MailFolderServiceImpl.java @@ -88,7 +88,7 @@ public class MailFolderServiceImpl extends FaxToMailServiceSupport implements Ma @Override public List<MailFolder> getAllMailFolders() { MailFolderTopiaDao dao = getPersistenceContext().getMailFolderDao(); - return new ArrayList<MailFolder>(dao.findAll()); + return new ArrayList<>(dao.findAll()); } @Override @@ -129,13 +129,19 @@ public class MailFolderServiceImpl extends FaxToMailServiceSupport implements Ma } if (folder != null) { - browseReadableFolders(folder, result, user, false); + browseReadableFolders(folder, user, false); } } return result; } - protected void browseReadableFolders(MailFolder folder, List<MailFolder> readableRoots, FaxToMailUser user, boolean writable) { + @Override + public Set<MailFolder> getAllMailFoldersWithReadingRights(FaxToMailUser user) { + MailFolderTopiaDao dao = getPersistenceContext().getMailFolderDao(); + return new HashSet<>(dao.getReadableFolders(user)); + } + + protected void browseReadableFolders(MailFolder folder, FaxToMailUser user, boolean writable) { folder.setFolderReadable(true); if (!writable && folder.sizeWriteRightGroups() > 0) { @@ -148,7 +154,7 @@ public class MailFolderServiceImpl extends FaxToMailServiceSupport implements Ma if (folder.isChildrenNotEmpty()) { for (MailFolder child : folder.getChildren()) { - browseReadableFolders(child, readableRoots, user, writable); + browseReadableFolders(child, user, writable); } } @@ -353,5 +359,4 @@ public class MailFolderServiceImpl extends FaxToMailServiceSupport implements Ma return filter; } - } diff --git a/faxtomail-ui-web/src/main/webapp/js/configuration.js b/faxtomail-ui-web/src/main/webapp/js/configuration.js index c3804b4..ed5cadc 100644 --- a/faxtomail-ui-web/src/main/webapp/js/configuration.js +++ b/faxtomail-ui-web/src/main/webapp/js/configuration.js @@ -91,6 +91,21 @@ ConfigurationModule.controller('ConfigurationController', ['$scope', 'Configurat // et on modifie encore (tant qu'on a commencé !!!) mailFolder.$cumulativeCount = folderCount; cumulativeCount += folderCount; + + // et on supprime les droits de lecture qui sont déjà dans les parents + angular.forEach(mailFolder.readRightUsers, function(user) { + if (parent.readRightUsers.containsByTopiaId(user)) { + var index = mailFolder.readRightUsers.indexOfByTopiaId(user); + mailFolder.readRightUsers.splice(index, 1); + } + }); + + angular.forEach(mailFolder.readRightGroups, function(group) { + if (parent.readRightGroups.containsByTopiaId(group)) { + var index = mailFolder.readRightGroups.indexOfByTopiaId(group); + mailFolder.readRightGroups.splice(index, 1); + } + }); }); } return cumulativeCount; diff --git a/trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js b/trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js index c3804b4..4963044 100644 --- a/trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js +++ b/trunk/faxtomail-ui-web/src/main/webapp/js/configuration.js @@ -720,7 +720,7 @@ ConfigurationModule.controller('ConfigurationTreeController', ['$scope', '$windo $scope.parentScopeValues.ranges = folder.ranges; } - // move to parent first to keed parent order for collection + // move to parent first to keep parent order for collection if (folder.$parent) { updateParentScopeValues(folder.$parent); }; -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.