[gatein-commits] gatein SVN: r775 - in portal/trunk: component/application-registry/src/test/java/conf/portal and 13 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Nov 23 19:35:59 EST 2009


Author: dbaeli
Date: 2009-11-23 19:35:57 -0500 (Mon, 23 Nov 2009)
New Revision: 775

Added:
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java
Removed:
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/idm/
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java
   portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java
Modified:
   portal/trunk/component/application-registry/src/test/java/conf/portal/idm-configuration.xml
   portal/trunk/component/identity/pom.xml
   portal/trunk/component/identity/src/main/java/conf/portal/hibernate-jbidm.cfg.xml
   portal/trunk/component/identity/src/main/java/conf/portal/idm-config.xml
   portal/trunk/component/identity/src/main/java/conf/portal/jboss-idm-configuration.xml
   portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml
   portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestOrganizationService.java
   portal/trunk/component/portal/pom.xml
   portal/trunk/component/portal/src/test/java/conf/portal/database-configuration.xml
   portal/trunk/component/portal/src/test/java/conf/portal/idm-configuration.xml
   portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
   portal/trunk/docs/user-guide/en/modules/configuration/IDM_Configuration.xml
   portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
   portal/trunk/pom.xml
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/database/database-configuration.xml
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-config.xml
   portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
Log:
Rollback revision 744
- upgrade to PicketLink IDM (former JBoss Identity) 1.0.0.CR1
- remove separate IDM hibernate config

Modified: portal/trunk/component/application-registry/src/test/java/conf/portal/idm-configuration.xml
===================================================================
--- portal/trunk/component/application-registry/src/test/java/conf/portal/idm-configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/application-registry/src/test/java/conf/portal/idm-configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -25,8 +25,8 @@
                xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 
    <component>
-      <key>org.exoplatform.services.organization.idm.PicketLinkIDMService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMServiceImpl</type>
+      <key>org.exoplatform.services.organization.jbidm.JBossIDMService</key>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMServiceImpl</type>
       <init-params>
          <value-param>
             <name>config</name>
@@ -34,18 +34,18 @@
          </value-param>
          <values-param>
             <name>hibernate.annotations</name>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObject</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateRealm</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
          </values-param>
          <properties-param>
             <name>hibernate.properties</name>
@@ -70,7 +70,7 @@
 
    <component>
       <key>org.exoplatform.services.organization.OrganizationService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</type>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</type>
    </component>
 
 </configuration>

Modified: portal/trunk/component/identity/pom.xml
===================================================================
--- portal/trunk/component/identity/pom.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/identity/pom.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -55,24 +55,24 @@
     </dependency>
 
      <dependency>
-        <groupId>org.picketlink.idm</groupId>
-        <artifactId>picketlink-idm-core</artifactId>
-        <version>${org.picketlink.idm}</version>
+        <groupId>org.jboss.identity.idm</groupId>
+        <artifactId>idm-core</artifactId>
+        <version>${org.jboss.identity.idm}</version>
      </dependency>
      <dependency>
-        <groupId>org.picketlink.idm</groupId>
-        <artifactId>picketlink-idm-hibernate</artifactId>
-        <version>${org.picketlink.idm}</version>
+        <groupId>org.jboss.identity.idm</groupId>
+        <artifactId>idm-hibernate</artifactId>
+        <version>${org.jboss.identity.idm}</version>
      </dependency>
      <dependency>
-        <groupId>org.picketlink.idm</groupId>
-        <artifactId>picketlink-idm-ldap</artifactId>
-        <version>${org.picketlink.idm}</version>
+        <groupId>org.jboss.identity.idm</groupId>
+        <artifactId>idm-ldap</artifactId>
+        <version>${org.jboss.identity.idm}</version>
      </dependency>
      <dependency>
-        <groupId>org.picketlink.idm</groupId>
-        <artifactId>picketlink-idm-cache</artifactId>
-        <version>${org.picketlink.idm}</version>
+        <groupId>org.jboss.identity.idm</groupId>
+        <artifactId>idm-cache</artifactId>
+        <version>${org.jboss.identity.idm}</version>
      </dependency>
 
       <!--To use instead of outdated version from xdoclet-->

Modified: portal/trunk/component/identity/src/main/java/conf/portal/hibernate-jbidm.cfg.xml
===================================================================
--- portal/trunk/component/identity/src/main/java/conf/portal/hibernate-jbidm.cfg.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/identity/src/main/java/conf/portal/hibernate-jbidm.cfg.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -41,5 +41,19 @@
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password"></property>
 
+       <!-- Mapping classes -->
+       <!-- all nessesary mappings are added programatically to the configuration -->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateRealm"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType"/>-->
+       <!--<mapping class="org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName"/>-->
+
    </session-factory>
 </hibernate-configuration>
\ No newline at end of file

Modified: portal/trunk/component/identity/src/main/java/conf/portal/idm-config.xml
===================================================================
--- portal/trunk/component/identity/src/main/java/conf/portal/idm-config.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/identity/src/main/java/conf/portal/idm-config.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -20,9 +20,9 @@
 
 -->
 
-<jboss-identity xmlns="urn:picketlink:idm:config:v1_0_0_cr1"
+<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_beta"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                xsi:schemaLocation="urn:picketlink:idm:config:v1_0_0_cr1 identity-config.xsd">
+                xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha identity-config.xsd">
     <realms>
         <realm>
             <id>PortalRealm</id>
@@ -35,7 +35,7 @@
     <repositories>
         <repository>
             <id>PortalRepository</id>
-            <class>org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository</class>
+            <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
             <external-config/>
             <default-identity-store-id>HibernateStore</default-identity-store-id>
             <default-attribute-store-id>HibernateStore</default-attribute-store-id>
@@ -46,7 +46,7 @@
         <identity-stores>
             <identity-store>
                 <id>HibernateStore</id>
-                <class>org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+                <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
                 <external-config/>
                 <supported-relationship-types>
                     <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>

Modified: portal/trunk/component/identity/src/main/java/conf/portal/jboss-idm-configuration.xml
===================================================================
--- portal/trunk/component/identity/src/main/java/conf/portal/jboss-idm-configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/identity/src/main/java/conf/portal/jboss-idm-configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -25,8 +25,8 @@
                xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 
    <component>
-      <key>org.exoplatform.services.organization.idm.PicketLinkIDMService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMServiceImpl</type>
+      <key>org.exoplatform.services.organization.jbidm.JBossIDMService</key>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMServiceImpl</type>
       <init-params>
          <value-param>
             <name>config</name>
@@ -41,7 +41,7 @@
 
    <component>
       <key>org.exoplatform.services.organization.OrganizationService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</type>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</type>
    </component>
 
    <external-component-plugins>
@@ -52,18 +52,19 @@
          <type>org.exoplatform.services.database.impl.AddHibernateMappingPlugin</type>
          <init-params>
             <values-param>
-               <name>hibernate.mapping</name>
-               <value>mappings/HibernateRealm.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttributeBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObject.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredential.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttribute.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationship.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipName.hbm.xml</value>
+               <name>hibernate.annotations</name>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
             </values-param>
          </init-params>
       </component-plugin>

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm)


Property changes on: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm
___________________________________________________________________
Name: svn:ignore
   + *.iml
.idea


Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,459 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.services.organization.Group;
-import org.exoplatform.services.organization.GroupEventListener;
-import org.exoplatform.services.organization.GroupHandler;
-import org.exoplatform.services.organization.impl.GroupImpl;
-import org.jboss.identity.idm.api.Attribute;
-import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.impl.api.SimpleAttribute;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class GroupDAOImpl implements GroupHandler
-{
-
-   public static final String GROUP_LABEL = "label";
-
-   public static final String GROUP_DESCRIPTION = "description";
-
-   private JBossIDMService service_;
-
-   private List<GroupEventListener> listeners_;
-
-   private JBossIDMOrganizationServiceImpl orgService;
-
-   public GroupDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service)
-   {
-      service_ = service;
-      this.orgService = orgService;
-      listeners_ = new ArrayList<GroupEventListener>();
-   }
-
-   public void addGroupEventListener(GroupEventListener listener)
-   {
-      listeners_.add(listener);
-   }
-
-   final public Group createGroupInstance()
-   {
-      return new GroupImpl();
-   }
-
-   public void createGroup(Group group, boolean broadcast) throws Exception
-   {
-      addChild(null, group, broadcast);
-   }
-
-   public void addChild(Group parent, Group child, boolean broadcast) throws Exception
-   {
-      org.jboss.identity.idm.api.Group parentGroup = null;
-
-      if (parent != null)
-      {
-         parentGroup =
-            getIdentitySession().getPersistenceManager().findGroup(parent.getGroupName(), orgService.getExoGroupType());
-         ((GroupImpl)child).setId(parent.getId() + "/" + child.getGroupName());
-
-      }
-      else
-      {
-         ((GroupImpl)child).setId("/" + child.getGroupName());
-      }
-
-      if (broadcast)
-      {
-         preSave(child, true);
-      }
-
-      org.jboss.identity.idm.api.Group childGroup = persistGroup(child);
-
-      if (parentGroup != null)
-      {
-         getIdentitySession().getRelationshipManager().associateGroups(parentGroup, childGroup);
-         ((GroupImpl)child).setParentId(parent.getId());
-
-      }
-      else
-      {
-         getIdentitySession().getRelationshipManager().associateGroups(getRootGroup(), childGroup);
-      }
-
-      if (broadcast)
-      {
-         postSave(child, true);
-      }
-
-   }
-
-   public void saveGroup(Group group, boolean broadcast) throws Exception
-   {
-      if (broadcast)
-      {
-         preSave(group, false);
-      }
-      persistGroup(group);
-      if (broadcast)
-      {
-         postSave(group, false);
-      }
-   }
-
-   public Group removeGroup(Group group, boolean broadcast) throws Exception
-   {
-      if (broadcast)
-      {
-         preDelete(group);
-      }
-
-      org.jboss.identity.idm.api.Group jbidGroup =
-         getIdentitySession().getPersistenceManager().findGroup(group.getGroupName(), orgService.getExoGroupType());
-
-      if (jbidGroup == null)
-      {
-         return group;
-      }
-
-      //      MembershipDAOImpl.removeMembershipEntriesOfGroup(group, getIdentitySession());
-
-      Collection<org.jboss.identity.idm.api.Group> oneLevelChilds =
-         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
-            true, false);
-
-      Collection<org.jboss.identity.idm.api.Group> allChilds =
-         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
-            true, true);
-
-      getIdentitySession().getRelationshipManager().disassociateGroups(jbidGroup, oneLevelChilds);
-
-      for (org.jboss.identity.idm.api.Group child : allChilds)
-      {
-         //TODO: impl force in IDM
-         getIdentitySession().getPersistenceManager().removeGroup(child, true);
-      }
-
-      getIdentitySession().getPersistenceManager().removeGroup(jbidGroup, true);
-
-      if (broadcast)
-      {
-         postDelete(group);
-      }
-      return group;
-   }
-
-   public Collection findGroupByMembership(String userName, String membershipType) throws Exception
-   {
-      Collection<org.jboss.identity.idm.api.Role> allRoles =
-         getIdentitySession().getRoleManager().findRoles(userName, membershipType);
-
-      Set<Group> exoGroups = new HashSet<Group>();
-
-      for (org.jboss.identity.idm.api.Role role : allRoles)
-      {
-         exoGroups.add(convertGroup(role.getGroup()));
-
-      }
-
-      return exoGroups;
-   }
-
-   //
-   public Group findGroupById(String groupId) throws Exception
-   {
-
-      org.jboss.identity.idm.api.Group jbidGroup = orgService.getJBIDMGroup(groupId);
-
-      if (jbidGroup == null)
-      {
-         return null;
-      }
-
-      return convertGroup(jbidGroup);
-   }
-
-   public Collection findGroups(Group parent) throws Exception
-   {
-      org.jboss.identity.idm.api.Group jbidGroup = null;
-
-      if (parent == null)
-      {
-         jbidGroup = getRootGroup();
-      }
-      else
-      {
-         jbidGroup =
-            getIdentitySession().getPersistenceManager().findGroup(parent.getGroupName(), orgService.getExoGroupType());
-      }
-
-      if (jbidGroup == null)
-      {
-         return Collections.emptyList();
-      }
-
-      Collection<org.jboss.identity.idm.api.Group> allGroups =
-         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
-            true, false);
-
-      List<Group> exoGroups = new LinkedList<Group>();
-
-      for (org.jboss.identity.idm.api.Group group : allGroups)
-      {
-         exoGroups.add(convertGroup(group));
-
-      }
-
-      return exoGroups;
-
-   }
-
-   public Collection findGroupsOfUser(String user) throws Exception
-   {
-
-      if (user == null)
-      {
-         // julien : integration bug
-         // need to look at that later
-         //
-         // Caused by: java.lang.IllegalArgumentException: User name cannot be null
-         // at org.jboss.identity.idm.impl.api.session.managers.AbstractManager.checkNotNullArgument(AbstractManager.java:267)
-         //  at org.jboss.identity.idm.impl.api.session.managers.RelationshipManagerImpl.findRelatedGroups(RelationshipManagerImpl.java:753)
-         // at org.exoplatform.services.organization.jbidm.GroupDAOImpl.findGroupsOfUser(GroupDAOImpl.java:225)
-         // at org.exoplatform.organization.webui.component.GroupManagement.isMemberOfGroup(GroupManagement.java:72)
-         // at org.exoplatform.organization.webui.component.GroupManagement.isAdministrator(GroupManagement.java:125)
-         // at org.exoplatform.organization.webui.component.UIGroupExplorer.<init>(UIGroupExplorer.java:57)
-         return Collections.emptyList();
-      }
-
-      Collection<org.jboss.identity.idm.api.Group> allGroups =
-         getIdentitySession().getRelationshipManager().findRelatedGroups(user, orgService.getExoGroupType(), null);
-
-      List<Group> exoGroups = new LinkedList<Group>();
-
-      for (org.jboss.identity.idm.api.Group group : allGroups)
-      {
-         exoGroups.add(convertGroup(group));
-
-      }
-
-      return exoGroups;
-   }
-
-   public Collection getAllGroups() throws Exception
-   {
-      Collection<org.jboss.identity.idm.api.Group> allGroups =
-         getIdentitySession().getPersistenceManager().findGroup(orgService.getExoGroupType());
-
-      List<Group> exoGroups = new LinkedList<Group>();
-
-      for (org.jboss.identity.idm.api.Group group : allGroups)
-      {
-         if (!orgService.getExoGroupType().equals(orgService.getExoRootGroupType())
-            || !group.getName().equals(orgService.getExoRootGroupName()))
-         {
-            exoGroups.add(convertGroup(group));
-         }
-
-      }
-
-      return exoGroups;
-   }
-
-   private void preSave(Group group, boolean isNew) throws Exception
-   {
-      for (GroupEventListener listener : listeners_)
-      {
-         listener.preSave(group, isNew);
-      }
-   }
-
-   private void postSave(Group group, boolean isNew) throws Exception
-   {
-      for (GroupEventListener listener : listeners_)
-      {
-         listener.postSave(group, isNew);
-      }
-   }
-
-   private void preDelete(Group group) throws Exception
-   {
-      for (GroupEventListener listener : listeners_)
-      {
-         listener.preDelete(group);
-      }
-   }
-
-   private void postDelete(Group group) throws Exception
-   {
-      for (GroupEventListener listener : listeners_)
-      {
-         listener.postDelete(group);
-      }
-   }
-
-   public Group getGroup(String groupName) throws Exception
-   {
-      org.jboss.identity.idm.api.Group jbidGroup =
-         getIdentitySession().getPersistenceManager().findGroup(groupName, orgService.getExoGroupType());
-
-      if (jbidGroup == null)
-      {
-         return null;
-      }
-
-      return convertGroup(jbidGroup);
-
-   }
-
-   private Group convertGroup(org.jboss.identity.idm.api.Group jbidGroup) throws Exception
-   {
-      Map<String, Attribute> attrs = getIdentitySession().getAttributesManager().getAttributes(jbidGroup);
-
-      GroupImpl exoGroup = new GroupImpl(jbidGroup.getName());
-
-      if (attrs.containsKey(GROUP_DESCRIPTION))
-      {
-         exoGroup.setDescription(attrs.get(GROUP_DESCRIPTION).getValue().toString());
-      }
-      if (attrs.containsKey(GROUP_LABEL))
-      {
-         exoGroup.setLabel(attrs.get(GROUP_LABEL).getValue().toString());
-      }
-
-      // Resolve full ID
-      String id = getGroupId(jbidGroup.getName());
-
-      exoGroup.setId(id);
-
-      if (id.length() == jbidGroup.getName().length() + 1)
-      {
-         exoGroup.setParentId(null);
-      }
-      else
-      {
-         exoGroup.setParentId(id.substring(0, id.length() - jbidGroup.getName().length() - 1));
-      }
-
-      return exoGroup;
-   }
-
-   private String getGroupId(String groupName) throws Exception
-   {
-      if (groupName.equals(orgService.getExoRootGroupName()))
-      {
-         return "";
-      }
-
-      org.jboss.identity.idm.api.Group jbidGroup =
-         getIdentitySession().getPersistenceManager().findGroup(groupName, orgService.getExoGroupType());
-
-      Collection<org.jboss.identity.idm.api.Group> parents =
-         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
-            false, false);
-
-      if (parents.size() > 1)
-      {
-         throw new IllegalStateException("Group has more than one parent: " + groupName);
-      }
-
-      if (parents.size() == 0)
-      {
-         //As there is special root group this shouldn't happen:
-         throw new IllegalStateException("Group present that is not connected to the root: " + groupName);
-
-         // This group is at the root
-         //return "/" + groupName;
-      }
-
-      String parentGroupId = getGroupId(((org.jboss.identity.idm.api.Group)parents.iterator().next()).getName());
-
-      return parentGroupId + "/" + groupName;
-
-   }
-
-   private org.jboss.identity.idm.api.Group persistGroup(Group exoGroup) throws Exception
-   {
-
-      org.jboss.identity.idm.api.Group jbidGroup =
-         getIdentitySession().getPersistenceManager().findGroup(exoGroup.getGroupName(), orgService.getExoGroupType());
-
-      if (jbidGroup == null)
-      {
-         jbidGroup =
-            getIdentitySession().getPersistenceManager().createGroup(exoGroup.getGroupName(),
-               orgService.getExoGroupType());
-      }
-
-      String description = exoGroup.getDescription();
-      String label = exoGroup.getLabel();
-
-      List<Attribute> attrsList = new ArrayList<Attribute>();
-      if (description != null)
-      {
-         attrsList.add(new SimpleAttribute(GROUP_DESCRIPTION, description));
-      }
-
-      if (label != null)
-      {
-         attrsList.add(new SimpleAttribute(GROUP_LABEL, label));
-      }
-
-      if (attrsList.size() > 0)
-      {
-         Attribute[] attrs = new Attribute[attrsList.size()];
-
-         attrs = attrsList.toArray(attrs);
-
-         getIdentitySession().getAttributesManager().addAttributes(jbidGroup, attrs);
-
-      }
-
-      return jbidGroup;
-   }
-
-   private IdentitySession getIdentitySession() throws Exception
-   {
-      return service_.getIdentitySession();
-   }
-
-   private org.jboss.identity.idm.api.Group getRootGroup() throws Exception
-   {
-      org.jboss.identity.idm.api.Group rootGroup =
-         getIdentitySession().getPersistenceManager().findGroup(orgService.getExoRootGroupName(),
-            orgService.getExoRootGroupType());
-
-      if (rootGroup == null)
-      {
-         rootGroup =
-            getIdentitySession().getPersistenceManager().createGroup(orgService.getExoRootGroupName(),
-               orgService.getExoRootGroupType());
-      }
-
-      return rootGroup;
-   }
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/GroupDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,459 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.GroupEventListener;
+import org.exoplatform.services.organization.GroupHandler;
+import org.exoplatform.services.organization.impl.GroupImpl;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class GroupDAOImpl implements GroupHandler
+{
+
+   public static final String GROUP_LABEL = "label";
+
+   public static final String GROUP_DESCRIPTION = "description";
+
+   private JBossIDMService service_;
+
+   private List<GroupEventListener> listeners_;
+
+   private JBossIDMOrganizationServiceImpl orgService;
+
+   public GroupDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service)
+   {
+      service_ = service;
+      this.orgService = orgService;
+      listeners_ = new ArrayList<GroupEventListener>();
+   }
+
+   public void addGroupEventListener(GroupEventListener listener)
+   {
+      listeners_.add(listener);
+   }
+
+   final public Group createGroupInstance()
+   {
+      return new GroupImpl();
+   }
+
+   public void createGroup(Group group, boolean broadcast) throws Exception
+   {
+      addChild(null, group, broadcast);
+   }
+
+   public void addChild(Group parent, Group child, boolean broadcast) throws Exception
+   {
+      org.jboss.identity.idm.api.Group parentGroup = null;
+
+      if (parent != null)
+      {
+         parentGroup =
+            getIdentitySession().getPersistenceManager().findGroup(parent.getGroupName(), orgService.getExoGroupType());
+         ((GroupImpl)child).setId(parent.getId() + "/" + child.getGroupName());
+
+      }
+      else
+      {
+         ((GroupImpl)child).setId("/" + child.getGroupName());
+      }
+
+      if (broadcast)
+      {
+         preSave(child, true);
+      }
+
+      org.jboss.identity.idm.api.Group childGroup = persistGroup(child);
+
+      if (parentGroup != null)
+      {
+         getIdentitySession().getRelationshipManager().associateGroups(parentGroup, childGroup);
+         ((GroupImpl)child).setParentId(parent.getId());
+
+      }
+      else
+      {
+         getIdentitySession().getRelationshipManager().associateGroups(getRootGroup(), childGroup);
+      }
+
+      if (broadcast)
+      {
+         postSave(child, true);
+      }
+
+   }
+
+   public void saveGroup(Group group, boolean broadcast) throws Exception
+   {
+      if (broadcast)
+      {
+         preSave(group, false);
+      }
+      persistGroup(group);
+      if (broadcast)
+      {
+         postSave(group, false);
+      }
+   }
+
+   public Group removeGroup(Group group, boolean broadcast) throws Exception
+   {
+      if (broadcast)
+      {
+         preDelete(group);
+      }
+
+      org.jboss.identity.idm.api.Group jbidGroup =
+         getIdentitySession().getPersistenceManager().findGroup(group.getGroupName(), orgService.getExoGroupType());
+
+      if (jbidGroup == null)
+      {
+         return group;
+      }
+
+      //      MembershipDAOImpl.removeMembershipEntriesOfGroup(group, getIdentitySession());
+
+      Collection<org.jboss.identity.idm.api.Group> oneLevelChilds =
+         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
+            true, false);
+
+      Collection<org.jboss.identity.idm.api.Group> allChilds =
+         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
+            true, true);
+
+      getIdentitySession().getRelationshipManager().disassociateGroups(jbidGroup, oneLevelChilds);
+
+      for (org.jboss.identity.idm.api.Group child : allChilds)
+      {
+         //TODO: impl force in IDM
+         getIdentitySession().getPersistenceManager().removeGroup(child, true);
+      }
+
+      getIdentitySession().getPersistenceManager().removeGroup(jbidGroup, true);
+
+      if (broadcast)
+      {
+         postDelete(group);
+      }
+      return group;
+   }
+
+   public Collection findGroupByMembership(String userName, String membershipType) throws Exception
+   {
+      Collection<org.jboss.identity.idm.api.Role> allRoles =
+         getIdentitySession().getRoleManager().findRoles(userName, membershipType);
+
+      Set<Group> exoGroups = new HashSet<Group>();
+
+      for (org.jboss.identity.idm.api.Role role : allRoles)
+      {
+         exoGroups.add(convertGroup(role.getGroup()));
+
+      }
+
+      return exoGroups;
+   }
+
+   //
+   public Group findGroupById(String groupId) throws Exception
+   {
+
+      org.jboss.identity.idm.api.Group jbidGroup = orgService.getJBIDMGroup(groupId);
+
+      if (jbidGroup == null)
+      {
+         return null;
+      }
+
+      return convertGroup(jbidGroup);
+   }
+
+   public Collection findGroups(Group parent) throws Exception
+   {
+      org.jboss.identity.idm.api.Group jbidGroup = null;
+
+      if (parent == null)
+      {
+         jbidGroup = getRootGroup();
+      }
+      else
+      {
+         jbidGroup =
+            getIdentitySession().getPersistenceManager().findGroup(parent.getGroupName(), orgService.getExoGroupType());
+      }
+
+      if (jbidGroup == null)
+      {
+         return Collections.emptyList();
+      }
+
+      Collection<org.jboss.identity.idm.api.Group> allGroups =
+         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
+            true, false);
+
+      List<Group> exoGroups = new LinkedList<Group>();
+
+      for (org.jboss.identity.idm.api.Group group : allGroups)
+      {
+         exoGroups.add(convertGroup(group));
+
+      }
+
+      return exoGroups;
+
+   }
+
+   public Collection findGroupsOfUser(String user) throws Exception
+   {
+
+      if (user == null)
+      {
+         // julien : integration bug
+         // need to look at that later
+         //
+         // Caused by: java.lang.IllegalArgumentException: User name cannot be null
+         // at org.jboss.identity.idm.impl.api.session.managers.AbstractManager.checkNotNullArgument(AbstractManager.java:267)
+         //  at org.jboss.identity.idm.impl.api.session.managers.RelationshipManagerImpl.findRelatedGroups(RelationshipManagerImpl.java:753)
+         // at org.exoplatform.services.organization.jbidm.GroupDAOImpl.findGroupsOfUser(GroupDAOImpl.java:225)
+         // at org.exoplatform.organization.webui.component.GroupManagement.isMemberOfGroup(GroupManagement.java:72)
+         // at org.exoplatform.organization.webui.component.GroupManagement.isAdministrator(GroupManagement.java:125)
+         // at org.exoplatform.organization.webui.component.UIGroupExplorer.<init>(UIGroupExplorer.java:57)
+         return Collections.emptyList();
+      }
+
+      Collection<org.jboss.identity.idm.api.Group> allGroups =
+         getIdentitySession().getRelationshipManager().findRelatedGroups(user, orgService.getExoGroupType(), null);
+
+      List<Group> exoGroups = new LinkedList<Group>();
+
+      for (org.jboss.identity.idm.api.Group group : allGroups)
+      {
+         exoGroups.add(convertGroup(group));
+
+      }
+
+      return exoGroups;
+   }
+
+   public Collection getAllGroups() throws Exception
+   {
+      Collection<org.jboss.identity.idm.api.Group> allGroups =
+         getIdentitySession().getPersistenceManager().findGroup(orgService.getExoGroupType());
+
+      List<Group> exoGroups = new LinkedList<Group>();
+
+      for (org.jboss.identity.idm.api.Group group : allGroups)
+      {
+         if (!orgService.getExoGroupType().equals(orgService.getExoRootGroupType())
+            || !group.getName().equals(orgService.getExoRootGroupName()))
+         {
+            exoGroups.add(convertGroup(group));
+         }
+
+      }
+
+      return exoGroups;
+   }
+
+   private void preSave(Group group, boolean isNew) throws Exception
+   {
+      for (GroupEventListener listener : listeners_)
+      {
+         listener.preSave(group, isNew);
+      }
+   }
+
+   private void postSave(Group group, boolean isNew) throws Exception
+   {
+      for (GroupEventListener listener : listeners_)
+      {
+         listener.postSave(group, isNew);
+      }
+   }
+
+   private void preDelete(Group group) throws Exception
+   {
+      for (GroupEventListener listener : listeners_)
+      {
+         listener.preDelete(group);
+      }
+   }
+
+   private void postDelete(Group group) throws Exception
+   {
+      for (GroupEventListener listener : listeners_)
+      {
+         listener.postDelete(group);
+      }
+   }
+
+   public Group getGroup(String groupName) throws Exception
+   {
+      org.jboss.identity.idm.api.Group jbidGroup =
+         getIdentitySession().getPersistenceManager().findGroup(groupName, orgService.getExoGroupType());
+
+      if (jbidGroup == null)
+      {
+         return null;
+      }
+
+      return convertGroup(jbidGroup);
+
+   }
+
+   private Group convertGroup(org.jboss.identity.idm.api.Group jbidGroup) throws Exception
+   {
+      Map<String, Attribute> attrs = getIdentitySession().getAttributesManager().getAttributes(jbidGroup);
+
+      GroupImpl exoGroup = new GroupImpl(jbidGroup.getName());
+
+      if (attrs.containsKey(GROUP_DESCRIPTION))
+      {
+         exoGroup.setDescription(attrs.get(GROUP_DESCRIPTION).getValue().toString());
+      }
+      if (attrs.containsKey(GROUP_LABEL))
+      {
+         exoGroup.setLabel(attrs.get(GROUP_LABEL).getValue().toString());
+      }
+
+      // Resolve full ID
+      String id = getGroupId(jbidGroup.getName());
+
+      exoGroup.setId(id);
+
+      if (id.length() == jbidGroup.getName().length() + 1)
+      {
+         exoGroup.setParentId(null);
+      }
+      else
+      {
+         exoGroup.setParentId(id.substring(0, id.length() - jbidGroup.getName().length() - 1));
+      }
+
+      return exoGroup;
+   }
+
+   private String getGroupId(String groupName) throws Exception
+   {
+      if (groupName.equals(orgService.getExoRootGroupName()))
+      {
+         return "";
+      }
+
+      org.jboss.identity.idm.api.Group jbidGroup =
+         getIdentitySession().getPersistenceManager().findGroup(groupName, orgService.getExoGroupType());
+
+      Collection<org.jboss.identity.idm.api.Group> parents =
+         getIdentitySession().getRelationshipManager().findAssociatedGroups(jbidGroup, orgService.getExoGroupType(),
+            false, false);
+
+      if (parents.size() > 1)
+      {
+         throw new IllegalStateException("Group has more than one parent: " + groupName);
+      }
+
+      if (parents.size() == 0)
+      {
+         //As there is special root group this shouldn't happen:
+         throw new IllegalStateException("Group present that is not connected to the root: " + groupName);
+
+         // This group is at the root
+         //return "/" + groupName;
+      }
+
+      String parentGroupId = getGroupId(((org.jboss.identity.idm.api.Group)parents.iterator().next()).getName());
+
+      return parentGroupId + "/" + groupName;
+
+   }
+
+   private org.jboss.identity.idm.api.Group persistGroup(Group exoGroup) throws Exception
+   {
+
+      org.jboss.identity.idm.api.Group jbidGroup =
+         getIdentitySession().getPersistenceManager().findGroup(exoGroup.getGroupName(), orgService.getExoGroupType());
+
+      if (jbidGroup == null)
+      {
+         jbidGroup =
+            getIdentitySession().getPersistenceManager().createGroup(exoGroup.getGroupName(),
+               orgService.getExoGroupType());
+      }
+
+      String description = exoGroup.getDescription();
+      String label = exoGroup.getLabel();
+
+      List<Attribute> attrsList = new ArrayList<Attribute>();
+      if (description != null)
+      {
+         attrsList.add(new SimpleAttribute(GROUP_DESCRIPTION, description));
+      }
+
+      if (label != null)
+      {
+         attrsList.add(new SimpleAttribute(GROUP_LABEL, label));
+      }
+
+      if (attrsList.size() > 0)
+      {
+         Attribute[] attrs = new Attribute[attrsList.size()];
+
+         attrs = attrsList.toArray(attrs);
+
+         getIdentitySession().getAttributesManager().addAttributes(jbidGroup, attrs);
+
+      }
+
+      return jbidGroup;
+   }
+
+   private IdentitySession getIdentitySession() throws Exception
+   {
+      return service_.getIdentitySession();
+   }
+
+   private org.jboss.identity.idm.api.Group getRootGroup() throws Exception
+   {
+      org.jboss.identity.idm.api.Group rootGroup =
+         getIdentitySession().getPersistenceManager().findGroup(orgService.getExoRootGroupName(),
+            orgService.getExoRootGroupType());
+
+      if (rootGroup == null)
+      {
+         rootGroup =
+            getIdentitySession().getPersistenceManager().createGroup(orgService.getExoRootGroupName(),
+               orgService.getExoRootGroupType());
+      }
+
+      return rootGroup;
+   }
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,83 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.commons.utils.ListAccess;
-import org.exoplatform.services.organization.User;
-import org.jboss.identity.idm.api.query.UserQuery;
-import org.jboss.identity.idm.api.query.UserQueryBuilder;
-
-import java.util.List;
-
-public class IDMUserListAccess implements ListAccess<User>
-{
-   private final UserDAOImpl userDAO;
-
-   private final JBossIDMService idmService;
-
-   private final UserQueryBuilder userQueryBuilder;
-
-   private final int pageSize;
-
-   private final boolean countAll;
-
-   public IDMUserListAccess(UserDAOImpl userDAO, JBossIDMService idmService, UserQueryBuilder userQueryBuilder,
-      int pageSize, boolean countAll)
-   {
-      this.userDAO = userDAO;
-      this.idmService = idmService;
-      this.userQueryBuilder = userQueryBuilder;
-      this.pageSize = pageSize;
-      this.countAll = countAll;
-   }
-
-   public User[] load(int index, int length) throws Exception, IllegalArgumentException
-   {
-      userQueryBuilder.page(index, length);
-      UserQuery query = userQueryBuilder.createQuery();
-      List<org.jboss.identity.idm.api.User> users = idmService.getIdentitySession().list(query);
-
-      User[] exoUsers = new User[users.size()];
-
-      for (int i = 0; i < users.size(); i++)
-      {
-         org.jboss.identity.idm.api.User user = users.get(i);
-
-         exoUsers[i] = UserDAOImpl.getPopulatedUser(user.getId(), idmService.getIdentitySession());
-      }
-
-      return exoUsers;
-   }
-
-   public int getSize() throws Exception
-   {
-      if (countAll)
-      {
-         return idmService.getIdentitySession().getPersistenceManager().getUserCount();
-      }
-      else
-      {
-         userQueryBuilder.page(0, 0);
-         UserQuery query = userQueryBuilder.createQuery();
-         return idmService.getIdentitySession().execute(query).size();
-      }
-
-   }
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/IDMUserListAccess.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.commons.utils.ListAccess;
+import org.exoplatform.services.organization.User;
+import org.jboss.identity.idm.api.query.UserQuery;
+import org.jboss.identity.idm.api.query.UserQueryBuilder;
+
+import java.util.List;
+
+public class IDMUserListAccess implements ListAccess<User>
+{
+   private final UserDAOImpl userDAO;
+
+   private final JBossIDMService idmService;
+
+   private final UserQueryBuilder userQueryBuilder;
+
+   private final int pageSize;
+
+   private final boolean countAll;
+
+   public IDMUserListAccess(UserDAOImpl userDAO, JBossIDMService idmService, UserQueryBuilder userQueryBuilder,
+      int pageSize, boolean countAll)
+   {
+      this.userDAO = userDAO;
+      this.idmService = idmService;
+      this.userQueryBuilder = userQueryBuilder;
+      this.pageSize = pageSize;
+      this.countAll = countAll;
+   }
+
+   public User[] load(int index, int length) throws Exception, IllegalArgumentException
+   {
+      userQueryBuilder.page(index, length);
+      UserQuery query = userQueryBuilder.createQuery();
+      List<org.jboss.identity.idm.api.User> users = idmService.getIdentitySession().list(query);
+
+      User[] exoUsers = new User[users.size()];
+
+      for (int i = 0; i < users.size(); i++)
+      {
+         org.jboss.identity.idm.api.User user = users.get(i);
+
+         exoUsers[i] = UserDAOImpl.getPopulatedUser(user.getId(), idmService.getIdentitySession());
+      }
+
+      return exoUsers;
+   }
+
+   public int getSize() throws Exception
+   {
+      if (countAll)
+      {
+         return idmService.getIdentitySession().getPersistenceManager().getUserCount();
+      }
+      else
+      {
+         userQueryBuilder.page(0, 0);
+         UserQuery query = userQueryBuilder.createQuery();
+         return idmService.getIdentitySession().execute(query).size();
+      }
+
+   }
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,175 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.component.ComponentRequestLifecycle;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.ValueParam;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.organization.BaseOrganizationService;
-import org.picocontainer.Startable;
-
-public class JBossIDMOrganizationServiceImpl extends BaseOrganizationService implements Startable,
-   ComponentRequestLifecycle
-{
-
-   // We may have several portal containers thus we need one JBossIDMService per portal container   
-   //   private static JBossIDMService jbidmService_;
-   private JBossIDMService jbidmService_;
-
-   public static final String EXO_GROUP_TYPE_OPTION = "exoGroupTypeName";
-
-   public static final String EXO_ROOT_GROUP_NAME_OPTION = "exoRootGroupName";
-
-   public static final String EXO_ROOT_GROUP_TYPE_NAME_OPTION = "exoRootGroupTypeName";
-
-   public static final String PASSWORD_AS_ATTRIBUTE_OPTION = "passwordAsAttribute";
-
-   private String exoGroupType = "EXO_GROUP_TYPE";
-
-   private String exoRootGroupName = "EXO_ROOT_GROUP";
-
-   private String exoRootGroupType = exoGroupType;
-
-   private boolean passwordAsAttribute = false;
-
-   public JBossIDMOrganizationServiceImpl(InitParams params, CacheService cservice, JBossIDMService jbidmService)
-      throws Exception
-   {
-      groupDAO_ = new GroupDAOImpl(this, jbidmService);
-      userDAO_ = new UserDAOImpl(this, jbidmService, cservice);
-      userProfileDAO_ = new UserProfileDAOImpl(this, jbidmService, cservice);
-      membershipDAO_ = new MembershipDAOImpl(this, jbidmService);
-      membershipTypeDAO_ = new MembershipTypeDAOImpl(this, jbidmService);
-
-      jbidmService_ = jbidmService;
-
-      if (params != null)
-      {
-         //Options
-         ValueParam exoGroupTypeNameParam = params.getValueParam(EXO_GROUP_TYPE_OPTION);
-         ValueParam exoRootGroupTypeNameParam = params.getValueParam(EXO_ROOT_GROUP_TYPE_NAME_OPTION);
-         ValueParam exoRootGroupNameParam = params.getValueParam(EXO_ROOT_GROUP_NAME_OPTION);
-         ValueParam passwordAsAttributeParam = params.getValueParam(PASSWORD_AS_ATTRIBUTE_OPTION);
-
-         if (exoGroupTypeNameParam != null)
-         {
-            this.exoGroupType = exoGroupTypeNameParam.getValue();
-         }
-
-         if (exoRootGroupNameParam != null)
-         {
-            this.exoRootGroupName = exoRootGroupNameParam.getValue();
-         }
-
-         if (exoRootGroupTypeNameParam != null)
-         {
-            this.exoRootGroupType = exoRootGroupTypeNameParam.getValue();
-         }
-         else if (exoRootGroupTypeNameParam != null)
-         {
-            this.exoRootGroupType = this.exoGroupType;
-         }
-
-         if (passwordAsAttributeParam != null && passwordAsAttributeParam.getValue().equalsIgnoreCase("true"))
-         {
-            this.passwordAsAttribute = true;
-         }
-      }
-
-   }
-
-   public final org.jboss.identity.idm.api.Group getJBIDMGroup(String groupId) throws Exception
-   {
-      String[] ids = groupId.split("/");
-      String name = ids[ids.length - 1];
-      return jbidmService_.getIdentitySession().getPersistenceManager().findGroup(name, getExoGroupType());
-   }
-
-   @Override
-   public void start()
-   {
-
-      try
-      {
-         // Wrap within transaction so all initializers can work
-         jbidmService_.getIdentitySession().beginTransaction();
-         super.start();
-         jbidmService_.getIdentitySession().getTransaction().commit();
-
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-      }
-
-   }
-
-   @Override
-   public void stop()
-   {
-      //toto
-   }
-
-   public void startRequest(ExoContainer container)
-   {
-      try
-      {
-         jbidmService_.getIdentitySession().beginTransaction();
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace();
-      }
-   }
-
-   public void endRequest(ExoContainer container)
-   {
-      try
-      {
-         jbidmService_.getIdentitySession().getTransaction().commit();
-      }
-      catch (Exception e)
-      {
-         e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
-      }
-   }
-
-   public String getExoGroupType()
-   {
-      return exoGroupType;
-   }
-
-   public String getExoRootGroupName()
-   {
-      return exoRootGroupName;
-   }
-
-   public String getExoRootGroupType()
-   {
-      return exoRootGroupType;
-   }
-
-   public boolean isPasswordAsAttribute()
-   {
-      return passwordAsAttribute;
-   }
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMOrganizationServiceImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,175 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.component.ComponentRequestLifecycle;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.organization.BaseOrganizationService;
+import org.picocontainer.Startable;
+
+public class JBossIDMOrganizationServiceImpl extends BaseOrganizationService implements Startable,
+   ComponentRequestLifecycle
+{
+
+   // We may have several portal containers thus we need one JBossIDMService per portal container   
+   //   private static JBossIDMService jbidmService_;
+   private JBossIDMService jbidmService_;
+
+   public static final String EXO_GROUP_TYPE_OPTION = "exoGroupTypeName";
+
+   public static final String EXO_ROOT_GROUP_NAME_OPTION = "exoRootGroupName";
+
+   public static final String EXO_ROOT_GROUP_TYPE_NAME_OPTION = "exoRootGroupTypeName";
+
+   public static final String PASSWORD_AS_ATTRIBUTE_OPTION = "passwordAsAttribute";
+
+   private String exoGroupType = "EXO_GROUP_TYPE";
+
+   private String exoRootGroupName = "EXO_ROOT_GROUP";
+
+   private String exoRootGroupType = exoGroupType;
+
+   private boolean passwordAsAttribute = false;
+
+   public JBossIDMOrganizationServiceImpl(InitParams params, CacheService cservice, JBossIDMService jbidmService)
+      throws Exception
+   {
+      groupDAO_ = new GroupDAOImpl(this, jbidmService);
+      userDAO_ = new UserDAOImpl(this, jbidmService, cservice);
+      userProfileDAO_ = new UserProfileDAOImpl(this, jbidmService, cservice);
+      membershipDAO_ = new MembershipDAOImpl(this, jbidmService);
+      membershipTypeDAO_ = new MembershipTypeDAOImpl(this, jbidmService);
+
+      jbidmService_ = jbidmService;
+
+      if (params != null)
+      {
+         //Options
+         ValueParam exoGroupTypeNameParam = params.getValueParam(EXO_GROUP_TYPE_OPTION);
+         ValueParam exoRootGroupTypeNameParam = params.getValueParam(EXO_ROOT_GROUP_TYPE_NAME_OPTION);
+         ValueParam exoRootGroupNameParam = params.getValueParam(EXO_ROOT_GROUP_NAME_OPTION);
+         ValueParam passwordAsAttributeParam = params.getValueParam(PASSWORD_AS_ATTRIBUTE_OPTION);
+
+         if (exoGroupTypeNameParam != null)
+         {
+            this.exoGroupType = exoGroupTypeNameParam.getValue();
+         }
+
+         if (exoRootGroupNameParam != null)
+         {
+            this.exoRootGroupName = exoRootGroupNameParam.getValue();
+         }
+
+         if (exoRootGroupTypeNameParam != null)
+         {
+            this.exoRootGroupType = exoRootGroupTypeNameParam.getValue();
+         }
+         else if (exoRootGroupTypeNameParam != null)
+         {
+            this.exoRootGroupType = this.exoGroupType;
+         }
+
+         if (passwordAsAttributeParam != null && passwordAsAttributeParam.getValue().equalsIgnoreCase("true"))
+         {
+            this.passwordAsAttribute = true;
+         }
+      }
+
+   }
+
+   public final org.jboss.identity.idm.api.Group getJBIDMGroup(String groupId) throws Exception
+   {
+      String[] ids = groupId.split("/");
+      String name = ids[ids.length - 1];
+      return jbidmService_.getIdentitySession().getPersistenceManager().findGroup(name, getExoGroupType());
+   }
+
+   @Override
+   public void start()
+   {
+
+      try
+      {
+         // Wrap within transaction so all initializers can work
+         jbidmService_.getIdentitySession().beginTransaction();
+         super.start();
+         jbidmService_.getIdentitySession().getTransaction().commit();
+
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+      }
+
+   }
+
+   @Override
+   public void stop()
+   {
+      //toto
+   }
+
+   public void startRequest(ExoContainer container)
+   {
+      try
+      {
+         jbidmService_.getIdentitySession().beginTransaction();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+      }
+   }
+
+   public void endRequest(ExoContainer container)
+   {
+      try
+      {
+         jbidmService_.getIdentitySession().getTransaction().commit();
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+      }
+   }
+
+   public String getExoGroupType()
+   {
+      return exoGroupType;
+   }
+
+   public String getExoRootGroupName()
+   {
+      return exoRootGroupName;
+   }
+
+   public String getExoRootGroupType()
+   {
+      return exoRootGroupType;
+   }
+
+   public boolean isPasswordAsAttribute()
+   {
+      return passwordAsAttribute;
+   }
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.IdentitySessionFactory;
-
-public interface JBossIDMService
-{
-
-   IdentitySessionFactory getIdentitySessionFactory();
-
-   IdentitySession getIdentitySession() throws Exception;
-
-   IdentitySession getIdentitySession(String realm) throws Exception;
-
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMService.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+
+public interface JBossIDMService
+{
+
+   IdentitySessionFactory getIdentitySessionFactory();
+
+   IdentitySession getIdentitySession() throws Exception;
+
+   IdentitySession getIdentitySession(String realm) throws Exception;
+
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,222 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.xml.InitParams;
-import org.exoplatform.container.xml.PropertiesParam;
-import org.exoplatform.container.xml.Property;
-import org.exoplatform.container.xml.ValueParam;
-import org.exoplatform.container.xml.ValuesParam;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.AnnotationConfiguration;
-import org.hibernate.dialect.Dialect;
-import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.IdentitySessionFactory;
-import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
-import org.jboss.identity.idm.common.exception.IdentityConfigurationException;
-import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
-import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
-import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
-import org.picocontainer.Startable;
-
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.naming.InitialContext;
-
-public class JBossIDMServiceImpl implements JBossIDMService, Startable
-{
-
-   private static Log log_ = ExoLogger.getLogger(JBossIDMServiceImpl.class);
-
-   public static final String PARAM_CONFIG_OPTION = "config";
-
-   public static final String PARAM_HIBERNATE_PROPS = "hibernate.properties";
-
-   public static final String PARAM_HIBERNATE_MAPPINGS = "hibernate.mappings";
-
-   public static final String PARAM_HIBERNATE_ANNOTATIONS = "hibernate.annotations";
-
-   public static final String PARAM_JNDI_NAME_OPTION = "jndiName";
-
-   public static final String DEFAULT_REALM_NAME_OPTION = "PortalRealm";
-
-   // We may have several portal containers thus we need one indentitySessionFactory per portal container
-   //   private static IdentitySessionFactory identitySessionFactory;
-   private IdentitySessionFactory identitySessionFactory;
-
-   private String config;
-
-   private String defaultRealmName = "PortalRealm";
-
-   private IdentityConfiguration identityConfiguration;
-
-   private JBossIDMServiceImpl()
-   {
-   }
-
-   public JBossIDMServiceImpl(InitParams initParams, ConfigurationManager confManager) throws Exception
-   {
-      ValueParam config = initParams.getValueParam(PARAM_CONFIG_OPTION);
-      ValueParam jndiName = initParams.getValueParam(PARAM_JNDI_NAME_OPTION);
-      ValueParam realmName = initParams.getValueParam(DEFAULT_REALM_NAME_OPTION);
-
-      if (config == null && jndiName == null)
-      {
-         throw new IllegalStateException("Either '" + PARAM_CONFIG_OPTION + "' or '" + PARAM_JNDI_NAME_OPTION
-            + "' parameter must " + "be specified");
-      }
-      if (realmName != null)
-      {
-         this.defaultRealmName = realmName.getValue();
-      }
-
-      SessionFactory sf = null;
-
-      if (initParams.containsKey(PARAM_HIBERNATE_PROPS))
-      {
-         PropertiesParam param = initParams.getPropertiesParam(PARAM_HIBERNATE_PROPS);
-         AnnotationConfiguration conf_ = new AnnotationConfiguration();
-         Iterator properties = param.getPropertyIterator();
-         while (properties.hasNext())
-         {
-            Property p = (Property)properties.next();
-
-            //
-            String name = p.getName();
-            String value = p.getValue();
-
-            // Julien: Don't remove that unless you know what you are doing
-            if (name.equals("hibernate.dialect"))
-            {
-               Package pkg = Dialect.class.getPackage();
-               String dialect = value.substring(22);
-               value = pkg.getName() + "." + dialect; // 22 is the length of
-               // "org.hibernate.dialect"
-               log_.info("Using dialect " + dialect);
-            }
-
-            //
-            conf_.setProperty(name, value);
-         }
-
-         ClassLoader cl = Thread.currentThread().getContextClassLoader();
-
-         if (initParams.containsKey(PARAM_HIBERNATE_MAPPINGS))
-         {
-            ValuesParam mappings = initParams.getValuesParam(PARAM_HIBERNATE_MAPPINGS);
-
-            List<String> paths = mappings.getValues();
-
-            for (String path : paths)
-            {
-               URL url = cl.getResource(path);
-               log_.info("Adding  Hibernate Mapping: " + path);
-               conf_.addURL(url);
-            }
-         }
-
-         if (initParams.containsKey(PARAM_HIBERNATE_ANNOTATIONS))
-         {
-            ValuesParam annotations = initParams.getValuesParam(PARAM_HIBERNATE_ANNOTATIONS);
-
-            List<String> classes = annotations.getValues();
-
-            for (String name : classes)
-            {
-               Class clazz = cl.loadClass(name);
-               conf_.addAnnotatedClass(clazz);
-            }
-
-         }
-
-         sf = conf_.buildSessionFactory();
-
-      }
-
-      if (config != null)
-      {
-         this.config = config.getValue();
-         URL configURL = confManager.getURL(this.config);
-
-         if (configURL == null)
-         {
-            throw new IllegalStateException("Cannot fine resource: " + this.config);
-         }
-
-         IdentityConfigurationMetaData configMD =
-            JAXB2IdentityConfiguration.createConfigurationMetaData(confManager.getInputStream(this.config));
-
-         identityConfiguration = new IdentityConfigurationImpl().configure(configMD);
-
-         if (sf != null)
-         {
-            identityConfiguration.getIdentityConfigurationRegistry().register(sf, "hibernateSessionFactory");
-         }
-      }
-      else
-      {
-         identitySessionFactory = (IdentitySessionFactory)new InitialContext().lookup(jndiName.getValue());
-      }
-
-   }
-
-   public void start()
-   {
-      if (identitySessionFactory == null)
-      {
-         try
-         {
-            identitySessionFactory = identityConfiguration.buildIdentitySessionFactory();
-         }
-         catch (IdentityConfigurationException e)
-         {
-            throw new RuntimeException(e);
-         }
-      }
-   }
-
-   public void stop()
-   {
-   }
-
-   public IdentitySessionFactory getIdentitySessionFactory()
-   {
-      return identitySessionFactory; //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-   public IdentitySession getIdentitySession() throws Exception
-   {
-      return getIdentitySessionFactory().getCurrentIdentitySession(defaultRealmName);
-   }
-
-   public IdentitySession getIdentitySession(String realm) throws Exception
-   {
-      if (realm == null)
-      {
-         throw new IllegalArgumentException("Realm name cannot be null");
-      }
-      return getIdentitySessionFactory().getCurrentIdentitySession(realm);
-   }
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/JBossIDMServiceImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,222 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.container.xml.PropertiesParam;
+import org.exoplatform.container.xml.Property;
+import org.exoplatform.container.xml.ValueParam;
+import org.exoplatform.container.xml.ValuesParam;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.dialect.Dialect;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.cfg.IdentityConfiguration;
+import org.jboss.identity.idm.common.exception.IdentityConfigurationException;
+import org.jboss.identity.idm.impl.configuration.IdentityConfigurationImpl;
+import org.jboss.identity.idm.impl.configuration.jaxb2.JAXB2IdentityConfiguration;
+import org.jboss.identity.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.picocontainer.Startable;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.InitialContext;
+
+public class JBossIDMServiceImpl implements JBossIDMService, Startable
+{
+
+   private static Log log_ = ExoLogger.getLogger(JBossIDMServiceImpl.class);
+
+   public static final String PARAM_CONFIG_OPTION = "config";
+
+   public static final String PARAM_HIBERNATE_PROPS = "hibernate.properties";
+
+   public static final String PARAM_HIBERNATE_MAPPINGS = "hibernate.mappings";
+
+   public static final String PARAM_HIBERNATE_ANNOTATIONS = "hibernate.annotations";
+
+   public static final String PARAM_JNDI_NAME_OPTION = "jndiName";
+
+   public static final String DEFAULT_REALM_NAME_OPTION = "PortalRealm";
+
+   // We may have several portal containers thus we need one indentitySessionFactory per portal container
+   //   private static IdentitySessionFactory identitySessionFactory;
+   private IdentitySessionFactory identitySessionFactory;
+
+   private String config;
+
+   private String defaultRealmName = "PortalRealm";
+
+   private IdentityConfiguration identityConfiguration;
+
+   private JBossIDMServiceImpl()
+   {
+   }
+
+   public JBossIDMServiceImpl(InitParams initParams, ConfigurationManager confManager) throws Exception
+   {
+      ValueParam config = initParams.getValueParam(PARAM_CONFIG_OPTION);
+      ValueParam jndiName = initParams.getValueParam(PARAM_JNDI_NAME_OPTION);
+      ValueParam realmName = initParams.getValueParam(DEFAULT_REALM_NAME_OPTION);
+
+      if (config == null && jndiName == null)
+      {
+         throw new IllegalStateException("Either '" + PARAM_CONFIG_OPTION + "' or '" + PARAM_JNDI_NAME_OPTION
+            + "' parameter must " + "be specified");
+      }
+      if (realmName != null)
+      {
+         this.defaultRealmName = realmName.getValue();
+      }
+
+      SessionFactory sf = null;
+
+      if (initParams.containsKey(PARAM_HIBERNATE_PROPS))
+      {
+         PropertiesParam param = initParams.getPropertiesParam(PARAM_HIBERNATE_PROPS);
+         AnnotationConfiguration conf_ = new AnnotationConfiguration();
+         Iterator properties = param.getPropertyIterator();
+         while (properties.hasNext())
+         {
+            Property p = (Property)properties.next();
+
+            //
+            String name = p.getName();
+            String value = p.getValue();
+
+            // Julien: Don't remove that unless you know what you are doing
+            if (name.equals("hibernate.dialect"))
+            {
+               Package pkg = Dialect.class.getPackage();
+               String dialect = value.substring(22);
+               value = pkg.getName() + "." + dialect; // 22 is the length of
+               // "org.hibernate.dialect"
+               log_.info("Using dialect " + dialect);
+            }
+
+            //
+            conf_.setProperty(name, value);
+         }
+
+         ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+         if (initParams.containsKey(PARAM_HIBERNATE_MAPPINGS))
+         {
+            ValuesParam mappings = initParams.getValuesParam(PARAM_HIBERNATE_MAPPINGS);
+
+            List<String> paths = mappings.getValues();
+
+            for (String path : paths)
+            {
+               URL url = cl.getResource(path);
+               log_.info("Adding  Hibernate Mapping: " + path);
+               conf_.addURL(url);
+            }
+         }
+
+         if (initParams.containsKey(PARAM_HIBERNATE_ANNOTATIONS))
+         {
+            ValuesParam annotations = initParams.getValuesParam(PARAM_HIBERNATE_ANNOTATIONS);
+
+            List<String> classes = annotations.getValues();
+
+            for (String name : classes)
+            {
+               Class clazz = cl.loadClass(name);
+               conf_.addAnnotatedClass(clazz);
+            }
+
+         }
+
+         sf = conf_.buildSessionFactory();
+
+      }
+
+      if (config != null)
+      {
+         this.config = config.getValue();
+         URL configURL = confManager.getURL(this.config);
+
+         if (configURL == null)
+         {
+            throw new IllegalStateException("Cannot fine resource: " + this.config);
+         }
+
+         IdentityConfigurationMetaData configMD =
+            JAXB2IdentityConfiguration.createConfigurationMetaData(confManager.getInputStream(this.config));
+
+         identityConfiguration = new IdentityConfigurationImpl().configure(configMD);
+
+         if (sf != null)
+         {
+            identityConfiguration.getIdentityConfigurationRegistry().register(sf, "hibernateSessionFactory");
+         }
+      }
+      else
+      {
+         identitySessionFactory = (IdentitySessionFactory)new InitialContext().lookup(jndiName.getValue());
+      }
+
+   }
+
+   public void start()
+   {
+      if (identitySessionFactory == null)
+      {
+         try
+         {
+            identitySessionFactory = identityConfiguration.buildIdentitySessionFactory();
+         }
+         catch (IdentityConfigurationException e)
+         {
+            throw new RuntimeException(e);
+         }
+      }
+   }
+
+   public void stop()
+   {
+   }
+
+   public IdentitySessionFactory getIdentitySessionFactory()
+   {
+      return identitySessionFactory; //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public IdentitySession getIdentitySession() throws Exception
+   {
+      return getIdentitySessionFactory().getCurrentIdentitySession(defaultRealmName);
+   }
+
+   public IdentitySession getIdentitySession(String realm) throws Exception
+   {
+      if (realm == null)
+      {
+         throw new IllegalArgumentException("Realm name cannot be null");
+      }
+      return getIdentitySessionFactory().getCurrentIdentitySession(realm);
+   }
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,394 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.commons.utils.ListenerStack;
-import org.exoplatform.services.organization.Group;
-import org.exoplatform.services.organization.Membership;
-import org.exoplatform.services.organization.MembershipEventListener;
-import org.exoplatform.services.organization.MembershipHandler;
-import org.exoplatform.services.organization.MembershipType;
-import org.exoplatform.services.organization.User;
-import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.Role;
-import org.jboss.identity.idm.api.RoleType;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.naming.InvalidNameException;
-
-/**
- */
-public class MembershipDAOImpl implements MembershipHandler
-{
-
-   private JBossIDMService service_;
-
-   private List listeners_;
-
-   private JBossIDMOrganizationServiceImpl orgService;
-
-   public MembershipDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service)
-   {
-      service_ = service;
-      listeners_ = new ListenerStack(5);
-      this.orgService = orgService;
-   }
-
-   public void addMembershipEventListener(MembershipEventListener listener)
-   {
-      listeners_.add(listener);
-   }
-
-   final public Membership createMembershipInstance()
-   {
-      return new MembershipImpl();
-   }
-
-   public void createMembership(Membership m, boolean broadcast) throws Exception
-   {
-
-      if (broadcast)
-      {
-         preSave(m, true);
-      }
-
-      saveMembership(m, false);
-
-      if (broadcast)
-      {
-         postSave(m, true);
-      }
-
-   }
-
-   public void linkMembership(User user, Group g, MembershipType mt, boolean broadcast) throws Exception
-   {
-      if (g == null)
-      {
-         throw new InvalidNameException("Can not create membership record for " + user.getUserName()
-            + " because group is null");
-      }
-
-      if (mt == null)
-      {
-         throw new InvalidNameException("Can not create membership record for " + user.getUserName()
-            + " because membership type is null");
-      }
-
-      if (getIdentitySession().getRoleManager().getRoleType(mt.getName()) == null)
-      {
-         getIdentitySession().getRoleManager().createRoleType(mt.getName());
-      }
-
-      String groupId =
-         getIdentitySession().getPersistenceManager().createGroupId(g.getGroupName(), orgService.getExoGroupType());
-
-      if (getIdentitySession().getRoleManager().hasRole(user.getUserName(), groupId, mt.getName()))
-      {
-         return;
-      }
-
-      MembershipImpl membership = new MembershipImpl();
-      membership.setMembershipType(mt.getName());
-      membership.setUserName(user.getUserName());
-      membership.setGroupId(g.getId());
-
-      if (broadcast)
-      {
-         preSave(membership, true);
-      }
-
-      getIdentitySession().getRoleManager().createRole(mt.getName(), user.getUserName(), groupId);
-
-      if (broadcast)
-      {
-         postSave(membership, true);
-      }
-
-   }
-
-   public void saveMembership(Membership m, boolean broadcast) throws Exception
-   {
-      String groupId =
-         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(m.getGroupId()),
-            orgService.getExoGroupType());
-
-      if (getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
-      {
-         return;
-      }
-
-      if (broadcast)
-      {
-         preSave(m, false);
-      }
-
-      getIdentitySession().getRoleManager().createRole(m.getMembershipType(), m.getUserName(), groupId);
-
-      if (broadcast)
-      {
-         postSave(m, false);
-      }
-   }
-
-   public Membership removeMembership(String id, boolean broadcast) throws Exception
-   {
-
-      Membership m = new MembershipImpl(id);
-
-      String groupId =
-         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(m.getGroupId()),
-            orgService.getExoGroupType());
-
-      if (!getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
-      {
-         return m;
-      }
-
-      if (broadcast)
-      {
-         preDelete(m);
-      }
-
-      getIdentitySession().getRoleManager().removeRole(m.getMembershipType(), m.getUserName(), groupId);
-
-      if (broadcast)
-      {
-         postDelete(m);
-      }
-      return m;
-   }
-
-   public Collection removeMembershipByUser(String userName, boolean broadcast) throws Exception
-   {
-
-      Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(userName, null);
-
-      //TODO: Exo UI has hardcoded casts to List
-      List<Membership> memberships = new LinkedList<Membership>();
-
-      for (Role role : roles)
-      {
-         MembershipImpl m = new MembershipImpl();
-         Group g = ((GroupDAOImpl)orgService.getGroupHandler()).getGroup(role.getGroup().getName());
-         m.setGroupId(g.getId());
-         m.setUserName(role.getUser().getId());
-         m.setMembershipType(role.getRoleType().getName());
-         memberships.add(m);
-
-         if (broadcast)
-         {
-            preDelete(m);
-         }
-
-         getIdentitySession().getRoleManager().removeRole(role);
-
-         if (broadcast)
-         {
-            postDelete(m);
-         }
-
-      }
-
-      return memberships;
-
-   }
-
-   public Membership findMembershipByUserGroupAndType(String userName, String groupId, String type) throws Exception
-   {
-      String gid =
-         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(groupId),
-            orgService.getExoGroupType());
-
-      Role role = getIdentitySession().getRoleManager().getRole(type, userName, gid);
-
-      if (role == null)
-      {
-         return null;
-      }
-
-      MembershipImpl m = new MembershipImpl();
-      m.setGroupId(groupId);
-      m.setUserName(userName);
-      m.setMembershipType(type);
-
-      return m;
-   }
-
-   public Collection findMembershipsByUserAndGroup(String userName, String groupId) throws Exception
-   {
-      if (userName == null)
-      {
-         // julien fix : if user name is null, need to check if we do need to return a special group
-         return Collections.emptyList();
-      }
-
-      String gid =
-         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(groupId),
-            orgService.getExoGroupType());
-
-      Collection<RoleType> roleTypes = getIdentitySession().getRoleManager().findRoleTypes(userName, gid, null);
-
-      //TODO: Exo UI has hardcoded casts to List
-      List<Membership> memberships = new LinkedList<Membership>();
-
-      for (RoleType roleType : roleTypes)
-      {
-         MembershipImpl m = new MembershipImpl();
-         m.setGroupId(groupId);
-         m.setUserName(userName);
-         m.setMembershipType(roleType.getName());
-         memberships.add(m);
-      }
-
-      return memberships;
-   }
-
-   public Collection findMembershipsByUser(String userName) throws Exception
-   {
-      Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(userName, null);
-
-      //TODO: Exo UI has hardcoded casts to List
-      List<Membership> memberships = new LinkedList<Membership>();
-
-      for (Role role : roles)
-      {
-         MembershipImpl m = new MembershipImpl();
-         Group g = ((GroupDAOImpl)orgService.getGroupHandler()).getGroup(role.getGroup().getName());
-         m.setGroupId(g.getId());
-         m.setUserName(role.getUser().getId());
-         m.setMembershipType(role.getRoleType().getName());
-         memberships.add(m);
-      }
-
-      return memberships;
-   }
-
-   static void removeMembershipEntriesOfGroup(JBossIDMOrganizationServiceImpl orgService, Group group,
-      IdentitySession session) throws Exception
-   {
-      String gid = session.getPersistenceManager().createGroupId(group.getGroupName(), orgService.getExoGroupType());
-
-      Collection<Role> roles = session.getRoleManager().findRoles(gid, null);
-
-      for (Role role : roles)
-      {
-         session.getRoleManager().removeRole(role);
-      }
-   }
-
-   public Collection findMembershipsByGroup(Group group) throws Exception
-   {
-      return findMembershipsByGroupId(group.getId());
-   }
-
-   public Collection findMembershipsByGroupId(String groupId) throws Exception
-   {
-      String gid =
-         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(groupId),
-            orgService.getExoGroupType());
-
-      Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(gid, null);
-
-      //TODO: Exo UI has hardcoded casts to List
-      List<Membership> memberships = new LinkedList<Membership>();
-
-      for (Role role : roles)
-      {
-         MembershipImpl m = new MembershipImpl();
-         Group g = ((GroupDAOImpl)orgService.getGroupHandler()).getGroup(role.getGroup().getName());
-         m.setGroupId(g.getId());
-         m.setUserName(role.getUser().getId());
-         m.setMembershipType(role.getRoleType().getName());
-         memberships.add(m);
-      }
-
-      return memberships;
-
-   }
-
-   public Membership findMembership(String id) throws Exception
-   {
-      Membership m = new MembershipImpl(id);
-
-      String groupId =
-         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(m.getGroupId()),
-            orgService.getExoGroupType());
-
-      if (getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
-      {
-         return m;
-      }
-
-      return null;
-   }
-
-   private void preSave(Membership membership, boolean isNew) throws Exception
-   {
-      for (int i = 0; i < listeners_.size(); i++)
-      {
-         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
-         listener.preSave(membership, isNew);
-      }
-   }
-
-   private void postSave(Membership membership, boolean isNew) throws Exception
-   {
-      for (int i = 0; i < listeners_.size(); i++)
-      {
-         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
-         listener.postSave(membership, isNew);
-      }
-   }
-
-   private void preDelete(Membership membership) throws Exception
-   {
-      for (int i = 0; i < listeners_.size(); i++)
-      {
-         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
-         listener.preDelete(membership);
-      }
-   }
-
-   private void postDelete(Membership membership) throws Exception
-   {
-      for (int i = 0; i < listeners_.size(); i++)
-      {
-         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
-         listener.postDelete(membership);
-      }
-   }
-
-   private IdentitySession getIdentitySession() throws Exception
-   {
-      return service_.getIdentitySession();
-   }
-
-   private String getGroupNameFromId(String groupId)
-   {
-      String[] ids = groupId.split("/");
-
-      return ids[ids.length - 1];
-   }
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,394 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.commons.utils.ListenerStack;
+import org.exoplatform.services.organization.Group;
+import org.exoplatform.services.organization.Membership;
+import org.exoplatform.services.organization.MembershipEventListener;
+import org.exoplatform.services.organization.MembershipHandler;
+import org.exoplatform.services.organization.MembershipType;
+import org.exoplatform.services.organization.User;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.Role;
+import org.jboss.identity.idm.api.RoleType;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.InvalidNameException;
+
+/**
+ */
+public class MembershipDAOImpl implements MembershipHandler
+{
+
+   private JBossIDMService service_;
+
+   private List listeners_;
+
+   private JBossIDMOrganizationServiceImpl orgService;
+
+   public MembershipDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service)
+   {
+      service_ = service;
+      listeners_ = new ListenerStack(5);
+      this.orgService = orgService;
+   }
+
+   public void addMembershipEventListener(MembershipEventListener listener)
+   {
+      listeners_.add(listener);
+   }
+
+   final public Membership createMembershipInstance()
+   {
+      return new MembershipImpl();
+   }
+
+   public void createMembership(Membership m, boolean broadcast) throws Exception
+   {
+
+      if (broadcast)
+      {
+         preSave(m, true);
+      }
+
+      saveMembership(m, false);
+
+      if (broadcast)
+      {
+         postSave(m, true);
+      }
+
+   }
+
+   public void linkMembership(User user, Group g, MembershipType mt, boolean broadcast) throws Exception
+   {
+      if (g == null)
+      {
+         throw new InvalidNameException("Can not create membership record for " + user.getUserName()
+            + " because group is null");
+      }
+
+      if (mt == null)
+      {
+         throw new InvalidNameException("Can not create membership record for " + user.getUserName()
+            + " because membership type is null");
+      }
+
+      if (getIdentitySession().getRoleManager().getRoleType(mt.getName()) == null)
+      {
+         getIdentitySession().getRoleManager().createRoleType(mt.getName());
+      }
+
+      String groupId =
+         getIdentitySession().getPersistenceManager().createGroupId(g.getGroupName(), orgService.getExoGroupType());
+
+      if (getIdentitySession().getRoleManager().hasRole(user.getUserName(), groupId, mt.getName()))
+      {
+         return;
+      }
+
+      MembershipImpl membership = new MembershipImpl();
+      membership.setMembershipType(mt.getName());
+      membership.setUserName(user.getUserName());
+      membership.setGroupId(g.getId());
+
+      if (broadcast)
+      {
+         preSave(membership, true);
+      }
+
+      getIdentitySession().getRoleManager().createRole(mt.getName(), user.getUserName(), groupId);
+
+      if (broadcast)
+      {
+         postSave(membership, true);
+      }
+
+   }
+
+   public void saveMembership(Membership m, boolean broadcast) throws Exception
+   {
+      String groupId =
+         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(m.getGroupId()),
+            orgService.getExoGroupType());
+
+      if (getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
+      {
+         return;
+      }
+
+      if (broadcast)
+      {
+         preSave(m, false);
+      }
+
+      getIdentitySession().getRoleManager().createRole(m.getMembershipType(), m.getUserName(), groupId);
+
+      if (broadcast)
+      {
+         postSave(m, false);
+      }
+   }
+
+   public Membership removeMembership(String id, boolean broadcast) throws Exception
+   {
+
+      Membership m = new MembershipImpl(id);
+
+      String groupId =
+         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(m.getGroupId()),
+            orgService.getExoGroupType());
+
+      if (!getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
+      {
+         return m;
+      }
+
+      if (broadcast)
+      {
+         preDelete(m);
+      }
+
+      getIdentitySession().getRoleManager().removeRole(m.getMembershipType(), m.getUserName(), groupId);
+
+      if (broadcast)
+      {
+         postDelete(m);
+      }
+      return m;
+   }
+
+   public Collection removeMembershipByUser(String userName, boolean broadcast) throws Exception
+   {
+
+      Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(userName, null);
+
+      //TODO: Exo UI has hardcoded casts to List
+      List<Membership> memberships = new LinkedList<Membership>();
+
+      for (Role role : roles)
+      {
+         MembershipImpl m = new MembershipImpl();
+         Group g = ((GroupDAOImpl)orgService.getGroupHandler()).getGroup(role.getGroup().getName());
+         m.setGroupId(g.getId());
+         m.setUserName(role.getUser().getId());
+         m.setMembershipType(role.getRoleType().getName());
+         memberships.add(m);
+
+         if (broadcast)
+         {
+            preDelete(m);
+         }
+
+         getIdentitySession().getRoleManager().removeRole(role);
+
+         if (broadcast)
+         {
+            postDelete(m);
+         }
+
+      }
+
+      return memberships;
+
+   }
+
+   public Membership findMembershipByUserGroupAndType(String userName, String groupId, String type) throws Exception
+   {
+      String gid =
+         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(groupId),
+            orgService.getExoGroupType());
+
+      Role role = getIdentitySession().getRoleManager().getRole(type, userName, gid);
+
+      if (role == null)
+      {
+         return null;
+      }
+
+      MembershipImpl m = new MembershipImpl();
+      m.setGroupId(groupId);
+      m.setUserName(userName);
+      m.setMembershipType(type);
+
+      return m;
+   }
+
+   public Collection findMembershipsByUserAndGroup(String userName, String groupId) throws Exception
+   {
+      if (userName == null)
+      {
+         // julien fix : if user name is null, need to check if we do need to return a special group
+         return Collections.emptyList();
+      }
+
+      String gid =
+         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(groupId),
+            orgService.getExoGroupType());
+
+      Collection<RoleType> roleTypes = getIdentitySession().getRoleManager().findRoleTypes(userName, gid, null);
+
+      //TODO: Exo UI has hardcoded casts to List
+      List<Membership> memberships = new LinkedList<Membership>();
+
+      for (RoleType roleType : roleTypes)
+      {
+         MembershipImpl m = new MembershipImpl();
+         m.setGroupId(groupId);
+         m.setUserName(userName);
+         m.setMembershipType(roleType.getName());
+         memberships.add(m);
+      }
+
+      return memberships;
+   }
+
+   public Collection findMembershipsByUser(String userName) throws Exception
+   {
+      Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(userName, null);
+
+      //TODO: Exo UI has hardcoded casts to List
+      List<Membership> memberships = new LinkedList<Membership>();
+
+      for (Role role : roles)
+      {
+         MembershipImpl m = new MembershipImpl();
+         Group g = ((GroupDAOImpl)orgService.getGroupHandler()).getGroup(role.getGroup().getName());
+         m.setGroupId(g.getId());
+         m.setUserName(role.getUser().getId());
+         m.setMembershipType(role.getRoleType().getName());
+         memberships.add(m);
+      }
+
+      return memberships;
+   }
+
+   static void removeMembershipEntriesOfGroup(JBossIDMOrganizationServiceImpl orgService, Group group,
+      IdentitySession session) throws Exception
+   {
+      String gid = session.getPersistenceManager().createGroupId(group.getGroupName(), orgService.getExoGroupType());
+
+      Collection<Role> roles = session.getRoleManager().findRoles(gid, null);
+
+      for (Role role : roles)
+      {
+         session.getRoleManager().removeRole(role);
+      }
+   }
+
+   public Collection findMembershipsByGroup(Group group) throws Exception
+   {
+      return findMembershipsByGroupId(group.getId());
+   }
+
+   public Collection findMembershipsByGroupId(String groupId) throws Exception
+   {
+      String gid =
+         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(groupId),
+            orgService.getExoGroupType());
+
+      Collection<Role> roles = getIdentitySession().getRoleManager().findRoles(gid, null);
+
+      //TODO: Exo UI has hardcoded casts to List
+      List<Membership> memberships = new LinkedList<Membership>();
+
+      for (Role role : roles)
+      {
+         MembershipImpl m = new MembershipImpl();
+         Group g = ((GroupDAOImpl)orgService.getGroupHandler()).getGroup(role.getGroup().getName());
+         m.setGroupId(g.getId());
+         m.setUserName(role.getUser().getId());
+         m.setMembershipType(role.getRoleType().getName());
+         memberships.add(m);
+      }
+
+      return memberships;
+
+   }
+
+   public Membership findMembership(String id) throws Exception
+   {
+      Membership m = new MembershipImpl(id);
+
+      String groupId =
+         getIdentitySession().getPersistenceManager().createGroupId(getGroupNameFromId(m.getGroupId()),
+            orgService.getExoGroupType());
+
+      if (getIdentitySession().getRoleManager().hasRole(m.getUserName(), groupId, m.getMembershipType()))
+      {
+         return m;
+      }
+
+      return null;
+   }
+
+   private void preSave(Membership membership, boolean isNew) throws Exception
+   {
+      for (int i = 0; i < listeners_.size(); i++)
+      {
+         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
+         listener.preSave(membership, isNew);
+      }
+   }
+
+   private void postSave(Membership membership, boolean isNew) throws Exception
+   {
+      for (int i = 0; i < listeners_.size(); i++)
+      {
+         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
+         listener.postSave(membership, isNew);
+      }
+   }
+
+   private void preDelete(Membership membership) throws Exception
+   {
+      for (int i = 0; i < listeners_.size(); i++)
+      {
+         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
+         listener.preDelete(membership);
+      }
+   }
+
+   private void postDelete(Membership membership) throws Exception
+   {
+      for (int i = 0; i < listeners_.size(); i++)
+      {
+         MembershipEventListener listener = (MembershipEventListener)listeners_.get(i);
+         listener.postDelete(membership);
+      }
+   }
+
+   private IdentitySession getIdentitySession() throws Exception
+   {
+      return service_.getIdentitySession();
+   }
+
+   private String getGroupNameFromId(String groupId)
+   {
+      String[] ids = groupId.split("/");
+
+      return ids[ids.length - 1];
+   }
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,106 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.services.organization.Membership;
-
-public class MembershipImpl implements Membership
-{
-   private String membershipType = "member";
-
-   private String userName = null;
-
-   private String groupId = null;
-
-   public MembershipImpl()
-   {
-   }
-
-   public MembershipImpl(String id)
-   {
-      String[] fields = id.split(":");
-
-      // Id can be pure "//" in some cases
-      if (fields[0] != null)
-      {
-         membershipType = fields[0];
-      }
-      if (fields[1] != null)
-      {
-         userName = fields[1];
-      }
-      if (fields[2] != null)
-      {
-         groupId = fields[2];
-      }
-   }
-
-   public String getId()
-   {
-      StringBuffer id = new StringBuffer();
-
-      if (membershipType != null)
-      {
-         id.append(membershipType);
-      }
-      id.append(":");
-      if (userName != null)
-      {
-         id.append(userName);
-      }
-      id.append(":");
-      if (groupId != null)
-      {
-         id.append(groupId);
-      }
-
-      return id.toString();
-   }
-
-   public String getMembershipType()
-   {
-      return membershipType;
-   }
-
-   public void setMembershipType(String membershipType)
-   {
-      this.membershipType = membershipType;
-   }
-
-   public String getUserName()
-   {
-      return userName;
-   }
-
-   public void setUserName(String userName)
-   {
-      this.userName = userName;
-   }
-
-   public String getGroupId()
-   {
-      return groupId;
-   }
-
-   public void setGroupId(String groupId)
-   {
-      this.groupId = groupId;
-   }
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,106 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.services.organization.Membership;
+
+public class MembershipImpl implements Membership
+{
+   private String membershipType = "member";
+
+   private String userName = null;
+
+   private String groupId = null;
+
+   public MembershipImpl()
+   {
+   }
+
+   public MembershipImpl(String id)
+   {
+      String[] fields = id.split(":");
+
+      // Id can be pure "//" in some cases
+      if (fields[0] != null)
+      {
+         membershipType = fields[0];
+      }
+      if (fields[1] != null)
+      {
+         userName = fields[1];
+      }
+      if (fields[2] != null)
+      {
+         groupId = fields[2];
+      }
+   }
+
+   public String getId()
+   {
+      StringBuffer id = new StringBuffer();
+
+      if (membershipType != null)
+      {
+         id.append(membershipType);
+      }
+      id.append(":");
+      if (userName != null)
+      {
+         id.append(userName);
+      }
+      id.append(":");
+      if (groupId != null)
+      {
+         id.append(groupId);
+      }
+
+      return id.toString();
+   }
+
+   public String getMembershipType()
+   {
+      return membershipType;
+   }
+
+   public void setMembershipType(String membershipType)
+   {
+      this.membershipType = membershipType;
+   }
+
+   public String getUserName()
+   {
+      return userName;
+   }
+
+   public void setUserName(String userName)
+   {
+      this.userName = userName;
+   }
+
+   public String getGroupId()
+   {
+      return groupId;
+   }
+
+   public void setGroupId(String groupId)
+   {
+      this.groupId = groupId;
+   }
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,178 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.services.organization.MembershipType;
-import org.exoplatform.services.organization.MembershipTypeHandler;
-import org.exoplatform.services.organization.impl.MembershipTypeImpl;
-import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.RoleType;
-
-import java.text.DateFormat;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-public class MembershipTypeDAOImpl implements MembershipTypeHandler
-{
-
-   public static final String MEMBERSHIP_DESCRIPTION = "description";
-
-   public static final String MEMBERSHIP_OWNER = "owner";
-
-   public static final String MEMBERSHIP_CREATE_DATE = "create_date";
-
-   public static final String MEMBERSHIP_MODIFIED_DATE = "modified_date";
-
-   public static final DateFormat dateFormat = DateFormat.getInstance();
-
-   private JBossIDMService service_;
-
-   private JBossIDMOrganizationServiceImpl orgService;
-
-   public MembershipTypeDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service)
-   {
-      service_ = service;
-      this.orgService = orgService;
-   }
-
-   final public MembershipType createMembershipTypeInstance()
-   {
-      return new MembershipTypeImpl();
-   }
-
-   public MembershipType createMembershipType(MembershipType mt, boolean broadcast) throws Exception
-   {
-      Date now = new Date();
-      mt.setCreatedDate(now);
-      mt.setModifiedDate(now);
-
-      getIdentitySession().getRoleManager().createRoleType(mt.getName());
-      updateMembershipType(mt);
-
-      return mt;
-   }
-
-   public MembershipType saveMembershipType(MembershipType mt, boolean broadcast) throws Exception
-   {
-      Date now = new Date();
-      mt.setModifiedDate(now);
-      updateMembershipType(mt);
-      return mt;
-   }
-
-   public MembershipType findMembershipType(String name) throws Exception
-   {
-      RoleType rt = getIdentitySession().getRoleManager().getRoleType(name);
-
-      MembershipType mt = null;
-
-      if (rt != null)
-      {
-         mt = new MembershipTypeImpl(name, null, null);
-         populateMembershipType(mt);
-      }
-
-      return mt;
-   }
-
-   public MembershipType removeMembershipType(String name, boolean broadcast) throws Exception
-   {
-      MembershipType mt = findMembershipType(name);
-
-      if (mt != null)
-      {
-         getIdentitySession().getRoleManager().removeRoleType(mt.getName());
-      }
-
-      return mt;
-
-   }
-
-   public Collection findMembershipTypes() throws Exception
-   {
-
-      Collection<RoleType> rts = getIdentitySession().getRoleManager().findRoleTypes();
-
-      List<MembershipType> mts = new LinkedList<MembershipType>();
-
-      for (RoleType rt : rts)
-      {
-         MembershipType mt = new MembershipTypeImpl(rt.getName(), null, null);
-         populateMembershipType(mt);
-         mts.add(mt);
-      }
-
-      return mts;
-   }
-
-   private IdentitySession getIdentitySession() throws Exception
-   {
-      return service_.getIdentitySession();
-   }
-
-   private void updateMembershipType(MembershipType mt) throws Exception
-   {
-
-      RoleType rt = getIdentitySession().getRoleManager().getRoleType(mt.getName());
-
-      Map<String, String> props = new HashMap<String, String>();
-
-      props.put(MEMBERSHIP_DESCRIPTION, mt.getDescription());
-      props.put(MEMBERSHIP_CREATE_DATE, mt.getCreatedDate() == null ? null : dateFormat.format(mt.getCreatedDate()));
-      props
-         .put(MEMBERSHIP_MODIFIED_DATE, mt.getModifiedDate() == null ? null : dateFormat.format(mt.getModifiedDate()));
-      props.put(MEMBERSHIP_OWNER, mt.getOwner());
-
-      getIdentitySession().getRoleManager().setProperties(rt, props);
-
-      return;
-
-   }
-
-   private void populateMembershipType(MembershipType mt) throws Exception
-   {
-      RoleType rt = getIdentitySession().getRoleManager().getRoleType(mt.getName());
-
-      Map<String, String> props = getIdentitySession().getRoleManager().getProperties(rt);
-
-      mt.setDescription(props.get(MEMBERSHIP_DESCRIPTION));
-      mt.setOwner(props.get(MEMBERSHIP_OWNER));
-
-      String cd = props.get(MEMBERSHIP_CREATE_DATE);
-      String md = props.get(MEMBERSHIP_MODIFIED_DATE);
-
-      if (cd != null)
-      {
-         mt.setCreatedDate(dateFormat.parse(cd));
-      }
-
-      if (md != null)
-      {
-         mt.setModifiedDate(dateFormat.parse(md));
-      }
-
-      return;
-   }
-
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/MembershipTypeDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,178 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.services.organization.MembershipType;
+import org.exoplatform.services.organization.MembershipTypeHandler;
+import org.exoplatform.services.organization.impl.MembershipTypeImpl;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.RoleType;
+
+import java.text.DateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+public class MembershipTypeDAOImpl implements MembershipTypeHandler
+{
+
+   public static final String MEMBERSHIP_DESCRIPTION = "description";
+
+   public static final String MEMBERSHIP_OWNER = "owner";
+
+   public static final String MEMBERSHIP_CREATE_DATE = "create_date";
+
+   public static final String MEMBERSHIP_MODIFIED_DATE = "modified_date";
+
+   public static final DateFormat dateFormat = DateFormat.getInstance();
+
+   private JBossIDMService service_;
+
+   private JBossIDMOrganizationServiceImpl orgService;
+
+   public MembershipTypeDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service)
+   {
+      service_ = service;
+      this.orgService = orgService;
+   }
+
+   final public MembershipType createMembershipTypeInstance()
+   {
+      return new MembershipTypeImpl();
+   }
+
+   public MembershipType createMembershipType(MembershipType mt, boolean broadcast) throws Exception
+   {
+      Date now = new Date();
+      mt.setCreatedDate(now);
+      mt.setModifiedDate(now);
+
+      getIdentitySession().getRoleManager().createRoleType(mt.getName());
+      updateMembershipType(mt);
+
+      return mt;
+   }
+
+   public MembershipType saveMembershipType(MembershipType mt, boolean broadcast) throws Exception
+   {
+      Date now = new Date();
+      mt.setModifiedDate(now);
+      updateMembershipType(mt);
+      return mt;
+   }
+
+   public MembershipType findMembershipType(String name) throws Exception
+   {
+      RoleType rt = getIdentitySession().getRoleManager().getRoleType(name);
+
+      MembershipType mt = null;
+
+      if (rt != null)
+      {
+         mt = new MembershipTypeImpl(name, null, null);
+         populateMembershipType(mt);
+      }
+
+      return mt;
+   }
+
+   public MembershipType removeMembershipType(String name, boolean broadcast) throws Exception
+   {
+      MembershipType mt = findMembershipType(name);
+
+      if (mt != null)
+      {
+         getIdentitySession().getRoleManager().removeRoleType(mt.getName());
+      }
+
+      return mt;
+
+   }
+
+   public Collection findMembershipTypes() throws Exception
+   {
+
+      Collection<RoleType> rts = getIdentitySession().getRoleManager().findRoleTypes();
+
+      List<MembershipType> mts = new LinkedList<MembershipType>();
+
+      for (RoleType rt : rts)
+      {
+         MembershipType mt = new MembershipTypeImpl(rt.getName(), null, null);
+         populateMembershipType(mt);
+         mts.add(mt);
+      }
+
+      return mts;
+   }
+
+   private IdentitySession getIdentitySession() throws Exception
+   {
+      return service_.getIdentitySession();
+   }
+
+   private void updateMembershipType(MembershipType mt) throws Exception
+   {
+
+      RoleType rt = getIdentitySession().getRoleManager().getRoleType(mt.getName());
+
+      Map<String, String> props = new HashMap<String, String>();
+
+      props.put(MEMBERSHIP_DESCRIPTION, mt.getDescription());
+      props.put(MEMBERSHIP_CREATE_DATE, mt.getCreatedDate() == null ? null : dateFormat.format(mt.getCreatedDate()));
+      props
+         .put(MEMBERSHIP_MODIFIED_DATE, mt.getModifiedDate() == null ? null : dateFormat.format(mt.getModifiedDate()));
+      props.put(MEMBERSHIP_OWNER, mt.getOwner());
+
+      getIdentitySession().getRoleManager().setProperties(rt, props);
+
+      return;
+
+   }
+
+   private void populateMembershipType(MembershipType mt) throws Exception
+   {
+      RoleType rt = getIdentitySession().getRoleManager().getRoleType(mt.getName());
+
+      Map<String, String> props = getIdentitySession().getRoleManager().getProperties(rt);
+
+      mt.setDescription(props.get(MEMBERSHIP_DESCRIPTION));
+      mt.setOwner(props.get(MEMBERSHIP_OWNER));
+
+      String cd = props.get(MEMBERSHIP_CREATE_DATE);
+      String md = props.get(MEMBERSHIP_MODIFIED_DATE);
+
+      if (cd != null)
+      {
+         mt.setCreatedDate(dateFormat.parse(cd));
+      }
+
+      if (md != null)
+      {
+         mt.setModifiedDate(dateFormat.parse(md));
+      }
+
+      return;
+   }
+
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,416 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.organization.Query;
-import org.exoplatform.services.organization.User;
-import org.exoplatform.services.organization.UserEventListener;
-import org.exoplatform.services.organization.UserHandler;
-import org.exoplatform.services.organization.impl.UserImpl;
-import org.jboss.identity.idm.api.Attribute;
-import org.jboss.identity.idm.api.AttributesManager;
-import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.api.query.UserQueryBuilder;
-import org.jboss.identity.idm.impl.api.SimpleAttribute;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- */
-public class UserDAOImpl implements UserHandler
-{
-
-   private final JBossIDMService service_;
-
-   private ExoCache cache_;
-
-   private List<UserEventListener> listeners_ = new ArrayList<UserEventListener>(3);
-
-   public static final String USER_PASSWORD = "password";
-
-   public static final String USER_FIRST_NAME = "firstName";
-
-   public static final String USER_LAST_NAME = "lastName";
-
-   public static final String USER_EMAIL = "email";
-
-   public static final String USER_CREATED_DATE = "createdDate";
-
-   public static final String USER_LAST_LOGIN_TIME = "lastLoginTime";
-
-   public static final String USER_ORGANIZATION_ID = "organizationId";
-
-   public static final Set<String> USER_NON_PROFILE_KEYS;
-
-   public static final DateFormat dateFormat = DateFormat.getInstance();
-
-   private JBossIDMOrganizationServiceImpl orgService;
-
-   static
-   {
-      Set<String> keys = new HashSet<String>();
-      keys.add(USER_PASSWORD);
-      keys.add(USER_FIRST_NAME);
-      keys.add(USER_LAST_NAME);
-      keys.add(USER_EMAIL);
-      keys.add(USER_CREATED_DATE);
-      keys.add(USER_LAST_LOGIN_TIME);
-      keys.add(USER_ORGANIZATION_ID);
-
-      USER_NON_PROFILE_KEYS = Collections.unmodifiableSet(keys);
-   }
-
-   public UserDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService idmService, CacheService cservice)
-      throws Exception
-   {
-      service_ = idmService;
-      cache_ = cservice.getCacheInstance(UserImpl.class.getName());
-      this.orgService = orgService;
-   }
-
-   final public List getUserEventListeners()
-   {
-      return listeners_;
-   }
-
-   public void addUserEventListener(UserEventListener listener)
-   {
-      listeners_.add(listener);
-   }
-
-   public User createUserInstance()
-   {
-      return new UserImpl();
-   }
-
-   public User createUserInstance(String username)
-   {
-      return new UserImpl(username);
-   }
-
-   public void createUser(User user, boolean broadcast) throws Exception
-   {
-      IdentitySession session = service_.getIdentitySession();
-      if (broadcast)
-      {
-         preSave(user, true);
-      }
-
-      session.getPersistenceManager().createUser(user.getUserName());
-
-      persistUserInfo(user, session);
-
-      if (broadcast)
-      {
-         postSave(user, true);
-      }
-
-   }
-
-   public void saveUser(User user, boolean broadcast) throws Exception
-   {
-      IdentitySession session = service_.getIdentitySession();
-      if (broadcast)
-      {
-         preSave(user, false);
-      }
-
-      persistUserInfo(user, session);
-
-      if (broadcast)
-      {
-         postSave(user, false);
-      }
-      cache_.put(user.getUserName(), user);
-   }
-
-   public User removeUser(String userName, boolean broadcast) throws Exception
-   {
-      IdentitySession session = service_.getIdentitySession();
-
-      org.jboss.identity.idm.api.User foundUser = session.getPersistenceManager().findUser(userName);
-
-      if (foundUser == null)
-      {
-         cache_.remove(userName);
-         return null;
-      }
-
-      User exoUser = getPopulatedUser(userName, session);
-
-      if (broadcast)
-      {
-         preDelete(exoUser);
-      }
-
-      session.getPersistenceManager().removeUser(foundUser, true);
-      if (broadcast)
-      {
-         postDelete(exoUser);
-      }
-      cache_.remove(userName);
-      return exoUser;
-   }
-
-   //
-   public User findUserByName(String userName) throws Exception
-   {
-      IdentitySession session = service_.getIdentitySession();
-
-      User user = (User)cache_.get(userName);
-      if (user != null)
-      {
-         return user;
-      }
-      user = getPopulatedUser(userName, session);
-      if (user != null)
-      {
-         cache_.put(userName, user);
-      }
-      return user;
-   }
-
-   public LazyPageList getUserPageList(int pageSize) throws Exception
-   {
-      UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
-
-      return new LazyPageList(new IDMUserListAccess(this, service_, qb, pageSize, true), pageSize);
-   }
-
-   //
-   public boolean authenticate(String username, String password) throws Exception
-   {
-      User user = findUserByName(username);
-      if (user == null)
-      {
-         return false;
-      }
-
-      boolean authenticated = false;
-
-      if (orgService.isPasswordAsAttribute())
-      {
-         authenticated = user.getPassword().equals(password);
-      }
-      else
-      {
-         IdentitySession session = service_.getIdentitySession();
-         org.jboss.identity.idm.api.User idmUser = session.getPersistenceManager().findUser(user.getUserName());
-
-         authenticated = session.getAttributesManager().validatePassword(idmUser, password);
-      }
-
-      if (authenticated)
-      {
-         UserImpl userImpl = (UserImpl)user;
-         userImpl.setLastLoginTime(Calendar.getInstance().getTime());
-         saveUser(userImpl, false);
-      }
-      return authenticated;
-   }
-
-   public LazyPageList findUsers(Query q) throws Exception
-   {
-
-      UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
-
-      if (q.getUserName() != null)
-      {
-         qb.idFilter(q.getUserName());
-      }
-      if (q.getEmail() != null)
-      {
-         qb.attributeValuesFilter(UserDAOImpl.USER_EMAIL, new String[]{q.getEmail()});
-      }
-      if (q.getFirstName() != null)
-      {
-         qb.attributeValuesFilter(UserDAOImpl.USER_FIRST_NAME, new String[]{q.getFirstName()});
-      }
-
-      //TODO: from/to login date
-
-      if (q.getLastName() != null)
-      {
-         qb.attributeValuesFilter(UserDAOImpl.USER_LAST_NAME, new String[]{q.getLastName()});
-      }
-
-      return new LazyPageList(new IDMUserListAccess(this, service_, qb, 20, false), 20);
-   }
-
-   //
-   public LazyPageList findUsersByGroup(String groupId) throws Exception
-   {
-      UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
-
-      org.jboss.identity.idm.api.Group jbidGroup = orgService.getJBIDMGroup(groupId);
-
-      qb.addRelatedGroup(jbidGroup);
-
-      return new LazyPageList(new IDMUserListAccess(this, service_, qb, 20, false), 20);
-   }
-
-   //
-
-   private void preSave(User user, boolean isNew) throws Exception
-   {
-      for (UserEventListener listener : listeners_)
-      {
-         listener.preSave(user, isNew);
-      }
-   }
-
-   private void postSave(User user, boolean isNew) throws Exception
-   {
-      for (UserEventListener listener : listeners_)
-      {
-         listener.postSave(user, isNew);
-      }
-   }
-
-   private void preDelete(User user) throws Exception
-   {
-      for (UserEventListener listener : listeners_)
-      {
-         listener.preDelete(user);
-      }
-   }
-
-   private void postDelete(User user) throws Exception
-   {
-      for (UserEventListener listener : listeners_)
-      {
-         listener.postDelete(user);
-      }
-   }
-
-   public void persistUserInfo(User user, IdentitySession session) throws Exception
-   {
-
-      AttributesManager am = session.getAttributesManager();
-
-      ArrayList attributes = new ArrayList();
-
-      if (user.getCreatedDate() != null)
-      {
-         attributes.add(new SimpleAttribute(USER_CREATED_DATE, dateFormat.format(user.getCreatedDate())));
-      }
-      if (user.getLastLoginTime() != null)
-      {
-         attributes.add(new SimpleAttribute(USER_LAST_LOGIN_TIME, dateFormat.format(user.getLastLoginTime())));
-      }
-      if (user.getEmail() != null)
-      {
-         attributes.add(new SimpleAttribute(USER_EMAIL, user.getEmail()));
-      }
-      if (user.getFirstName() != null)
-      {
-         attributes.add(new SimpleAttribute(USER_FIRST_NAME, user.getFirstName()));
-      }
-      if (user.getLastName() != null)
-      {
-         attributes.add(new SimpleAttribute(USER_LAST_NAME, user.getLastName()));
-      }
-      if (user.getOrganizationId() != null)
-      {
-         attributes.add(new SimpleAttribute(USER_ORGANIZATION_ID, user.getOrganizationId()));
-      }
-      if (user.getPassword() != null)
-      {
-         if (orgService.isPasswordAsAttribute())
-         {
-            attributes.add(new SimpleAttribute(USER_PASSWORD, user.getPassword()));
-         }
-         else
-         {
-            am.updatePassword(session.getPersistenceManager().findUser(user.getUserName()), user.getPassword());
-         }
-      }
-
-      Attribute[] attrs = new Attribute[attributes.size()];
-      attrs = (Attribute[])attributes.toArray(attrs);
-      am.addAttributes(user.getUserName(), attrs);
-   }
-
-   public static User getPopulatedUser(String userName, IdentitySession session) throws Exception
-   {
-
-      if (session.getPersistenceManager().findUser(userName) == null)
-      {
-         return null;
-      }
-
-      AttributesManager am = session.getAttributesManager();
-
-      Map<String, Attribute> attrs = am.getAttributes(userName);
-
-      User user = new UserImpl(userName);
-
-      if (attrs == null)
-      {
-
-         return user;
-      }
-      else
-      {
-         if (attrs.containsKey(USER_CREATED_DATE))
-         {
-            user.setCreatedDate(dateFormat.parse(attrs.get(USER_CREATED_DATE).getValue().toString()));
-         }
-         if (attrs.containsKey(USER_EMAIL))
-         {
-            user.setEmail(attrs.get(USER_EMAIL).getValue().toString());
-         }
-         if (attrs.containsKey(USER_FIRST_NAME))
-         {
-            user.setFirstName(attrs.get(USER_FIRST_NAME).getValue().toString());
-         }
-         if (attrs.containsKey(USER_LAST_LOGIN_TIME))
-         {
-            user.setLastLoginTime(dateFormat.parse(attrs.get(USER_LAST_LOGIN_TIME).getValue().toString()));
-         }
-         if (attrs.containsKey(USER_LAST_NAME))
-         {
-            user.setLastName(attrs.get(USER_LAST_NAME).getValue().toString());
-         }
-         if (attrs.containsKey(USER_ORGANIZATION_ID))
-         {
-            user.setOrganizationId(attrs.get(USER_ORGANIZATION_ID).getValue().toString());
-         }
-         if (attrs.containsKey(USER_PASSWORD))
-         {
-            user.setPassword(attrs.get(USER_PASSWORD).getValue().toString());
-         }
-      }
-
-      return user;
-
-   }
-
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,416 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.organization.Query;
+import org.exoplatform.services.organization.User;
+import org.exoplatform.services.organization.UserEventListener;
+import org.exoplatform.services.organization.UserHandler;
+import org.exoplatform.services.organization.impl.UserImpl;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.AttributesManager;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.query.UserQueryBuilder;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ */
+public class UserDAOImpl implements UserHandler
+{
+
+   private final JBossIDMService service_;
+
+   private ExoCache cache_;
+
+   private List<UserEventListener> listeners_ = new ArrayList<UserEventListener>(3);
+
+   public static final String USER_PASSWORD = "password";
+
+   public static final String USER_FIRST_NAME = "firstName";
+
+   public static final String USER_LAST_NAME = "lastName";
+
+   public static final String USER_EMAIL = "email";
+
+   public static final String USER_CREATED_DATE = "createdDate";
+
+   public static final String USER_LAST_LOGIN_TIME = "lastLoginTime";
+
+   public static final String USER_ORGANIZATION_ID = "organizationId";
+
+   public static final Set<String> USER_NON_PROFILE_KEYS;
+
+   public static final DateFormat dateFormat = DateFormat.getInstance();
+
+   private JBossIDMOrganizationServiceImpl orgService;
+
+   static
+   {
+      Set<String> keys = new HashSet<String>();
+      keys.add(USER_PASSWORD);
+      keys.add(USER_FIRST_NAME);
+      keys.add(USER_LAST_NAME);
+      keys.add(USER_EMAIL);
+      keys.add(USER_CREATED_DATE);
+      keys.add(USER_LAST_LOGIN_TIME);
+      keys.add(USER_ORGANIZATION_ID);
+
+      USER_NON_PROFILE_KEYS = Collections.unmodifiableSet(keys);
+   }
+
+   public UserDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService idmService, CacheService cservice)
+      throws Exception
+   {
+      service_ = idmService;
+      cache_ = cservice.getCacheInstance(UserImpl.class.getName());
+      this.orgService = orgService;
+   }
+
+   final public List getUserEventListeners()
+   {
+      return listeners_;
+   }
+
+   public void addUserEventListener(UserEventListener listener)
+   {
+      listeners_.add(listener);
+   }
+
+   public User createUserInstance()
+   {
+      return new UserImpl();
+   }
+
+   public User createUserInstance(String username)
+   {
+      return new UserImpl(username);
+   }
+
+   public void createUser(User user, boolean broadcast) throws Exception
+   {
+      IdentitySession session = service_.getIdentitySession();
+      if (broadcast)
+      {
+         preSave(user, true);
+      }
+
+      session.getPersistenceManager().createUser(user.getUserName());
+
+      persistUserInfo(user, session);
+
+      if (broadcast)
+      {
+         postSave(user, true);
+      }
+
+   }
+
+   public void saveUser(User user, boolean broadcast) throws Exception
+   {
+      IdentitySession session = service_.getIdentitySession();
+      if (broadcast)
+      {
+         preSave(user, false);
+      }
+
+      persistUserInfo(user, session);
+
+      if (broadcast)
+      {
+         postSave(user, false);
+      }
+      cache_.put(user.getUserName(), user);
+   }
+
+   public User removeUser(String userName, boolean broadcast) throws Exception
+   {
+      IdentitySession session = service_.getIdentitySession();
+
+      org.jboss.identity.idm.api.User foundUser = session.getPersistenceManager().findUser(userName);
+
+      if (foundUser == null)
+      {
+         cache_.remove(userName);
+         return null;
+      }
+
+      User exoUser = getPopulatedUser(userName, session);
+
+      if (broadcast)
+      {
+         preDelete(exoUser);
+      }
+
+      session.getPersistenceManager().removeUser(foundUser, true);
+      if (broadcast)
+      {
+         postDelete(exoUser);
+      }
+      cache_.remove(userName);
+      return exoUser;
+   }
+
+   //
+   public User findUserByName(String userName) throws Exception
+   {
+      IdentitySession session = service_.getIdentitySession();
+
+      User user = (User)cache_.get(userName);
+      if (user != null)
+      {
+         return user;
+      }
+      user = getPopulatedUser(userName, session);
+      if (user != null)
+      {
+         cache_.put(userName, user);
+      }
+      return user;
+   }
+
+   public LazyPageList getUserPageList(int pageSize) throws Exception
+   {
+      UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
+
+      return new LazyPageList(new IDMUserListAccess(this, service_, qb, pageSize, true), pageSize);
+   }
+
+   //
+   public boolean authenticate(String username, String password) throws Exception
+   {
+      User user = findUserByName(username);
+      if (user == null)
+      {
+         return false;
+      }
+
+      boolean authenticated = false;
+
+      if (orgService.isPasswordAsAttribute())
+      {
+         authenticated = user.getPassword().equals(password);
+      }
+      else
+      {
+         IdentitySession session = service_.getIdentitySession();
+         org.jboss.identity.idm.api.User idmUser = session.getPersistenceManager().findUser(user.getUserName());
+
+         authenticated = session.getAttributesManager().validatePassword(idmUser, password);
+      }
+
+      if (authenticated)
+      {
+         UserImpl userImpl = (UserImpl)user;
+         userImpl.setLastLoginTime(Calendar.getInstance().getTime());
+         saveUser(userImpl, false);
+      }
+      return authenticated;
+   }
+
+   public LazyPageList findUsers(Query q) throws Exception
+   {
+
+      UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
+
+      if (q.getUserName() != null)
+      {
+         qb.idFilter(q.getUserName());
+      }
+      if (q.getEmail() != null)
+      {
+         qb.attributeValuesFilter(UserDAOImpl.USER_EMAIL, new String[]{q.getEmail()});
+      }
+      if (q.getFirstName() != null)
+      {
+         qb.attributeValuesFilter(UserDAOImpl.USER_FIRST_NAME, new String[]{q.getFirstName()});
+      }
+
+      //TODO: from/to login date
+
+      if (q.getLastName() != null)
+      {
+         qb.attributeValuesFilter(UserDAOImpl.USER_LAST_NAME, new String[]{q.getLastName()});
+      }
+
+      return new LazyPageList(new IDMUserListAccess(this, service_, qb, 20, false), 20);
+   }
+
+   //
+   public LazyPageList findUsersByGroup(String groupId) throws Exception
+   {
+      UserQueryBuilder qb = service_.getIdentitySession().createUserQueryBuilder();
+
+      org.jboss.identity.idm.api.Group jbidGroup = orgService.getJBIDMGroup(groupId);
+
+      qb.addRelatedGroup(jbidGroup);
+
+      return new LazyPageList(new IDMUserListAccess(this, service_, qb, 20, false), 20);
+   }
+
+   //
+
+   private void preSave(User user, boolean isNew) throws Exception
+   {
+      for (UserEventListener listener : listeners_)
+      {
+         listener.preSave(user, isNew);
+      }
+   }
+
+   private void postSave(User user, boolean isNew) throws Exception
+   {
+      for (UserEventListener listener : listeners_)
+      {
+         listener.postSave(user, isNew);
+      }
+   }
+
+   private void preDelete(User user) throws Exception
+   {
+      for (UserEventListener listener : listeners_)
+      {
+         listener.preDelete(user);
+      }
+   }
+
+   private void postDelete(User user) throws Exception
+   {
+      for (UserEventListener listener : listeners_)
+      {
+         listener.postDelete(user);
+      }
+   }
+
+   public void persistUserInfo(User user, IdentitySession session) throws Exception
+   {
+
+      AttributesManager am = session.getAttributesManager();
+
+      ArrayList attributes = new ArrayList();
+
+      if (user.getCreatedDate() != null)
+      {
+         attributes.add(new SimpleAttribute(USER_CREATED_DATE, dateFormat.format(user.getCreatedDate())));
+      }
+      if (user.getLastLoginTime() != null)
+      {
+         attributes.add(new SimpleAttribute(USER_LAST_LOGIN_TIME, dateFormat.format(user.getLastLoginTime())));
+      }
+      if (user.getEmail() != null)
+      {
+         attributes.add(new SimpleAttribute(USER_EMAIL, user.getEmail()));
+      }
+      if (user.getFirstName() != null)
+      {
+         attributes.add(new SimpleAttribute(USER_FIRST_NAME, user.getFirstName()));
+      }
+      if (user.getLastName() != null)
+      {
+         attributes.add(new SimpleAttribute(USER_LAST_NAME, user.getLastName()));
+      }
+      if (user.getOrganizationId() != null)
+      {
+         attributes.add(new SimpleAttribute(USER_ORGANIZATION_ID, user.getOrganizationId()));
+      }
+      if (user.getPassword() != null)
+      {
+         if (orgService.isPasswordAsAttribute())
+         {
+            attributes.add(new SimpleAttribute(USER_PASSWORD, user.getPassword()));
+         }
+         else
+         {
+            am.updatePassword(session.getPersistenceManager().findUser(user.getUserName()), user.getPassword());
+         }
+      }
+
+      Attribute[] attrs = new Attribute[attributes.size()];
+      attrs = (Attribute[])attributes.toArray(attrs);
+      am.addAttributes(user.getUserName(), attrs);
+   }
+
+   public static User getPopulatedUser(String userName, IdentitySession session) throws Exception
+   {
+
+      if (session.getPersistenceManager().findUser(userName) == null)
+      {
+         return null;
+      }
+
+      AttributesManager am = session.getAttributesManager();
+
+      Map<String, Attribute> attrs = am.getAttributes(userName);
+
+      User user = new UserImpl(userName);
+
+      if (attrs == null)
+      {
+
+         return user;
+      }
+      else
+      {
+         if (attrs.containsKey(USER_CREATED_DATE))
+         {
+            user.setCreatedDate(dateFormat.parse(attrs.get(USER_CREATED_DATE).getValue().toString()));
+         }
+         if (attrs.containsKey(USER_EMAIL))
+         {
+            user.setEmail(attrs.get(USER_EMAIL).getValue().toString());
+         }
+         if (attrs.containsKey(USER_FIRST_NAME))
+         {
+            user.setFirstName(attrs.get(USER_FIRST_NAME).getValue().toString());
+         }
+         if (attrs.containsKey(USER_LAST_LOGIN_TIME))
+         {
+            user.setLastLoginTime(dateFormat.parse(attrs.get(USER_LAST_LOGIN_TIME).getValue().toString()));
+         }
+         if (attrs.containsKey(USER_LAST_NAME))
+         {
+            user.setLastName(attrs.get(USER_LAST_NAME).getValue().toString());
+         }
+         if (attrs.containsKey(USER_ORGANIZATION_ID))
+         {
+            user.setOrganizationId(attrs.get(USER_ORGANIZATION_ID).getValue().toString());
+         }
+         if (attrs.containsKey(USER_PASSWORD))
+         {
+            user.setPassword(attrs.get(USER_PASSWORD).getValue().toString());
+         }
+      }
+
+      return user;
+
+   }
+
+}

Deleted: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java	2009-11-20 16:25:22 UTC (rev 743)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -1,286 +0,0 @@
-/**
- * Copyright (C) 2009 eXo Platform SAS.
- * 
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- * 
- * This software 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
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.exoplatform.services.organization.jbidm;
-
-import org.exoplatform.services.cache.CacheService;
-import org.exoplatform.services.cache.ExoCache;
-import org.exoplatform.services.organization.UserProfile;
-import org.exoplatform.services.organization.UserProfileEventListener;
-import org.exoplatform.services.organization.UserProfileHandler;
-import org.exoplatform.services.organization.impl.UserProfileImpl;
-import org.jboss.identity.idm.api.Attribute;
-import org.jboss.identity.idm.api.IdentitySession;
-import org.jboss.identity.idm.impl.api.SimpleAttribute;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class UserProfileDAOImpl implements UserProfileHandler
-{
-
-   static private UserProfile NOT_FOUND = new UserProfileImpl();
-
-   private JBossIDMService service_;
-
-   private ExoCache cache_;
-
-   private List<UserProfileEventListener> listeners_;
-
-   private JBossIDMOrganizationServiceImpl orgService;
-
-   public UserProfileDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service, CacheService cservice)
-      throws Exception
-   {
-      service_ = service;
-      cache_ = cservice.getCacheInstance(getClass().getName());
-      listeners_ = new ArrayList<UserProfileEventListener>(3);
-      this.orgService = orgService;
-   }
-
-   public void addUserProfileEventListener(UserProfileEventListener listener)
-   {
-      listeners_.add(listener);
-   }
-
-   final public UserProfile createUserProfileInstance()
-   {
-      return new UserProfileImpl();
-   }
-
-   public UserProfile createUserProfileInstance(String userName)
-   {
-      return new UserProfileImpl(userName);
-   }
-
-   //   void createUserProfileEntry(UserProfile up, IdentitySession session) throws Exception
-   //   {
-   //      UserProfileData upd = new UserProfileData();
-   //      upd.setUserProfile(up);
-   //      session.save(upd);
-   //      session.flush();
-   //      cache_.remove(up.getUserName());
-   //   }
-
-   public void saveUserProfile(UserProfile profile, boolean broadcast) throws Exception
-   {
-
-      if (broadcast)
-      {
-         preSave(profile, true);
-      }
-
-      setProfile(profile.getUserName(), profile);
-
-      if (broadcast)
-      {
-         postSave(profile, true);
-      }
-
-      cache_.put(profile.getUserName(), profile);
-
-   }
-
-   public UserProfile removeUserProfile(String userName, boolean broadcast) throws Exception
-   {
-      UserProfile profile = getProfile(userName);
-
-      if (profile != null)
-      {
-         try
-         {
-            if (broadcast)
-            {
-               preDelete(profile);
-            }
-
-            removeProfile(userName, profile);
-
-            if (broadcast)
-            {
-               postDelete(profile);
-            }
-            cache_.remove(userName);
-            return profile;
-         }
-         catch (Exception exp)
-         {
-            return null;
-         }
-      }
-      cache_.remove(userName);
-      return null;
-   }
-
-   public UserProfile findUserProfileByName(String userName) throws Exception
-   {
-
-      org.jboss.identity.idm.api.User foundUser = getIdentitySession().getPersistenceManager().findUser(userName);
-
-      if (foundUser == null)
-      {
-         return null;
-      }
-
-      UserProfile up = (UserProfile)cache_.get(userName);
-      if (up == null)
-      {
-         up = getProfile(userName);
-      }
-
-      //
-      if (up == null)
-      {
-         up = NOT_FOUND;
-      }
-
-      //
-      cache_.put(userName, up);
-
-      // Just to avoid to return a shared object between many threads
-      // that would not be thread safe nor corrct
-      if (up == NOT_FOUND)
-      {
-         // julien : integration bug fix
-         // Return an empty profile to avoid NPE in portal
-         // Should clarify what do do (maybe portal should care about returned value)
-         UserProfileImpl profile = new UserProfileImpl();
-         profile.setUserName(userName);
-         return profile;
-      }
-      else
-      {
-         return up;
-      }
-   }
-
-   public Collection findUserProfiles() throws Exception
-   {
-      return null;
-   }
-
-   private void preSave(UserProfile profile, boolean isNew) throws Exception
-   {
-      for (UserProfileEventListener listener : listeners_)
-      {
-         listener.preSave(profile, isNew);
-      }
-   }
-
-   private void postSave(UserProfile profile, boolean isNew) throws Exception
-   {
-      for (UserProfileEventListener listener : listeners_)
-      {
-         listener.postSave(profile, isNew);
-      }
-   }
-
-   private void preDelete(UserProfile profile) throws Exception
-   {
-      for (UserProfileEventListener listener : listeners_)
-      {
-         listener.preDelete(profile);
-      }
-   }
-
-   private void postDelete(UserProfile profile) throws Exception
-   {
-      for (UserProfileEventListener listener : listeners_)
-      {
-         listener.postDelete(profile);
-      }
-   }
-
-   public UserProfile getProfile(String userName) throws Exception
-   {
-      if (getIdentitySession().getPersistenceManager().findUser(userName) == null)
-      {
-         return null;
-      }
-
-      Map<String, Attribute> attrs = getIdentitySession().getAttributesManager().getAttributes(userName);
-
-      if (attrs == null || attrs.isEmpty())
-      {
-         return null;
-      }
-
-      Map<String, String> filteredAttrs = new HashMap<String, String>();
-
-      for (String key : attrs.keySet())
-      {
-         // Check if attribute is part of User interface data
-         if (!UserDAOImpl.USER_NON_PROFILE_KEYS.contains(key))
-         {
-            filteredAttrs.put(key, attrs.get(key).getValue().toString());
-         }
-
-      }
-
-      if (filteredAttrs.isEmpty())
-      {
-         return null;
-      }
-
-      UserProfile profile = new UserProfileImpl(userName, filteredAttrs);
-
-      return profile;
-
-   }
-
-   public void setProfile(String userName, UserProfile profile) throws Exception
-   {
-
-      Map<String, String> profileAttrs = profile.getUserInfoMap();
-
-      Set<Attribute> attrs = new HashSet<Attribute>();
-
-      for (Map.Entry<String, String> entry : profileAttrs.entrySet())
-      {
-         attrs.add(new SimpleAttribute(entry.getKey(), entry.getValue()));
-      }
-
-      Attribute[] attrArray = new Attribute[attrs.size()];
-      attrArray = attrs.toArray(attrArray);
-
-      getIdentitySession().getAttributesManager().updateAttributes(userName, attrArray);
-
-   }
-
-   public void removeProfile(String userName, UserProfile profile) throws Exception
-   {
-      Map<String, String> profileAttrs = profile.getUserInfoMap();
-
-      String[] attrKeys = new String[profileAttrs.keySet().size()];
-
-      attrKeys = profileAttrs.keySet().toArray(attrKeys);
-
-      getIdentitySession().getAttributesManager().removeAttributes(userName, attrKeys);
-   }
-
-   private IdentitySession getIdentitySession() throws Exception
-   {
-      return service_.getIdentitySession();
-   }
-}

Copied: portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java (from rev 743, portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java)
===================================================================
--- portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java	                        (rev 0)
+++ portal/trunk/component/identity/src/main/java/org/exoplatform/services/organization/jbidm/UserProfileDAOImpl.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -0,0 +1,286 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ * 
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * This software 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
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.exoplatform.services.organization.jbidm;
+
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.cache.ExoCache;
+import org.exoplatform.services.organization.UserProfile;
+import org.exoplatform.services.organization.UserProfileEventListener;
+import org.exoplatform.services.organization.UserProfileHandler;
+import org.exoplatform.services.organization.impl.UserProfileImpl;
+import org.jboss.identity.idm.api.Attribute;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.impl.api.SimpleAttribute;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class UserProfileDAOImpl implements UserProfileHandler
+{
+
+   static private UserProfile NOT_FOUND = new UserProfileImpl();
+
+   private JBossIDMService service_;
+
+   private ExoCache cache_;
+
+   private List<UserProfileEventListener> listeners_;
+
+   private JBossIDMOrganizationServiceImpl orgService;
+
+   public UserProfileDAOImpl(JBossIDMOrganizationServiceImpl orgService, JBossIDMService service, CacheService cservice)
+      throws Exception
+   {
+      service_ = service;
+      cache_ = cservice.getCacheInstance(getClass().getName());
+      listeners_ = new ArrayList<UserProfileEventListener>(3);
+      this.orgService = orgService;
+   }
+
+   public void addUserProfileEventListener(UserProfileEventListener listener)
+   {
+      listeners_.add(listener);
+   }
+
+   final public UserProfile createUserProfileInstance()
+   {
+      return new UserProfileImpl();
+   }
+
+   public UserProfile createUserProfileInstance(String userName)
+   {
+      return new UserProfileImpl(userName);
+   }
+
+   //   void createUserProfileEntry(UserProfile up, IdentitySession session) throws Exception
+   //   {
+   //      UserProfileData upd = new UserProfileData();
+   //      upd.setUserProfile(up);
+   //      session.save(upd);
+   //      session.flush();
+   //      cache_.remove(up.getUserName());
+   //   }
+
+   public void saveUserProfile(UserProfile profile, boolean broadcast) throws Exception
+   {
+
+      if (broadcast)
+      {
+         preSave(profile, true);
+      }
+
+      setProfile(profile.getUserName(), profile);
+
+      if (broadcast)
+      {
+         postSave(profile, true);
+      }
+
+      cache_.put(profile.getUserName(), profile);
+
+   }
+
+   public UserProfile removeUserProfile(String userName, boolean broadcast) throws Exception
+   {
+      UserProfile profile = getProfile(userName);
+
+      if (profile != null)
+      {
+         try
+         {
+            if (broadcast)
+            {
+               preDelete(profile);
+            }
+
+            removeProfile(userName, profile);
+
+            if (broadcast)
+            {
+               postDelete(profile);
+            }
+            cache_.remove(userName);
+            return profile;
+         }
+         catch (Exception exp)
+         {
+            return null;
+         }
+      }
+      cache_.remove(userName);
+      return null;
+   }
+
+   public UserProfile findUserProfileByName(String userName) throws Exception
+   {
+
+      org.jboss.identity.idm.api.User foundUser = getIdentitySession().getPersistenceManager().findUser(userName);
+
+      if (foundUser == null)
+      {
+         return null;
+      }
+
+      UserProfile up = (UserProfile)cache_.get(userName);
+      if (up == null)
+      {
+         up = getProfile(userName);
+      }
+
+      //
+      if (up == null)
+      {
+         up = NOT_FOUND;
+      }
+
+      //
+      cache_.put(userName, up);
+
+      // Just to avoid to return a shared object between many threads
+      // that would not be thread safe nor corrct
+      if (up == NOT_FOUND)
+      {
+         // julien : integration bug fix
+         // Return an empty profile to avoid NPE in portal
+         // Should clarify what do do (maybe portal should care about returned value)
+         UserProfileImpl profile = new UserProfileImpl();
+         profile.setUserName(userName);
+         return profile;
+      }
+      else
+      {
+         return up;
+      }
+   }
+
+   public Collection findUserProfiles() throws Exception
+   {
+      return null;
+   }
+
+   private void preSave(UserProfile profile, boolean isNew) throws Exception
+   {
+      for (UserProfileEventListener listener : listeners_)
+      {
+         listener.preSave(profile, isNew);
+      }
+   }
+
+   private void postSave(UserProfile profile, boolean isNew) throws Exception
+   {
+      for (UserProfileEventListener listener : listeners_)
+      {
+         listener.postSave(profile, isNew);
+      }
+   }
+
+   private void preDelete(UserProfile profile) throws Exception
+   {
+      for (UserProfileEventListener listener : listeners_)
+      {
+         listener.preDelete(profile);
+      }
+   }
+
+   private void postDelete(UserProfile profile) throws Exception
+   {
+      for (UserProfileEventListener listener : listeners_)
+      {
+         listener.postDelete(profile);
+      }
+   }
+
+   public UserProfile getProfile(String userName) throws Exception
+   {
+      if (getIdentitySession().getPersistenceManager().findUser(userName) == null)
+      {
+         return null;
+      }
+
+      Map<String, Attribute> attrs = getIdentitySession().getAttributesManager().getAttributes(userName);
+
+      if (attrs == null || attrs.isEmpty())
+      {
+         return null;
+      }
+
+      Map<String, String> filteredAttrs = new HashMap<String, String>();
+
+      for (String key : attrs.keySet())
+      {
+         // Check if attribute is part of User interface data
+         if (!UserDAOImpl.USER_NON_PROFILE_KEYS.contains(key))
+         {
+            filteredAttrs.put(key, attrs.get(key).getValue().toString());
+         }
+
+      }
+
+      if (filteredAttrs.isEmpty())
+      {
+         return null;
+      }
+
+      UserProfile profile = new UserProfileImpl(userName, filteredAttrs);
+
+      return profile;
+
+   }
+
+   public void setProfile(String userName, UserProfile profile) throws Exception
+   {
+
+      Map<String, String> profileAttrs = profile.getUserInfoMap();
+
+      Set<Attribute> attrs = new HashSet<Attribute>();
+
+      for (Map.Entry<String, String> entry : profileAttrs.entrySet())
+      {
+         attrs.add(new SimpleAttribute(entry.getKey(), entry.getValue()));
+      }
+
+      Attribute[] attrArray = new Attribute[attrs.size()];
+      attrArray = attrs.toArray(attrArray);
+
+      getIdentitySession().getAttributesManager().updateAttributes(userName, attrArray);
+
+   }
+
+   public void removeProfile(String userName, UserProfile profile) throws Exception
+   {
+      Map<String, String> profileAttrs = profile.getUserInfoMap();
+
+      String[] attrKeys = new String[profileAttrs.keySet().size()];
+
+      attrKeys = profileAttrs.keySet().toArray(attrKeys);
+
+      getIdentitySession().getAttributesManager().removeAttributes(userName, attrKeys);
+   }
+
+   private IdentitySession getIdentitySession() throws Exception
+   {
+      return service_.getIdentitySession();
+   }
+}

Modified: portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml
===================================================================
--- portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/identity/src/test/java/conf/portal/idm-configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -25,54 +25,54 @@
                xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 
    <component>
-      <key>org.exoplatform.services.organization.idm.PicketLinkIDMService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMServiceImpl</type>
+      <key>org.exoplatform.services.organization.jbidm.JBossIDMService</key>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMServiceImpl</type>
       <init-params>
          <value-param>
             <name>config</name>
             <value>jar:/conf/portal/idm-config.xml</value>
          </value-param>
+         <values-param>
+            <name>hibernate.annotations</name>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
+         </values-param>
+         <properties-param>
+            <name>hibernate.properties</name>
+            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+            <property name="hibernate.current_session_context_class" value="thread"/>
+            <property name="hibernate.show_sql" value="false"/>
+            <property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
+            <property name="hibernate.connection.url" value="jdbc:hsqldb:file:target/temp/data/exodb"/>
+            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+            <property name="hibernate.connection.autocommit" value="true"/>
+            <property name="hibernate.connection.username" value="sa"/>
+            <property name="hibernate.connection.password" value=""/>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+            <property name="hibernate.c3p0.min_size" value="5"/>
+            <property name="hibernate.c3p0.max_size" value="20"/>
+            <property name="hibernate.c3p0.timeout" value="1800"/>
+            <property name="hibernate.c3p0.max_statements" value="50"/>
+         </properties-param>
+         
       </init-params>
    </component>
 
    <component>
       <key>org.exoplatform.services.organization.OrganizationService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</type>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</type>
    </component>
 
-   <component>
-    <key>org.exoplatform.services.database.HibernateService</key>
-    <jmx-name>database:type=HibernateService</jmx-name>
-    <type>org.exoplatform.services.database.impl.HibernateServiceImpl</type>
-    <init-params>
-      <properties-param>
-        <name>hibernate.properties</name>
-        <description>Default Hibernate Service</description>
-        <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
-        <!--<property name="hibernate.show_sql" value="true"/>-->
-        <!--<property name="hibernate.use_sql_comments" value="true"/>-->
-        <!--<property name="hibernate.format_sql" value="true"/>-->
-        <property name="hibernate.current_session_context_class" value="thread"/>
-        <property name="hibernate.jdbc.batch_size" value="100"/>
-        <property name="hibernate.cache.use_second_level_cache" value="true"/>
-        <property name="hibernate.cache.use_query_cache" value="true"/>
-        <!--CHANGEME HashtableCacheProvider shold not be used in production env-->
-        <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
-        <property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
-        <property name="hibernate.connection.url" value="jdbc:hsqldb:file:../temp/data/exodb${container.name.suffix}"/>
-        <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
-        <property name="hibernate.connection.autocommit" value="true"/>
-        <property name="hibernate.connection.username" value="sa"/>
-        <property name="hibernate.connection.password" value=""/>
-        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
-        <property name="hibernate.c3p0.min_size" value="5"/>
-        <property name="hibernate.c3p0.max_size" value="20"/>
-        <property name="hibernate.c3p0.timeout" value="1800"/>
-        <property name="hibernate.c3p0.max_statements" value="50"/>
-      </properties-param>
-    </init-params>
-  </component>
-
    <external-component-plugins>
       <target-component>org.exoplatform.services.database.HibernateService</target-component>
       <component-plugin>
@@ -81,18 +81,19 @@
          <type>org.exoplatform.services.database.impl.AddHibernateMappingPlugin</type>
          <init-params>
             <values-param>
-               <name>hibernate.mapping</name>
-               <value>mappings/HibernateRealm.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttributeBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObject.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredential.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttribute.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationship.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipName.hbm.xml</value>
+               <name>hibernate.annotations</name>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
             </values-param>
          </init-params>
       </component-plugin>

Modified: portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestOrganizationService.java
===================================================================
--- portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestOrganizationService.java	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/identity/src/test/java/org/exoplatform/services/organization/TestOrganizationService.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -173,7 +173,6 @@
       // newly created 'test' and 'demo'
       assertEquals(2, piterator.currentPage().size());
 
-//      membershipHandler_.removeMembershipByUser(USER,false);
       userHandler_.removeUser(USER, true);
       piterator = userHandler_.getUserPageList(10);
       // one 'demo'
@@ -437,20 +436,19 @@
       groupHandler_.removeGroup(group3, true);
    }
 
-//   public void testUserProfileListener() throws Exception
-//   {
-//      UserProfileListener l = new UserProfileListener();
-//      profileHandler_.addUserProfileEventListener(l);
-//      User user = createUser(USER);
-//      assertNotNull(user);
-//      UserProfile profile = profileHandler_.createUserProfileInstance(user.getUserName());
-//      profile.setAttribute("blah", "blah");
-//      profileHandler_.saveUserProfile(profile, true);
-//      assertTrue(l.preSave && l.postSave);
-//      profileHandler_.removeUserProfile(user.getUserName(), true);
-//      assertFalse(l.preDelete && l.postDelete);
-//      userHandler_.removeUser(user.getUserName(), false);
-//   }
+   public void testUserProfileListener() throws Exception
+   {
+      UserProfileListener l = new UserProfileListener();
+      profileHandler_.addUserProfileEventListener(l);
+      User user = createUser(USER);
+      assertNotNull(user);
+      UserProfile profile = profileHandler_.createUserProfileInstance(user.getUserName());
+      profile.setAttribute("blah", "blah");
+      profileHandler_.saveUserProfile(profile, true);
+      assertTrue(l.preSave && l.postSave);
+      profileHandler_.removeUserProfile(user.getUserName(), true);
+      assertFalse(l.preDelete && l.postDelete);
+   }
 
    public void testFindUsersByGroupId() throws Exception
    {

Modified: portal/trunk/component/portal/pom.xml
===================================================================
--- portal/trunk/component/portal/pom.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/portal/pom.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -82,9 +82,9 @@
     </dependency>
 
     <dependency>
-       <groupId>org.picketlink.idm</groupId>
-       <artifactId>picketlink-idm-core</artifactId>
-       <version>${org.picketlink.idm}</version>
+       <groupId>org.jboss.identity.idm</groupId>
+       <artifactId>idm-core</artifactId>
+       <version>${org.jboss.identity.idm}</version>
     </dependency>
 
   </dependencies>

Modified: portal/trunk/component/portal/src/test/java/conf/portal/database-configuration.xml
===================================================================
--- portal/trunk/component/portal/src/test/java/conf/portal/database-configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/portal/src/test/java/conf/portal/database-configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -34,9 +34,6 @@
         <description>Default Hibernate Service</description>
         <property name="hibernate.show_sql" value="false"/>
         <property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
-        <property name="hibernate.cache.use_second_level_cache" value="true"/>
-        <property name="hibernate.cache.use_query_cache" value="true"/>
-        <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
         <property name="hibernate.connection.url" value="jdbc:hsqldb:file:target/temp/data/exodb"/>
         <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
         <property name="hibernate.connection.autocommit" value="true"/>

Modified: portal/trunk/component/portal/src/test/java/conf/portal/idm-configuration.xml
===================================================================
--- portal/trunk/component/portal/src/test/java/conf/portal/idm-configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/portal/src/test/java/conf/portal/idm-configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -25,21 +25,52 @@
                xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 
    <component>
-      <key>org.exoplatform.services.organization.idm.PicketLinkIDMService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMServiceImpl</type>
+      <key>org.exoplatform.services.organization.jbidm.JBossIDMService</key>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMServiceImpl</type>
       <init-params>
          <value-param>
             <name>config</name>
             <value>war:/conf/organization/idm-config.xml</value>
          </value-param>
-
+         <values-param>
+            <name>hibernate.annotations</name>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
+         </values-param>
+         <properties-param>
+            <name>hibernate.properties</name>
+            <property name="hibernate.hbm2ddl.auto" value="update"/>
+            <property name="hibernate.current_session_context_class" value="thread"/>
+            <property name="hibernate.show_sql" value="false"/>
+            <property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
+            <property name="hibernate.connection.url" value="jdbc:hsqldb:file:target/temp/data/exodb"/>
+            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+            <property name="hibernate.connection.autocommit" value="true"/>
+            <property name="hibernate.connection.username" value="sa"/>
+            <property name="hibernate.connection.password" value=""/>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+            <property name="hibernate.c3p0.min_size" value="5"/>
+            <property name="hibernate.c3p0.max_size" value="20"/>
+            <property name="hibernate.c3p0.timeout" value="1800"/>
+            <property name="hibernate.c3p0.max_statements" value="50"/>
+         </properties-param>
          
       </init-params>
    </component>
 
    <component>
       <key>org.exoplatform.services.organization.OrganizationService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</type>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</type>
    </component>
 
    <external-component-plugins>
@@ -50,18 +81,19 @@
          <type>org.exoplatform.services.database.impl.AddHibernateMappingPlugin</type>
          <init-params>
             <values-param>
-               <name>hibernate.mapping</name>
-               <value>mappings/HibernateRealm.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttributeBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObject.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredential.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttribute.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationship.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipName.hbm.xml</value>
+               <name>hibernate.annotations</name>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+               <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
             </values-param>
          </init-params>
       </component-plugin>

Modified: portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java
===================================================================
--- portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/component/portal/src/test/java/org/exoplatform/portal/config/TestUserPortalConfigService.java	2009-11-24 00:35:57 UTC (rev 775)
@@ -43,12 +43,12 @@
 import org.exoplatform.services.organization.OrganizationService;
 import org.exoplatform.services.organization.User;
 import org.exoplatform.services.organization.UserHandler;
-import org.exoplatform.services.organization.idm.PicketLinkIDMService;
+import org.exoplatform.services.organization.jbidm.JBossIDMService;
 import org.exoplatform.services.security.Authenticator;
 import org.exoplatform.services.security.ConversationState;
 import org.exoplatform.test.BasicTestCase;
-import org.picketlink.idm.api.IdentitySession;
-import org.picketlink.idm.common.exception.IdentityException;
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.common.exception.IdentityException;
 
 import java.util.Arrays;
 import java.util.Collections;
@@ -76,7 +76,7 @@
    private DataStorage storage_;
 
    /** . */
-   private PicketLinkIDMService idmService;
+   private JBossIDMService idmService;
 
    /** . */
    private POMSessionManager mgr;
@@ -122,7 +122,7 @@
       userPortalConfigSer_ =
          (UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
       orgService_ = (OrganizationService)container.getComponentInstanceOfType(OrganizationService.class);
-      idmService = (PicketLinkIDMService)container.getComponentInstanceOfType(PicketLinkIDMService.class);
+      idmService = (JBossIDMService)container.getComponentInstanceOfType(JBossIDMService.class);
       mgr = (POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
       authenticator = (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
       listenerService = (ListenerService)container.getComponentInstanceOfType(ListenerService.class);

Modified: portal/trunk/docs/user-guide/en/modules/configuration/IDM_Configuration.xml
===================================================================
--- portal/trunk/docs/user-guide/en/modules/configuration/IDM_Configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/docs/user-guide/en/modules/configuration/IDM_Configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -17,15 +17,15 @@
    <section>
       <title>Configuration files</title>
       <para>Main configuration file is <emphasis role="bold">idm-configuration</emphasis>:</para>
-      <programlisting><![CDATA[<![CDATA[<![CDATA[
+      <programlisting>
          <![CDATA[
 <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
                xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 
    <component>
-      <key>org.exoplatform.services.orgaidmion.jbidm.PicketLinkIDMService</key>
-      <type>org.exoplatform.servicidmganization.jbidm.PicketLinkIDMServiceImpl</type>
+      <key>org.exoplatform.services.organization.jbidm.JBossIDMService</key>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMServiceImpl</type>
       <init-params>
          <value-param>
             <name>config</name>
@@ -33,18 +33,18 @@
          </value-param>
          <values-param>
             <name>hibernate.annotations</name>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObject</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
-            <value>org.picketlink.idm.impl.model.hibernate.HibernateRealm</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
          </values-param>
          <properties-param>
             <name>hibernate.properties</name>
@@ -70,18 +70,18 @@
 
    <component>
       <key>org.exoplatform.services.organization.OrganizationService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</type>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</type>
    </component>
 
-</configuration>
+</configuration>                 
          ]]>
-      ]]>]]>]]></programlisting>
-      <para><emphasis role="bold">org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</emphasis>
+      </programlisting>
+      <para><emphasis role="bold">org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</emphasis>
          is a main entrypoint implementing
       <emphasis role="bold">org.exoplatform.services.organization.OrganizationService</emphasis> and is dependant on
-       <emphasis role="bold">org.exoplatform.services.organization.idm.PicketLinkIDMService</emphasis></para>
+       <emphasis role="bold">org.exoplatform.services.organization.jbidm.JBossIDMService</emphasis></para>
 
-      <para><emphasis role="bold">org.exoplatform.services.organization.idm.PicketLinkIDMServiceImpl</emphasis> service has following
+      <para><emphasis role="bold">org.exoplatform.services.organization.jbidm.JBossIDMServiceImpl</emphasis> service has following
       options:</para>
       <itemizedlist>
          <listitem>
@@ -121,25 +121,25 @@
          </listitem>
       </itemizedlist>
 
-       <para><emphasis role="bold">org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</emphasis> service has following
+       <para><emphasis role="bold">org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</emphasis> service has following
       options:</para>
       <itemizedlist>
          <listitem>
             <para>
-               <emphasis role="bold">gtnGroupTypeName</emphasis> - (value-param) - Name of JBoss Identity IDM GroupType
-               that will be used to store groups. Default is 'GTN_GROUP_TYPE'
+               <emphasis role="bold">exoGroupTypeName</emphasis> - (value-param) - Name of JBoss Identity IDM GroupType
+               that will be used to store groups. Default is 'EXO_GROUP_TYPE'
             </para>
          </listitem>
          <listitem>
             <para>
-               <emphasis role="bold">gtnRootGroupName</emphasis> - (value-param) - Name of JBoss Identity IDM Group that will
-               be used as a root parent. Default is 'GTN_ROOT_GROUP'
+               <emphasis role="bold">exoRootGroupName</emphasis> - (value-param) - Name of JBoss Identity IDM Group that will
+               be used as a root parent. Default is 'EXO_ROOT_GROUP'
             </para>
          </listitem>
          <listitem>
             <para>
-               <emphasis role="bold">gtnRootGroupTypeName</emphasis> - (value-param) - Name of JBoss Identity IDM GroupType
-               of a Group used as a parent root. Default is 'GTN_GROUP_TYPE'
+               <emphasis role="bold">exoRootGroupTypeName</emphasis> - (value-param) - Name of JBoss Identity IDM GroupType
+               of a Group used as a parent root. Default is 'EXO_GROUP_TYPE'
             </para>
          </listitem>
          <listitem>
@@ -187,7 +187,7 @@
     <repositories>
         <repository>
             <id>PortalRepository</id>
-            <class>org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository</class>
+            <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
             <external-config/>
             <default-identity-store-id>HibernateStore</default-identity-store-id>
             <default-attribute-store-id>HibernateStore</default-attribute-store-id>
@@ -198,7 +198,7 @@
         <identity-stores>
             <identity-store>
                 <id>HibernateStore</id>
-                <class>org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+                <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
                 <external-config/>
                 <supported-relationship-types>
                     <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>

Modified: portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js
===================================================================
--- portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/packaging/module/src/main/javascript/portal.packaging.module.js	2009-11-24 00:35:57 UTC (rev 775)
@@ -37,7 +37,7 @@
    var mopVersion =  "${org.gatein.mop.version}";
    var chromatticVersion =  "${version.chromattic}";
    var reflectVersion =  "${version.reflect}";
-   var idmVersion = "${org.picketlink.idm}";
+   var idmVersion = "${org.jboss.identity.idm}";
    var pcVersion = "${org.gatein.pc.version}";
    var wciVersion = "${org.gatein.wci.version}";
    var commonVersion = "${org.gatein.common.version}";
@@ -115,12 +115,12 @@
 
    module.component.identity =
    new Project("org.exoplatform.portal", "exo.portal.component.identity", "jar", module.version).
-      addDependency(new Project("org.picketlink.idm", "picketlink-idm-core", "jar", idmVersion)).
-      addDependency(new Project("org.picketlink.idm", "picketlink-idm-common", "jar", idmVersion)).
-      addDependency(new Project("org.picketlink.idm", "picketlink-idm-api", "jar", idmVersion)).
-      addDependency(new Project("org.picketlink.idm", "picketlink-idm-spi", "jar", idmVersion)).
-      addDependency(new Project("org.picketlink.idm", "picketlink-idm-hibernate", "jar", idmVersion)).
-      addDependency(new Project("org.picketlink.idm", "picketlink-idm-ldap", "jar", idmVersion));
+      addDependency(new Project("org.jboss.identity.idm", "idm-core", "jar", idmVersion)).
+      addDependency(new Project("org.jboss.identity.idm", "idm-common", "jar", idmVersion)).
+      addDependency(new Project("org.jboss.identity.idm", "idm-api", "jar", idmVersion)).
+      addDependency(new Project("org.jboss.identity.idm", "idm-spi", "jar", idmVersion)).
+      addDependency(new Project("org.jboss.identity.idm", "idm-hibernate", "jar", idmVersion)).
+      addDependency(new Project("org.jboss.identity.idm", "idm-ldap", "jar", idmVersion));
 
    module.component.applicationRegistry =
    new Project("org.exoplatform.portal", "exo.portal.component.application-registry", "jar", module.version).

Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/pom.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -46,7 +46,7 @@
       <org.gatein.common.version>2.0.0-Beta03</org.gatein.common.version>
       <org.gatein.wci.version>2.0.0-Beta02</org.gatein.wci.version>
       <org.gatein.pc.version>2.1.0-Beta02</org.gatein.pc.version>
-      <org.picketlink.idm>1.0.0.CR1</org.picketlink.idm>
+      <org.jboss.identity.idm>1.0.0.Beta3</org.jboss.identity.idm>
       <org.gatein.wsrp.version>1.0.0-Beta01</org.gatein.wsrp.version>
       <org.gatein.mop.version>1.0.0-Beta09</org.gatein.mop.version>
       <version.chromattic>1.0.0-beta6</version.chromattic>

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/database/database-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/database/database-configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/database/database-configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -33,11 +33,6 @@
         <name>hibernate.properties</name>
         <description>Default Hibernate Service</description>
         <property name="hibernate.show_sql" value="false"/>
-        <property name="hibernate.current_session_context_class" value="thread"/>
-        <property name="hibernate.cache.use_second_level_cache" value="true"/>
-        <property name="hibernate.cache.use_query_cache" value="true"/>
-        <!--CHANGEME HashtableCacheProvider shold not be used in production env-->
-        <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
         <property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
         <property name="hibernate.connection.url" value="jdbc:hsqldb:file:../temp/data/exodb${container.name.suffix}"/>
         <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-config.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-config.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-config.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -20,9 +20,9 @@
 
 -->
 
-<jboss-identity xmlns="urn:picketlink:idm:config:v1_0_0_cr1"
+<jboss-identity xmlns="urn:jboss:identity:idm:config:v1_0_beta"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                xsi:schemaLocation="urn:picketlink:idm:config:v1_0_0_cr1 identity-config.xsd">
+                xsi:schemaLocation="urn:jboss:identity:idm:config:v1_0_alpha identity-config.xsd">
     <realms>
         <realm>
             <id>PortalRealm</id>
@@ -35,7 +35,7 @@
     <repositories>
         <repository>
             <id>PortalRepository</id>
-            <class>org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository</class>
+            <class>org.jboss.identity.idm.impl.repository.WrapperIdentityStoreRepository</class>
             <external-config/>
             <default-identity-store-id>HibernateStore</default-identity-store-id>
             <default-attribute-store-id>HibernateStore</default-attribute-store-id>
@@ -46,7 +46,7 @@
         <identity-stores>
             <identity-store>
                 <id>HibernateStore</id>
-                <class>org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
+                <class>org.jboss.identity.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
                 <external-config/>
                 <supported-relationship-types>
                     <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>

Modified: portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml
===================================================================
--- portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml	2009-11-23 20:13:58 UTC (rev 774)
+++ portal/trunk/web/portal/src/main/webapp/WEB-INF/conf/organization/idm-configuration.xml	2009-11-24 00:35:57 UTC (rev 775)
@@ -23,50 +23,54 @@
 <configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
                xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
-   
 
-
    <component>
-      <key>org.exoplatform.services.organization.idm.PicketLinkIDMService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMServiceImpl</type>
+      <key>org.exoplatform.services.organization.jbidm.JBossIDMService</key>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMServiceImpl</type>
       <init-params>
          <value-param>
             <name>config</name>
             <value>war:/conf/organization/idm-config.xml</value>
          </value-param>
+         <values-param>
+            <name>hibernate.annotations</name>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectBinaryAttributeValue</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipName</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectTextAttribute</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType</value>
+            <value>org.jboss.identity.idm.impl.model.hibernate.HibernateRealm</value>
+         </values-param>
+         <properties-param>
+            <name>hibernate.properties</name>
+            <property name="hibernate.hbm2ddl.auto" value="update"/>
+            <property name="hibernate.current_session_context_class" value="thread"/>
+            <property name="hibernate.show_sql" value="false"/>
+            <property name="hibernate.cglib.use_reflection_optimizer" value="true"/>
+            <property name="hibernate.connection.url" value="jdbc:hsqldb:file:../temp/data/exodb${container.name.suffix}"/>
+            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+            <property name="hibernate.connection.autocommit" value="true"/>
+            <property name="hibernate.connection.username" value="sa"/>
+            <property name="hibernate.connection.password" value=""/>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+            <property name="hibernate.c3p0.min_size" value="5"/>
+            <property name="hibernate.c3p0.max_size" value="20"/>
+            <property name="hibernate.c3p0.timeout" value="1800"/>
+            <property name="hibernate.c3p0.max_statements" value="50"/>
+         </properties-param>
+         
       </init-params>
    </component>
 
-
    <component>
       <key>org.exoplatform.services.organization.OrganizationService</key>
-      <type>org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl</type>
+      <type>org.exoplatform.services.organization.jbidm.JBossIDMOrganizationServiceImpl</type>
    </component>
 
-    <external-component-plugins>
-      <target-component>org.exoplatform.services.database.HibernateService</target-component>
-      <component-plugin>
-         <name>add.hibernate.mapping</name>
-         <set-method>addPlugin</set-method>
-         <type>org.exoplatform.services.database.impl.AddHibernateMappingPlugin</type>
-         <init-params>
-            <values-param>
-               <name>hibernate.mapping</name>
-               <value>mappings/HibernateRealm.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttributeBinaryValue.hbm.xml</value>
-               <value>mappings/HibernateIdentityObject.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredential.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectCredentialType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectAttribute.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationship.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipType.hbm.xml</value>
-               <value>mappings/HibernateIdentityObjectRelationshipName.hbm.xml</value>
-            </values-param>
-         </init-params>
-      </component-plugin>
-   </external-component-plugins>
-
-
 </configuration>



More information about the gatein-commits mailing list