r1322 - trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service
Author: glandais Date: 2008-03-12 17:06:45 +0000 (Wed, 12 Mar 2008) New Revision: 1322 Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java Log: Avoid group recursion Modified: trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java 2008-03-12 17:06:24 UTC (rev 1321) +++ trunk/simexplorer-is/simexplorer-is-service/src/java/fr/cemagref/simexplorer/is/service/AuthenticationServiceImpl.java 2008-03-12 17:06:45 UTC (rev 1322) @@ -736,6 +736,27 @@ throw new SimExplorerSecurityException(); } + /** + * Checks if container contains contained. + * + * @param container the group container + * @param contained the group contained + * + * @return true, if is containing + */ + private boolean isContaining(Group container, Group contained) { + if (container.getId().equals(contained.getId())) { + return true; + } + List<Group> groups = container.getGroups(); + for (Group group : groups) { + if (isContaining(group, contained)) { + return true; + } + } + return false; + } + /* (non-Javadoc) * @see fr.cemagref.simexplorer.is.service.AuthenticationService#setGroupsOfGroup(java.lang.String, fr.cemagref.simexplorer.is.security.entities.Group, java.lang.Integer[]) */ @@ -745,7 +766,9 @@ realGroup.getGroups().clear(); for (Integer groupsId : groupsIds) { Group groupOwned = daoActor.getGroup(groupsId); - realGroup.getGroups().add(groupOwned); + if (!isContaining(groupOwned, realGroup)) { + realGroup.getGroups().add(groupOwned); + } } daoActor.updateGroup(realGroup); } else { @@ -805,7 +828,13 @@ return credentialManager.getPermissionsOwnedByCount(user); } +/* + public Object debugQuery(String query, int type) { + return daoActor.debugQuery(query, type); + } +*/ + { I18n.initISO88591("fr", "FR"); }
participants (1)
-
glandais@users.labs.libre-entreprise.org