Project

General

Profile

Bug #692 » patchBug692.patch

Nicolas Eysseric, 06/29/2010 03:45 PM

View differences:

src/main/java/com/stratelia/webactiv/beans/admin/Admin.java (working copy)
48 48
import com.stratelia.silverpeas.util.SilverpeasSettings;
49 49
import com.stratelia.webactiv.SilverpeasRole;
50 50
import com.stratelia.webactiv.beans.admin.cache.AdminCache;
51
import com.stratelia.webactiv.beans.admin.cache.GroupCache;
51 52
import com.stratelia.webactiv.beans.admin.cache.Space;
52 53
import com.stratelia.webactiv.beans.admin.cache.TreeCache;
53 54
import com.stratelia.webactiv.beans.admin.instance.control.Instanciateur;
......
1176 1177
      String componentName = componentInst.getName();
1177 1178
      String componentId = componentName + componentInst.getId();
1178 1179

  
1179
      String[] asCompoNames = {componentName};
1180
      String[] asCompoIds = {componentId};
1180
      String[] asCompoNames = { componentName };
1181
      String[] asCompoIds = { componentId };
1181 1182
      instantiateComponents(sUserId, asCompoIds, asCompoNames, spaceInstFather.getId(),
1182 1183
          connectionProd);
1183 1184

  
......
1301 1302

  
1302 1303
        // Uninstantiate the components
1303 1304
        String componentName = componentInst.getName();
1304
        String[] asCompoName = {componentName};
1305
        String[] asCompoId = {sClientComponentId};
1305
        String[] asCompoName = { componentName };
1306
        String[] asCompoId = { sClientComponentId };
1306 1307
        unInstantiateComponents(sUserId, asCompoId, asCompoName,
1307 1308
            getClientSpaceId(sFatherClientId), connectionProd);
1308 1309

  
......
1694 1695
      m_Cache.resetComponentInst();
1695 1696

  
1696 1697
      // reset treecache list in old and new spaces
1697
      TreeCache.setComponents(getDriverSpaceId(oldSpaceId), m_ComponentInstManager.getComponentsInSpace(Integer.parseInt(getDriverSpaceId(oldSpaceId))));
1698
      TreeCache.setComponents(getDriverSpaceId(spaceId), m_ComponentInstManager.getComponentsInSpace(Integer.parseInt(getDriverSpaceId(spaceId))));
1698
      TreeCache.setComponents(getDriverSpaceId(oldSpaceId), m_ComponentInstManager
1699
          .getComponentsInSpace(Integer.parseInt(getDriverSpaceId(oldSpaceId))));
1700
      TreeCache.setComponents(getDriverSpaceId(spaceId), m_ComponentInstManager
1701
          .getComponentsInSpace(Integer.parseInt(getDriverSpaceId(spaceId))));
1699 1702
    } catch (Exception e) {
1700 1703
      rollback();
1701 1704
      throw new AdminException("Admin.moveComponentInst",
......
1822 1825

  
1823 1826
    List<String> groups = getAllGroupsOfUser(userId);
1824 1827

  
1825
    return m_ProfiledObjectManager.getUserProfileNames(objectId, objectType, Integer.parseInt(getDriverComponentId(componentId)),
1828
    return m_ProfiledObjectManager.getUserProfileNames(objectId, objectType, Integer
1829
        .parseInt(getDriverComponentId(componentId)),
1826 1830
        Integer.parseInt(userId), groups);
1827 1831
  }
1828 1832

  
......
2809 2813
        m_DDManager.startTransaction(false);
2810 2814

  
2811 2815
        GroupProfileInst oldSpaceProfile =
2812
            m_GroupProfileInstManager.getGroupProfileInst(m_DDManager, null, groupProfileInstNew.getGroupId());
2816
            m_GroupProfileInstManager.getGroupProfileInst(m_DDManager, null, groupProfileInstNew
2817
                .getGroupId());
2813 2818

  
2814 2819
        // Update the group profile in tables
2815 2820
        m_GroupProfileInstManager.updateGroupProfileInst(oldSpaceProfile,
......
3607 3612
  }
3608 3613

  
3609 3614
  private List<String> getAllGroupsOfUser(String userId) throws AdminException {
3610
    List<String> allGroupsOfUser = new ArrayList<String>();
3611
    String[] directGroupIds = m_GroupManager.getDirectGroupsOfUser(m_DDManager, userId);
3612
    for (int g = 0; g < directGroupIds.length; g++) {
3613
      Group group = m_GroupManager.getGroup(directGroupIds[g], false); // TODO: cacher les groupes
3614
      if (group != null) {
3615
        allGroupsOfUser.add(group.getId());
3616
        while (StringUtil.isDefined(group.getSuperGroupId())) {
3617
          group = m_GroupManager.getGroup(group.getSuperGroupId(), false);
3618
          if (group != null) {
3619
            allGroupsOfUser.add(group.getId());
3615
    List<String> allGroupsOfUser = GroupCache.getAllGroupIdsOfUser(userId);
3616
    if (allGroupsOfUser == null) {
3617
      // group ids of user is not yet processed
3618
      // process it and store it in cache
3619
      allGroupsOfUser = new ArrayList<String>();
3620
      String[] directGroupIds = m_GroupManager.getDirectGroupsOfUser(m_DDManager, userId);
3621
      for (int g = 0; g < directGroupIds.length; g++) {
3622
        Group group = m_GroupManager.getGroup(directGroupIds[g], false);
3623
        if (group != null) {
3624
          allGroupsOfUser.add(group.getId());
3625
          while (StringUtil.isDefined(group.getSuperGroupId())) {
3626
            group = m_GroupManager.getGroup(group.getSuperGroupId(), false);
3627
            if (group != null) {
3628
              allGroupsOfUser.add(group.getId());
3629
            }
3620 3630
          }
3621 3631
        }
3622 3632
      }
3633
      // store groupIds of user in cache
3634
      GroupCache.setAllGroupIdsOfUser(userId, allGroupsOfUser);
3623 3635
    }
3624 3636
    return allGroupsOfUser;
3625 3637
  }
......
4936 4948
              // All users by access level
4937 4949
              if (domainId == null) {
4938 4950
                userIds =
4939
                    Arrays.asList(m_DDManager.organization.user.getUserIdsByAccessLevel(accessLevel));
4951
                    Arrays.asList(m_DDManager.organization.user
4952
                        .getUserIdsByAccessLevel(accessLevel));
4940 4953
              } else {
4941 4954
                userIds =
4942 4955
                    Arrays.asList(m_UserManager.getUserIdsOfDomainAndAccessLevel(m_DDManager,
......
4951 4964
            // Available only for "domaine mixte"
4952 4965
            if ("-1".equals(domainId)) {
4953 4966
              userIds =
4954
                  Arrays.asList(m_DDManager.organization.user.getUserIdsOfDomain(Integer.parseInt(dId)));
4967
                  Arrays.asList(m_DDManager.organization.user.getUserIdsOfDomain(Integer
4968
                      .parseInt(dId)));
4955 4969
            }
4956 4970
          }
4957 4971
        } else if (rule.toLowerCase().startsWith("dc_")) {
......
5424 5438
      }
5425 5439
    }
5426 5440
    if ((parentId == null)
5427
        && ((parentSpecificIds.length > 0) || ((askedParentId != null) && (askedParentId.length() > 0)))) {// We
5441
        &&
5442
        ((parentSpecificIds.length > 0) || ((askedParentId != null) && (askedParentId.length() > 0)))) {// We
5428 5443
      // can't
5429 5444
      // add
5430 5445
      // the
......
5479 5494
        existingGroupId = null;
5480 5495
        try {
5481 5496
          existingGroupId =
5482
              m_GroupManager.getGroupIdBySpecificIdAndDomainId(m_DDManager, childs[i].getSpecificId(), latestGroup.getDomainId());
5497
              m_GroupManager.getGroupIdBySpecificIdAndDomainId(m_DDManager, childs[i]
5498
                  .getSpecificId(), latestGroup.getDomainId());
5483 5499
          existingGroup = getGroup(existingGroupId);
5484 5500
          if (existingGroup.getSuperGroupId().equals(latestGroup.getId())) { // Only
5485 5501
            // synchronize
src/main/java/com/stratelia/webactiv/beans/admin/cache/GroupCache.java (revision 0)
1
/**
2
 * Copyright (C) 2000 - 2009 Silverpeas
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU Affero General Public License as
6
 * published by the Free Software Foundation, either version 3 of the
7
 * License, or (at your option) any later version.
8
 *
9
 * As a special exception to the terms and conditions of version 3.0 of
10
 * the GPL, you may redistribute this Program in connection with Free/Libre
11
 * Open Source Software ("FLOSS") applications as described in Silverpeas's
12
 * FLOSS exception.  You should have received a copy of the text describing
13
 * the FLOSS exception, and it is also available here:
14
 * "http://repository.silverpeas.com/legal/licensing"
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 */
24

  
25
package com.stratelia.webactiv.beans.admin.cache;
26

  
27
import java.util.List;
28
import java.util.concurrent.ConcurrentHashMap;
29
import java.util.concurrent.ConcurrentMap;
30

  
31
public class GroupCache {
32

  
33
  private static ConcurrentMap<String, List<String>> map =
34
      new ConcurrentHashMap<String, List<String>>();
35

  
36
  public static void clearCache() {
37
    map.clear();
38
  }
39

  
40
  public static List<String> getAllGroupIdsOfUser(String userId) {
41
    return map.get(userId);
42
  }
43

  
44
  public static void setAllGroupIdsOfUser(String userId, List<String> groupIds) {
45
    map.put(userId, groupIds);
46
  }
47
  
48
  public static void removeCacheOfUser(String userId) {
49
    map.remove(userId);
50
  }
51

  
52
}
src/main/java/com/stratelia/webactiv/organization/GroupTable.java (working copy)
34 34
import com.stratelia.silverpeas.silvertrace.SilverTrace;
35 35
import com.stratelia.webactiv.beans.admin.SynchroGroupReport;
36 36
import com.stratelia.webactiv.beans.admin.SynchroReport;
37
import com.stratelia.webactiv.beans.admin.cache.GroupCache;
37 38
import com.stratelia.webactiv.util.exception.SilverpeasException;
38 39

  
39 40
/**
......
723 724
        "Ajout de l'utilisateur d'ID " + userId + " dans le groupe d'ID "
724 725
        + groupId + ", requête : " + INSERT_A_GROUP_USER_REL, null);
725 726
    updateRelation(INSERT_A_GROUP_USER_REL, params);
727
    GroupCache.removeCacheOfUser(Integer.toString(userId));
726 728
  }
727 729

  
728 730
  /**
......
763 765
            "Ajout de l'utilisateur d'ID " + userId + " dans le groupe d'ID "
764 766
            + groupId + ", requête : " + INSERT_A_GROUP_USER_REL, null);
765 767
        updateRelation(INSERT_A_GROUP_USER_REL, params);
768
        GroupCache.removeCacheOfUser(Integer.toString(userId));
766 769
      }
767 770
    }
768 771
  }
......
786 789
        "Retrait de l'utilisateur d'ID " + userId + " du groupe d'ID "
787 790
        + groupId + ", requête : " + DELETE_GROUP_USER_REL, null);
788 791
    updateRelation(DELETE_GROUP_USER_REL, params);
792
    GroupCache.removeCacheOfUser(Integer.toString(userId));
789 793
  }
790 794

  
791 795
  static final private String DELETE_GROUP_USER_REL =
......
821 825
            "Retrait de l'utilisateur d'ID " + userId + " du groupe d'ID "
822 826
            + groupId + ", requête : " + DELETE_GROUP_USER_REL, null);
823 827
        updateRelation(DELETE_GROUP_USER_REL, params);
828
        GroupCache.removeCacheOfUser(Integer.toString(userId));
824 829
      } else {
825 830
        throw new AdminPersistenceException(
826 831
            "GroupTable.removeUsersFromGroup()", SilverpeasException.ERROR,
    (1-1/1)