Index: src/main/java/com/stratelia/webactiv/beans/admin/Admin.java =================================================================== --- src/main/java/com/stratelia/webactiv/beans/admin/Admin.java (revision 1789) +++ src/main/java/com/stratelia/webactiv/beans/admin/Admin.java (working copy) @@ -48,6 +48,7 @@ import com.stratelia.silverpeas.util.SilverpeasSettings; import com.stratelia.webactiv.SilverpeasRole; import com.stratelia.webactiv.beans.admin.cache.AdminCache; +import com.stratelia.webactiv.beans.admin.cache.GroupCache; import com.stratelia.webactiv.beans.admin.cache.Space; import com.stratelia.webactiv.beans.admin.cache.TreeCache; import com.stratelia.webactiv.beans.admin.instance.control.Instanciateur; @@ -1176,8 +1177,8 @@ String componentName = componentInst.getName(); String componentId = componentName + componentInst.getId(); - String[] asCompoNames = {componentName}; - String[] asCompoIds = {componentId}; + String[] asCompoNames = { componentName }; + String[] asCompoIds = { componentId }; instantiateComponents(sUserId, asCompoIds, asCompoNames, spaceInstFather.getId(), connectionProd); @@ -1301,8 +1302,8 @@ // Uninstantiate the components String componentName = componentInst.getName(); - String[] asCompoName = {componentName}; - String[] asCompoId = {sClientComponentId}; + String[] asCompoName = { componentName }; + String[] asCompoId = { sClientComponentId }; unInstantiateComponents(sUserId, asCompoId, asCompoName, getClientSpaceId(sFatherClientId), connectionProd); @@ -1694,8 +1695,10 @@ m_Cache.resetComponentInst(); // reset treecache list in old and new spaces - TreeCache.setComponents(getDriverSpaceId(oldSpaceId), m_ComponentInstManager.getComponentsInSpace(Integer.parseInt(getDriverSpaceId(oldSpaceId)))); - TreeCache.setComponents(getDriverSpaceId(spaceId), m_ComponentInstManager.getComponentsInSpace(Integer.parseInt(getDriverSpaceId(spaceId)))); + TreeCache.setComponents(getDriverSpaceId(oldSpaceId), m_ComponentInstManager + .getComponentsInSpace(Integer.parseInt(getDriverSpaceId(oldSpaceId)))); + TreeCache.setComponents(getDriverSpaceId(spaceId), m_ComponentInstManager + .getComponentsInSpace(Integer.parseInt(getDriverSpaceId(spaceId)))); } catch (Exception e) { rollback(); throw new AdminException("Admin.moveComponentInst", @@ -1822,7 +1825,8 @@ List groups = getAllGroupsOfUser(userId); - return m_ProfiledObjectManager.getUserProfileNames(objectId, objectType, Integer.parseInt(getDriverComponentId(componentId)), + return m_ProfiledObjectManager.getUserProfileNames(objectId, objectType, Integer + .parseInt(getDriverComponentId(componentId)), Integer.parseInt(userId), groups); } @@ -2809,7 +2813,8 @@ m_DDManager.startTransaction(false); GroupProfileInst oldSpaceProfile = - m_GroupProfileInstManager.getGroupProfileInst(m_DDManager, null, groupProfileInstNew.getGroupId()); + m_GroupProfileInstManager.getGroupProfileInst(m_DDManager, null, groupProfileInstNew + .getGroupId()); // Update the group profile in tables m_GroupProfileInstManager.updateGroupProfileInst(oldSpaceProfile, @@ -3607,19 +3612,26 @@ } private List getAllGroupsOfUser(String userId) throws AdminException { - List allGroupsOfUser = new ArrayList(); - String[] directGroupIds = m_GroupManager.getDirectGroupsOfUser(m_DDManager, userId); - for (int g = 0; g < directGroupIds.length; g++) { - Group group = m_GroupManager.getGroup(directGroupIds[g], false); // TODO: cacher les groupes - if (group != null) { - allGroupsOfUser.add(group.getId()); - while (StringUtil.isDefined(group.getSuperGroupId())) { - group = m_GroupManager.getGroup(group.getSuperGroupId(), false); - if (group != null) { - allGroupsOfUser.add(group.getId()); + List allGroupsOfUser = GroupCache.getAllGroupIdsOfUser(userId); + if (allGroupsOfUser == null) { + // group ids of user is not yet processed + // process it and store it in cache + allGroupsOfUser = new ArrayList(); + String[] directGroupIds = m_GroupManager.getDirectGroupsOfUser(m_DDManager, userId); + for (int g = 0; g < directGroupIds.length; g++) { + Group group = m_GroupManager.getGroup(directGroupIds[g], false); + if (group != null) { + allGroupsOfUser.add(group.getId()); + while (StringUtil.isDefined(group.getSuperGroupId())) { + group = m_GroupManager.getGroup(group.getSuperGroupId(), false); + if (group != null) { + allGroupsOfUser.add(group.getId()); + } } } } + // store groupIds of user in cache + GroupCache.setAllGroupIdsOfUser(userId, allGroupsOfUser); } return allGroupsOfUser; } @@ -4936,7 +4948,8 @@ // All users by access level if (domainId == null) { userIds = - Arrays.asList(m_DDManager.organization.user.getUserIdsByAccessLevel(accessLevel)); + Arrays.asList(m_DDManager.organization.user + .getUserIdsByAccessLevel(accessLevel)); } else { userIds = Arrays.asList(m_UserManager.getUserIdsOfDomainAndAccessLevel(m_DDManager, @@ -4951,7 +4964,8 @@ // Available only for "domaine mixte" if ("-1".equals(domainId)) { userIds = - Arrays.asList(m_DDManager.organization.user.getUserIdsOfDomain(Integer.parseInt(dId))); + Arrays.asList(m_DDManager.organization.user.getUserIdsOfDomain(Integer + .parseInt(dId))); } } } else if (rule.toLowerCase().startsWith("dc_")) { @@ -5424,7 +5438,8 @@ } } if ((parentId == null) - && ((parentSpecificIds.length > 0) || ((askedParentId != null) && (askedParentId.length() > 0)))) {// We + && + ((parentSpecificIds.length > 0) || ((askedParentId != null) && (askedParentId.length() > 0)))) {// We // can't // add // the @@ -5479,7 +5494,8 @@ existingGroupId = null; try { existingGroupId = - m_GroupManager.getGroupIdBySpecificIdAndDomainId(m_DDManager, childs[i].getSpecificId(), latestGroup.getDomainId()); + m_GroupManager.getGroupIdBySpecificIdAndDomainId(m_DDManager, childs[i] + .getSpecificId(), latestGroup.getDomainId()); existingGroup = getGroup(existingGroupId); if (existingGroup.getSuperGroupId().equals(latestGroup.getId())) { // Only // synchronize Index: src/main/java/com/stratelia/webactiv/beans/admin/cache/GroupCache.java =================================================================== --- src/main/java/com/stratelia/webactiv/beans/admin/cache/GroupCache.java (revision 0) +++ src/main/java/com/stratelia/webactiv/beans/admin/cache/GroupCache.java (revision 0) @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2000 - 2009 Silverpeas + * + * This program is free software: you can redistribute it and/or modify + * it 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. + * + * As a special exception to the terms and conditions of version 3.0 of + * the GPL, you may redistribute this Program in connection with Free/Libre + * Open Source Software ("FLOSS") applications as described in Silverpeas's + * FLOSS exception. You should have received a copy of the text describing + * the FLOSS exception, and it is also available here: + * "http://repository.silverpeas.com/legal/licensing" + * + * This program 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 + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.stratelia.webactiv.beans.admin.cache; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +public class GroupCache { + + private static ConcurrentMap> map = + new ConcurrentHashMap>(); + + public static void clearCache() { + map.clear(); + } + + public static List getAllGroupIdsOfUser(String userId) { + return map.get(userId); + } + + public static void setAllGroupIdsOfUser(String userId, List groupIds) { + map.put(userId, groupIds); + } + + public static void removeCacheOfUser(String userId) { + map.remove(userId); + } + +} Index: src/main/java/com/stratelia/webactiv/organization/GroupTable.java =================================================================== --- src/main/java/com/stratelia/webactiv/organization/GroupTable.java (revision 1789) +++ src/main/java/com/stratelia/webactiv/organization/GroupTable.java (working copy) @@ -34,6 +34,7 @@ import com.stratelia.silverpeas.silvertrace.SilverTrace; import com.stratelia.webactiv.beans.admin.SynchroGroupReport; import com.stratelia.webactiv.beans.admin.SynchroReport; +import com.stratelia.webactiv.beans.admin.cache.GroupCache; import com.stratelia.webactiv.util.exception.SilverpeasException; /** @@ -723,6 +724,7 @@ "Ajout de l'utilisateur d'ID " + userId + " dans le groupe d'ID " + groupId + ", requête : " + INSERT_A_GROUP_USER_REL, null); updateRelation(INSERT_A_GROUP_USER_REL, params); + GroupCache.removeCacheOfUser(Integer.toString(userId)); } /** @@ -763,6 +765,7 @@ "Ajout de l'utilisateur d'ID " + userId + " dans le groupe d'ID " + groupId + ", requête : " + INSERT_A_GROUP_USER_REL, null); updateRelation(INSERT_A_GROUP_USER_REL, params); + GroupCache.removeCacheOfUser(Integer.toString(userId)); } } } @@ -786,6 +789,7 @@ "Retrait de l'utilisateur d'ID " + userId + " du groupe d'ID " + groupId + ", requête : " + DELETE_GROUP_USER_REL, null); updateRelation(DELETE_GROUP_USER_REL, params); + GroupCache.removeCacheOfUser(Integer.toString(userId)); } static final private String DELETE_GROUP_USER_REL = @@ -821,6 +825,7 @@ "Retrait de l'utilisateur d'ID " + userId + " du groupe d'ID " + groupId + ", requête : " + DELETE_GROUP_USER_REL, null); updateRelation(DELETE_GROUP_USER_REL, params); + GroupCache.removeCacheOfUser(Integer.toString(userId)); } else { throw new AdminPersistenceException( "GroupTable.removeUsersFromGroup()", SilverpeasException.ERROR,