[portal-commits] JBoss Portal SVN: r5829 - in trunk/identity/src/main/org/jboss/portal/identity2: . experimental experimental/db

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Dec 13 10:13:49 EST 2006


Author: bdaw
Date: 2006-12-13 10:13:33 -0500 (Wed, 13 Dec 2006)
New Revision: 5829

Added:
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateHelper.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/IdentitySessionFactoryBinder.java
Removed:
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/DBRoleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/DBUserImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java
   trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/ProfileMapImpl.java
Log:
abandoned dynamic-map implementation of portal hibernate entities because of: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2299

Copied: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db (from rev 5770, trunk/identity/src/main/org/jboss/portal/identity2/db)

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/DBRoleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/DBRoleImpl.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/DBRoleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -1,146 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.Role;
-
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @version $Revision: 5448 $
- */
-public class DBRoleImpl
-   implements Role
-{
-
-   private Long key;
-   private String name;
-   private Set users;
-   private String displayName;
-
-   /**
-    *
-    */
-   public DBRoleImpl()
-   {
-      this.key = null;
-      this.name = null;
-      this.displayName = null;
-      this.users = new HashSet();
-   }
-
-   /**
-    *
-    */
-   public DBRoleImpl(String name)
-   {
-      this.key = null;
-      this.name = name;
-      this.displayName = name;
-      this.users = new HashSet();
-   }
-
-   /**
-    *
-    */
-   public DBRoleImpl(String name, String displayName)
-   {
-      this.key = null;
-      this.name = name;
-      this.displayName = displayName;
-      this.users = new HashSet();
-   }
-
-   /**
-    * Called by hibernate.
-    */
-   protected Long getKey()
-   {
-      return key;
-   }
-
-   /** Called by hibernate. */
-   protected void setKey(Long key)
-   {
-      this.key = key;
-   }
-
-   /** Called by hibernate. */
-   protected void setName(String name)
-   {
-      this.name = name;
-   }
-
-   /** Called by hibernate. */
-   protected void setUsers(Set users)
-   {
-      this.users = users;
-   }
-
-   // ******************************************************************************************************************
-
-   public Object getId()
-   {
-      return key;
-   }
-
-   /**
-    *
-    */
-   public String getName()
-   {
-      return name;
-   }
-
-   /**
-    *
-    */
-   public String getDisplayName()
-   {
-      return displayName;
-   }
-
-   /**
-    *
-    */
-   public void setDisplayName(String displayName)
-   {
-      this.displayName = displayName;
-   }
-
-   /**
-    *
-    */
-   public Set getUsers()
-   {
-      return users;
-   }
-
-   public String toString()
-   {
-      return "Role[" + key + "," + name + "]";
-   }
-}

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/DBUserImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/DBUserImpl.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/DBUserImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -1,660 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.ProfileMap;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity2.db.ProfileMapImpl;
-import org.jboss.portal.common.p3p.P3PConstants;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.common.util.LocaleInfo;
-
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.util.Set;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Iterator;
-import java.lang.reflect.Field;
-import java.text.SimpleDateFormat;
-import java.text.DateFormat;
-import java.text.ParseException;
-
-/**
- * User interface implementation.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author <a href="mailto:mageshbk at jboss.com">Magesh Kumar Bojan </a>
- * @version $Revision: 5448 $
- */
-public class DBUserImpl
-   implements User
-{
-
-   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(DBUserImpl.class);
-
-   static final Map ACCESSORS = buildAccessors();
-
-   private static Map buildAccessors()
-   {
-      Map map = new HashMap();
-
-      // Map attributes defined by the JSR 168 spec P3P.
-      map.put(P3PConstants.INFO_USER_NAME_NICKNAME, new DBUserImpl.StringPropertyAccessor(P3PConstants.INFO_USER_NAME_NICKNAME, "userName", false, false));
-      map.put(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, new DBUserImpl.StringPropertyAccessor(P3PConstants.INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, "realEmail", true, true));
-      map.put(P3PConstants.INFO_USER_NAME_GIVEN, new DBUserImpl.StringPropertyAccessor(P3PConstants.INFO_USER_NAME_GIVEN, "givenName", true, true));
-      map.put(P3PConstants.INFO_USER_NAME_FAMILY, new DBUserImpl.StringPropertyAccessor(P3PConstants.INFO_USER_NAME_FAMILY, "familyName", true, true));
-
-      // Map attributes specific to JBoss Portal
-      map.put(User.INFO_USER_EMAIL_FAKE, new DBUserImpl.StringPropertyAccessor(User.INFO_USER_EMAIL_FAKE, "fakeEmail", true, true));
-      map.put(User.INFO_USER_REGISTRATION_DATE, new DBUserImpl.DatePropertyAccessor(User.INFO_USER_REGISTRATION_DATE, "registrationDate", false, false));
-      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, new DBUserImpl.BooleanPropertyAccessor(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "viewRealEmail", true, false));
-
-      //
-      return Collections.unmodifiableMap(map);
-   }
-
-   /*
-    * Transient fields.
-    */
-
-   protected ProfileMap profile;
-   protected Set roleNames;
-
-   /*
-    * P3P mapped persistent fields.
-    */
-
-   protected String userName;
-   protected String givenName;
-   protected String familyName;
-   protected String realEmail;
-
-   /*
-    * Non mapped persistent fields.
-    */
-
-   protected Long key;
-   protected boolean enabled;
-   protected String password;
-
-   /*
-    * Extension mapped persistent fields.
-    */
-
-   protected String fakeEmail;
-   protected boolean viewRealEmail;
-   protected Date registrationDate;
-
-   /*
-    * Persistent associations
-    */
-
-   protected Map dynamic;
-   protected Set roles;
-
-   /**
-    *
-    */
-   public DBUserImpl()
-   {
-      this.key = null;
-      this.userName = null;
-      this.dynamic = null;
-      this.profile = new ProfileMapImpl(this);
-      this.roles = null;
-      this.registrationDate = null;
-      this.enabled = false;
-   }
-
-   /**
-    *
-    */
-   public DBUserImpl(String userName)
-   {
-      this.key = null;
-      this.userName = userName;
-      this.dynamic = new HashMap();
-      this.profile = new ProfileMapImpl(this);
-      this.roles = new HashSet();
-      this.registrationDate = new Date();
-      this.enabled = false;
-   }
-
-   /** Called by hibernate. */
-   public Long getKey()
-   {
-      return key;
-   }
-
-   /** Called by hibernate. */
-   protected void setKey(Long key)
-   {
-      this.key = key;
-   }
-
-   /** Called by hibernate. */
-   protected void setUserName(String userName)
-   {
-      this.userName = userName;
-   }
-
-   /** Called by Hibernate. */
-   protected Map getDynamic()
-   {
-      return dynamic;
-   }
-
-   /** Called by Hibernate. */
-   protected void setDynamic(Map dynamic)
-   {
-      this.dynamic = dynamic;
-   }
-
-   // User implementation **********************************************************************************************
-
-   /**
-    *
-    */
-   public Object getId()
-   {
-      return key;
-   }
-
-   /**
-    *
-    */
-   public String getUserName()
-   {
-      return userName;
-   }
-
-   /**
-    *
-    */
-   public String getGivenName()
-   {
-      return givenName;
-   }
-
-   public void setGivenName(String givenName)
-   {
-      this.givenName = givenName;
-   }
-
-   /**
-    *
-    */
-   public String getFamilyName()
-   {
-      return familyName;
-   }
-
-   public void setFamilyName(String familyName)
-   {
-      this.familyName = familyName;
-   }
-
-   public void updatePassword(String password)
-   {
-      this.password = Tools.md5AsHexString(password);
-   }
-
-   /**
-    *
-    */
-   public String getRealEmail()
-   {
-      return realEmail;
-   }
-
-   /**
-    *
-    */
-   public void setRealEmail(String realEmail)
-   {
-      this.realEmail = realEmail;
-   }
-
-   /**
-    *
-    */
-   public String getFakeEmail()
-   {
-      return fakeEmail;
-   }
-
-   /**
-    *
-    */
-   public void setFakeEmail(String fakeEmail)
-   {
-      this.fakeEmail = fakeEmail;
-   }
-
-   /**
-    *
-    */
-   public Date getRegistrationDate()
-   {
-      return registrationDate;
-   }
-
-   /**
-    *
-    */
-   public void setRegistrationDate(Date registrationDate)
-   {
-      this.registrationDate = registrationDate;
-   }
-
-   /**
-    *
-    */
-   public boolean getViewRealEmail()
-   {
-      return viewRealEmail;
-   }
-
-   /**
-    *
-    */
-   public void setViewRealEmail(boolean viewRealEmail)
-   {
-      this.viewRealEmail = viewRealEmail;
-   }
-
-   /**
-    *
-    */
-   public boolean getEnabled()
-   {
-      return enabled;
-   }
-
-   /**
-    *
-    */
-   public void setEnabled(boolean enable)
-   {
-      this.enabled = enable;
-   }
-
-   /**
-    *
-    */
-   public ProfileMap getProfile()
-   {
-      return profile;
-   }
-
-   public String getPassword()
-   {
-      return password;
-   }
-
-   public void setPassword(String password)
-   {
-      this.password = password;
-   }
-
-   /** Returns the roles related to this user. */
-   public Set getRoles()
-   {
-      return roles;
-   }
-
-   /** Update the roles. */
-   public void setRoles(Set roles)
-   {
-      this.roles = roles;
-      this.roleNames = null;
-   }
-
-   // Dynamic attributes
-
-   /** Implemented as a dynamic attribute (see #INFO_USER_LAST_LOGIN_DATE). */
-   public Date getLastVisitDate()
-   {
-      Date date = null;
-      String dateAsString = (String)getDynamic().get(User.INFO_USER_LAST_LOGIN_DATE);
-      if (dateAsString != null)
-      {
-         try
-         {
-            long dateAsLong = Long.parseLong(dateAsString);
-            date = new Date(dateAsLong);
-         }
-         catch (NumberFormatException e)
-         {
-            log.error("Bad date format " + dateAsString + " try to remove it", e);
-            getDynamic().remove(User.INFO_USER_LAST_LOGIN_DATE);
-         }
-      }
-      return date;
-   }
-
-   public void setLastVisitDate(Date date)
-   {
-      if (date == null)
-      {
-         getDynamic().remove(User.INFO_USER_LAST_LOGIN_DATE);
-      }
-      else
-      {
-         long dateAsLong = date.getTime();
-         String dateAsString = Long.toString(dateAsLong);
-         getDynamic().put(User.INFO_USER_LAST_LOGIN_DATE, dateAsString);
-      }
-   }
-
-   /** Implemented as a dynamic attribute (see #INFO_USER_SIGNATURE). */
-   public String getSignature()
-   {
-      return (String)getDynamic().get(User.INFO_USER_SIGNATURE);
-   }
-
-   public void setSignature(String signature)
-   {
-      getDynamic().put(User.INFO_USER_SIGNATURE, signature);
-   }
-
-   /** Implemented as a dynamic attribute (see #INFO_USER_LOCALE). */
-   public Locale getPreferredLocale()
-   {
-      Locale locale = null;
-      String localeAsString = (String)getDynamic().get(User.INFO_USER_LOCALE);
-      if (localeAsString != null)
-      {
-         LocaleInfo info = LocaleInfo.decodeLocaleInfo(localeAsString);
-         if (info != null)
-         {
-            locale = info.getLocale();
-         }
-      }
-      return locale;
-   }
-
-   public void setPreferredLocale(Locale locale)
-   {
-      if (locale == null)
-      {
-         getDynamic().remove(User.INFO_USER_LOCALE);
-      }
-      else
-      {
-         String localeAsString = locale.toString();
-         getDynamic().put(User.INFO_USER_LOCALE, localeAsString);
-      }
-   }
-
-   public String getTheme()
-   {
-      return (String)getDynamic().get(User.INFO_USER_THEME);
-   }
-
-   public void setTheme(String themeId)
-   {
-      if ((themeId == null) || (themeId.equals("")))
-      {
-         getDynamic().remove(User.INFO_USER_THEME);
-      }
-      else
-      {
-         getDynamic().put(User.INFO_USER_THEME, themeId);
-      }
-   }
-
-   public boolean validatePassword(String password)
-   {
-      if (password != null)
-      {
-         String hashedPassword = Tools.md5AsHexString(password);
-         return hashedPassword.equals(this.password);
-      }
-      return false;
-   }
-
-   /** Return all the role names of the user. */
-   public Set getRoleNames()
-   {
-      if (roleNames == null)
-      {
-         Iterator it = roles.iterator();
-         roleNames = new HashSet();
-         while (it.hasNext())
-         {
-            roleNames.add(((Role)it.next()).getName());
-         }
-      }
-      return roleNames;
-   }
-
-   /**
-    *
-    */
-   public String toString()
-   {
-      return "User[" + key + "," + userName + "]";
-   }
-
-   /** An accessor that maps a user field to a property name. */
-   static abstract class PropertyAccessor
-   {
-
-      protected final String propertyName;
-      protected final Field field;
-      protected final boolean writable;
-      protected final boolean nullable;
-
-      public PropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
-      {
-         try
-         {
-            this.propertyName = propertyName;
-            this.writable = writable;
-            this.field = DBUserImpl.class.getDeclaredField(fieldName);
-            this.nullable = nullable;
-         }
-         catch (NoSuchFieldException e)
-         {
-            throw new Error(e);
-         }
-      }
-
-      public String getPropertyName()
-      {
-         return propertyName;
-      }
-
-      public boolean isNullable()
-      {
-         return nullable;
-      }
-
-      public boolean isWritable()
-      {
-         return writable;
-      }
-
-      /**
-       * @param instance the user instance
-       * @param string   the value
-       * @throws IllegalArgumentException if the string cannot be converted to an object
-       */
-      public void set(Object instance, String string) throws IllegalArgumentException
-      {
-         try
-         {
-            if (string == null)
-            {
-               field.set(instance, null);
-            }
-            else
-            {
-               Object object = toObject(string);
-               field.set(instance, object);
-            }
-         }
-         catch (IllegalAccessException e)
-         {
-            throw new Error(e);
-         }
-      }
-
-      /**
-       * @param instance the user instance
-       * @return the converted value
-       * @throws IllegalArgumentException if the object cannot be converted to a string
-       */
-      public String get(Object instance) throws IllegalArgumentException
-      {
-         try
-         {
-            Object object = field.get(instance);
-            if (object == null)
-            {
-               return null;
-            }
-            else
-            {
-               return toString(object);
-            }
-         }
-         catch (IllegalAccessException e)
-         {
-            throw new Error(e);
-         }
-      }
-
-      /**
-       * Perform the to object conversion.
-       *
-       * @param value the value to convert
-       * @return the converted value
-       * @throws IllegalArgumentException if the string cannot be converted to an object
-       */
-      protected abstract Object toObject(String value) throws IllegalArgumentException;
-
-      /**
-       * Perform the to strong conversion.
-       *
-       * @param value the value to convert
-       * @return the converted value
-       * @throws IllegalArgumentException if the object cannot be converted to a string
-       */
-      protected abstract String toString(Object value);
-
-      public String toString()
-      {
-         return "PropertyAccessor[" + propertyName + "," + field + "]";
-      }
-   }
-
-   static class StringPropertyAccessor extends DBUserImpl.PropertyAccessor
-   {
-      public StringPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
-      {
-         super(propertyName, fieldName, writable, nullable);
-      }
-
-      protected Object toObject(String value)
-      {
-         return value;
-      }
-
-      protected String toString(Object value)
-      {
-         return (String)value;
-      }
-   }
-
-   static class BooleanPropertyAccessor extends DBUserImpl.PropertyAccessor
-   {
-      public BooleanPropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
-      {
-         super(propertyName, fieldName, writable, nullable);
-      }
-
-      protected Object toObject(String value) throws IllegalArgumentException
-      {
-         if ("true".equalsIgnoreCase(value))
-         {
-            return Boolean.TRUE;
-         }
-         else if ("false".equalsIgnoreCase(value))
-         {
-            return Boolean.FALSE;
-         }
-         else
-         {
-            throw new IllegalArgumentException("The value " + value + " cannot be converted to boolean for accessor " + toString());
-         }
-      }
-
-      protected String toString(Object value)
-      {
-         return value.toString();
-      }
-   }
-
-   static class DatePropertyAccessor extends DBUserImpl.PropertyAccessor
-   {
-      private static final ThreadLocal formatLocal = new ThreadLocal()
-      {
-         protected Object initialValue()
-         {
-            return new SimpleDateFormat();
-         }
-      };
-
-      public DatePropertyAccessor(String propertyName, String fieldName, boolean writable, boolean nullable)
-      {
-         super(propertyName, fieldName, writable, nullable);
-      }
-
-      protected Object toObject(String value) throws IllegalArgumentException
-      {
-         try
-         {
-            DateFormat format = (DateFormat)formatLocal.get();
-            Date date = format.parse(value);
-            return date;
-         }
-         catch (ParseException e)
-         {
-            throw new IllegalArgumentException();
-         }
-      }
-
-      protected String toString(Object value)
-      {
-         Date date = (Date)value;
-         DateFormat format = (DateFormat)formatLocal.get();
-         return format.format(date);
-      }
-   }
-}

Added: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateHelper.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateHelper.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateHelper.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,143 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.portal.identity2.experimental.db;
+
+import org.jboss.portal.identity2.info.ProfileInfo;
+import org.jboss.portal.identity2.info.PropertyInfo;
+import org.jboss.portal.identity.IdentityException;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
+import java.io.File;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.Map;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class HibernateHelper
+{
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateHelper.class);
+
+
+   public static synchronized String generateProfileMappings(String template, String output, String mappingPattern, ProfileInfo info, ClassLoader tcl) throws Exception
+   {
+      //InputStream profileIS;
+      InputStream templateIS;
+      OutputStream mappingOS;
+      File of = null;
+
+      try
+      {
+         templateIS = tcl.getResourceAsStream(template);
+      }
+      catch (Exception e)
+      {
+         throw new IdentityException("Cannot open mapping template resource: " + template, e);
+      }
+
+      try
+      {
+         of = new File(output);
+         if (!of.exists())
+         {
+            log.info("creating new file");
+            of.createNewFile();
+         }
+         log.info("Generating identity hibernate mappings file to: " + of.getAbsolutePath());
+         mappingOS = new FileOutputStream(of, false);
+      }
+      catch (Exception e)
+      {
+         throw new IdentityException("Cannot open mapping file for write",e);
+      }
+
+      if (output == null)
+      {
+         throw new IdentityException("Mapping Pattern not specified");
+      }
+
+
+      
+      //process template
+      LineNumberReader templateReader = new LineNumberReader(new InputStreamReader(templateIS));
+      PrintWriter mappingWriter = new PrintWriter(new OutputStreamWriter(mappingOS));
+
+      Pattern pattern = Pattern.compile(".*@mappings at .*");
+
+
+      String line;
+
+      while ((line = templateReader.readLine()) != null)
+      {
+         Matcher matcher = pattern.matcher(line);
+         if (matcher.matches())
+         {
+            if (log.isDebugEnabled())
+            {
+               log.debug("Found @mappings@ tag at line: " + templateReader.getLineNumber());
+            }
+
+            line = generateColumns(info, mappingPattern);
+            if (log.isDebugEnabled())
+            {
+               log.debug("Generated mappings: " + line);
+            }
+         }
+         mappingWriter.println(line);
+      }
+      templateReader.close();
+      mappingWriter.close();
+      return of.getAbsolutePath();
+   }
+
+   private static String generateColumns(ProfileInfo info, String pattern)
+   {
+      StringBuffer columns = new StringBuffer();
+
+      Map properties = info.getPropertiesInfo();
+      for (Iterator iterator = properties.keySet().iterator(); iterator.hasNext();)
+      {
+         String key = (String)iterator.next();
+         PropertyInfo property = (PropertyInfo)properties.get(key);
+
+         if (property.isMappedDB() && property.getMappingDBType().equals(PropertyInfo.MAPPING_DB_TYPE_COLUMN))
+         {
+            String mapping = pattern.replaceFirst("@name@", property.getName()).replaceFirst("@column@", property.getMappingDBValue());
+            columns.append(mapping);
+            columns.append('\n');
+         }
+
+      }
+      return columns.toString();
+
+   }
+
+}

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -1,61 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.service.MembershipModuleService;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity.IdentityException;
-
-import java.util.Set;
-
-/**
- * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class HibernateMembershipModuleImpl extends MembershipModuleService
-{
-   public Set getRoles(User user) throws IdentityException
-   {
-      return null;  //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-   public Set getUsers(Role role) throws IdentityException
-   {
-      return null;  //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-   public void assignUsers(Role role, Set users) throws IdentityException
-   {
-      //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-   public void assignRoles(User user, Set roles) throws IdentityException
-   {
-      //To change body of implemented methods use File | Settings | File Templates.
-   }
-
-   public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
-   {
-      return null;  //To change body of implemented methods use File | Settings | File Templates.
-   }
-}

Copied: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java (from rev 5809, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateMembershipModuleImpl.java	2006-12-12 18:42:45 UTC (rev 5809)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateMembershipModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,267 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.portal.identity2.experimental.db;
+
+import org.jboss.portal.identity2.service.MembershipModuleService;
+import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity2.Role;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.Tools;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+
+import javax.naming.InitialContext;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class HibernateMembershipModuleImpl extends MembershipModuleService
+{
+   /** . */
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateMembershipModuleImpl.class);
+   /** . */
+   protected SessionFactory sessionFactory;
+
+   /** . */
+   protected String sessionFactoryJNDIName;
+
+   protected void startService() throws Exception
+   {
+      //
+      sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+      super.startService();
+   }
+
+   protected void stopService() throws Exception
+   {
+
+      //
+      sessionFactory = null;
+
+      super.stopService();
+   }
+
+//   public SessionFactory getSessionFactory()
+//   {
+//      return sessionFactory;
+//   }
+
+   public String getSessionFactoryJNDIName()
+   {
+      return sessionFactoryJNDIName;
+   }
+
+   public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+   {
+      this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+   }
+
+   public Set getRoles(User user) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (!(user instanceof HibernateUserImpl))
+      {
+         throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+      }
+
+      // We return an immutable set to avoid modifications
+      HibernateUserImpl ui = (HibernateUserImpl)user;
+      Set roles = ui.getRoleMapsSet();
+      Set wrappers = new HashSet();
+      for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+      {
+         Map map = (Map)iterator.next();
+         wrappers.add(new HibernateRoleImpl(getSessionFactory(), map));
+      }
+
+      return wrappers;
+   }
+
+   public Set getUsers(Role role) throws IdentityException
+   {
+      if (!(role instanceof HibernateRoleImpl))
+      {
+         throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
+      }
+
+      // We return an immutable set to avoid modifications
+      HibernateRoleImpl ri = (HibernateRoleImpl)role;
+      Set users = ri.getUserMapsSet();
+      Set wrappers = new HashSet();
+      for (Iterator iterator = users.iterator(); iterator.hasNext();)
+      {
+         Map map = (Map)iterator.next();
+         wrappers.add(new HibernateUserImpl(getSessionFactory(), map));
+      }
+
+      return wrappers;
+   }
+
+   public void assignUsers(Role role, Set users) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (!(role instanceof HibernateRoleImpl))
+      {
+         throw new IllegalArgumentException("User is not a HibernateRoleImpl user");
+      }
+
+      for (Iterator i = users.iterator(); i.hasNext();)
+      {
+         Object o = i.next();
+         if (o instanceof HibernateUserImpl)
+         {
+            ((HibernateUserImpl)o).addRole(((HibernateRoleImpl)role).getCurrentMap());
+         }
+         else
+         {
+            throw new IllegalArgumentException("Only HibernateUserImpl roles can be accepted");
+         }
+      }
+
+   }
+
+   public void assignRoles(User user, Set roles) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (!(user instanceof HibernateUserImpl))
+      {
+         throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+      }
+
+      // We make a defensive copy with unwrapped maps and update with a new set
+      Set copy = new HashSet();
+      for (Iterator i = roles.iterator(); i.hasNext();)
+      {
+         Object o = i.next();
+         if (o instanceof HibernateRoleImpl)
+         {
+            copy.add(((HibernateRoleImpl)o).getCurrentMap());
+         }
+         else
+         {
+            throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
+         }
+      }
+
+      // Assign new roles
+      HibernateUserImpl ui = (HibernateUserImpl)user;
+      ui.setRoles(copy);
+   }
+
+   //TODO:
+   public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+   {
+      if (roleName != null)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+
+            Query query;
+            if (userNameFilter.trim().length() != 0)
+            {
+               //
+               userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
+
+               //
+               query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
+               query.setString("filter", userNameFilter);
+            }
+            else
+            {
+               query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name");
+            }
+            query.setString("name", roleName);
+            query.setFirstResult(offset);
+            query.setMaxResults(limit);
+
+            Iterator iterator = query.iterate();
+            Set result = processRolesSet(Tools.toSet(iterator));
+
+            Set newResult = new HashSet();
+            Iterator cleaner = result.iterator();
+            while (cleaner.hasNext())
+            {
+               Object[] oArr = (Object[])cleaner.next();
+               newResult.add(oArr[0]);
+            }
+
+            return newResult;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find role  " + roleName;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("id cannot be null");
+      }
+   }
+
+   /**
+    * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
+    * @param maps
+    * @return
+    * @throws Exception
+    */
+   private Set processRolesSet(Set maps) throws IdentityException
+   {
+      Set roles = new HashSet();
+      for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
+      {
+         Map roleMap = (Map)iterator1.next();
+         roles.add(new HibernateRoleImpl(getSessionFactory(),roleMap));
+      }
+      return roles;
+   }
+
+   /**
+    * Can be subclasses to provide testing in a non JTA environement.
+    *
+    * @throws IllegalStateException if no session factory is present
+    */
+   protected Session getCurrentSession() throws IllegalStateException
+   {
+      return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+
+   }
+
+   protected SessionFactory getSessionFactory() throws IllegalStateException
+   {
+       if (sessionFactory == null)
+      {
+         throw new IllegalStateException("No session factory");
+      }
+      return sessionFactory;//.getCurrentSession();
+   }
+}

Copied: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleImpl.java (from rev 5746, trunk/identity/src/main/org/jboss/portal/identity2/db/DBRoleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/DBRoleImpl.java	2006-11-30 22:53:29 UTC (rev 5746)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,206 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.portal.identity2.experimental.db;
+
+import org.jboss.portal.identity2.Role;
+import org.jboss.portal.identity.IdentityException;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.EntityMode;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class HibernateRoleImpl
+   implements Role
+{
+
+   public static final String ENTITY_NAME = "PortalRole";
+   public static final String MAPPING_ID = "key";
+   public static final String MAPPING_NAME = "name";
+   public static final String MAPPING_DISPLAY_NAME = "displayName";
+   public static final String MAPPING_USERS = "users";
+
+   private SessionFactory sessionFactory;
+
+   private Map currentMap;
+
+   /*
+    * Transient fields.
+    */
+
+   private HibernateRoleImpl()
+   {
+
+   }
+
+   /**
+    * Initializes Hibernate role object. initialContent map should be already persisted in hibernate Session 
+    * @param sf
+    * @param initialContent
+    * @throws IdentityException
+    */
+   public HibernateRoleImpl(SessionFactory sf, Map initialContent) throws IdentityException
+   {
+      if (sf == null)
+      {
+         throw new IdentityException("SessionFactory is null");
+      }
+      if (initialContent == null)
+      {
+         throw new IdentityException("Map is null");
+      }
+      this.sessionFactory = sf;
+      this.currentMap = initialContent;
+      //persist();
+   }
+
+   // ***
+   //
+   // API
+   //
+   // ***
+
+   public Object getId()
+   {
+      return getCurrentMap().get(MAPPING_ID);
+   }
+
+   public String getName()
+   {
+      return (String)getCurrentMap().get(MAPPING_NAME);
+   }
+
+   public String getDisplayName()
+   {
+      return (String)getCurrentMap().get(MAPPING_DISPLAY_NAME);
+   }
+
+   public void setDisplayName(String name)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("name is null");
+      }
+      getCurrentMap().put(MAPPING_DISPLAY_NAME, name);
+      persist();
+   }
+
+   //users
+   public Set getUserMapsSet()
+   {
+      return Collections.unmodifiableSet(getUsersSet());
+   }
+
+   public void setUsers(Set users)
+   {
+      if (users == null)
+      {
+         throw new IllegalArgumentException("users set is null");
+      }
+      getCurrentMap().put(MAPPING_USERS, users);
+   }
+
+   // ***
+   //
+   // SPI
+   //
+
+   // ***
+
+   public void setName(String name, String value)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("name is null");
+      }
+      getCurrentMap().put(name, value);
+      persist();
+   }
+
+   public Map getCurrentMap()
+   {
+      return currentMap;
+   }
+
+   // ********
+   //
+   // Internal
+   //
+   // ********
+   protected SessionFactory getSessionFactory()
+   {
+      return sessionFactory;
+   }
+
+   protected void setSessionFactory(SessionFactory sessionFactory)
+   {
+      this.sessionFactory = sessionFactory;
+   }
+
+   protected void setCurrentMap(Map currentMap)
+   {
+      this.currentMap = currentMap;
+   }
+
+   protected Set getUsersSet()
+   {
+      Set users = (Set)getCurrentMap().get(MAPPING_USERS);
+      if (users == null)
+      {
+         users = new HashSet();
+         getCurrentMap().put(MAPPING_USERS, users);
+      }
+      return users;
+   }
+
+   protected void persist()
+   {
+      getCurrentSession().save(ENTITY_NAME, currentMap);
+   }
+
+
+   public String toString()
+   {
+      return "Role[" + getId() + "," + getName() + "]";
+   }
+
+   /**
+    * Can be subclasses to provide testing in a non JTA environement.
+    */
+   protected Session getCurrentSession()
+   {
+      if (sessionFactory == null)
+      {
+         throw new IllegalStateException("No session factory");
+      }
+      return sessionFactory.getCurrentSession().getSession(EntityMode.MAP);
+   }
+}
+
+

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -1,388 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.Role;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.identity2.service.RoleModuleService;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Criteria;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.criterion.Restrictions;
-
-import javax.naming.InitialContext;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.HashSet;
-import java.util.Collections;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
- * @author Roy Russo : roy at jboss dot org
- * @version $Revision: 5448 $
- * @portal.core
- */
-public class HibernateRoleModuleImpl extends RoleModuleService
-{
-   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserModuleImpl.class);
-
-   /** . */
-   protected String sessionFactoryJNDIName;
-
-   /** . */
-   protected SessionFactory sessionFactory;
-
-   public String getSessionFactoryJNDIName()
-   {
-      return sessionFactoryJNDIName;
-   }
-
-   public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
-   {
-      this.sessionFactoryJNDIName = sessionFactoryJNDIName;
-   }
-
-   public SessionFactory getSessionFactory()
-   {
-      return sessionFactory;
-   }
-
-   protected void startService() throws Exception
-   {
-      //
-      sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
-      super.startService();
-   }
-
-   protected void stopService() throws Exception
-   {
-      sessionFactory = null;
-
-      super.stopService();
-
-      //
-
-   }
-
-   public Role findRoleByName(String name) throws IdentityException
-   {
-      if (name != null)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-            Criteria criteria = session.createCriteria(DBRoleImpl.class);
-            criteria.add(Restrictions.naturalId().set("name", name));
-            criteria.setCacheable(true);
-            DBRoleImpl role = (DBRoleImpl)criteria.uniqueResult();
-            if (role == null)
-            {
-               throw new IdentityException("No such role " + name);
-            }
-            return role;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find role by name " + name;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("name cannot be null");
-      }
-   }
-
-   public Set findRolesByNames(String[] names) throws IdentityException
-   {
-      if (names != null)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-            StringBuffer queryString = new StringBuffer("from DBRoleImpl as g where g.name=?");
-            for (int i = 1; i < names.length; i++)
-            {
-               queryString.append(" or g.name=?");
-            }
-            Query query = session.createQuery(queryString.toString());
-            for (int i = 0; i < names.length; i++)
-            {
-               query.setString(i, names[i]);
-            }
-            Iterator iterator = query.iterate();
-            return Tools.toSet(iterator);
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find roles";
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("name cannot be null");
-      }
-   }
-
-   public Role findRoleById(String id) throws IllegalArgumentException, IdentityException
-   {
-      if (id == null)
-      {
-         throw new IllegalArgumentException("The id is null");
-      }
-      try
-      {
-         return findRoleById(new Long(id));
-      }
-      catch (NumberFormatException e)
-      {
-         throw new IllegalArgumentException("Cannot parse id into an long " + id);
-      }
-   }
-
-   public Role findRoleById(Object id) throws IdentityException
-   {
-      if (id instanceof Long)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-            DBRoleImpl role = (DBRoleImpl)session.get(DBRoleImpl.class, (Long)id);
-            if (role == null)
-            {
-               throw new IdentityException("No role found for " + id);
-            }
-            return role;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find role by id " + id;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("The id is not an long : " + id);
-      }
-   }
-
-   public Role createRole(String name, String displayName) throws IdentityException
-   {
-      if (name != null)
-      {
-         try
-         {
-            DBRoleImpl role = new DBRoleImpl(name, displayName);
-            Session session = getCurrentSession();
-            session.save(role);
-            return role;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot create role " + name;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("name cannot be null");
-      }
-   }
-
-   public void removeRole(Object id) throws IdentityException
-   {
-      if (id instanceof Long)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-            DBRoleImpl role = (DBRoleImpl)session.load(DBRoleImpl.class, (Long)id);
-            Iterator users = role.getUsers().iterator();
-            while (users.hasNext())
-            {
-               DBUserImpl user = (DBUserImpl)users.next();
-               user.getRoles().remove(role);
-            }
-            session.delete(role);
-            session.flush();
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot remove role  " + id;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("The id is not an long : " + id);
-      }
-   }
-
-   public int getRolesCount() throws IdentityException
-   {
-      try
-      {
-         Session session = getCurrentSession();
-         Query query = session.createQuery("select count(g.id) from DBRoleImpl as g");
-         return ((Number)query.uniqueResult()).intValue();
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot count roles";
-         log.error(message, e);
-         throw new IdentityException(message, e);
-      }
-   }
-
-   public Set findRoles() throws IdentityException
-   {
-      try
-      {
-         Session session = getCurrentSession();
-         Query query = session.createQuery("from DBRoleImpl");
-         Iterator iterator = query.iterate();
-         return Tools.toSet(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find roles";
-         log.error(message, e);
-         throw new IdentityException(message, e);
-      }
-   }
-
-   public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
-   {
-      if (roleName != null)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-
-            DBUserImpl userimpl = new DBUserImpl();
-            userimpl.setEnabled(true);
-
-            Query query;
-            if (userNameFilter.trim().length() != 0)
-            {
-               //
-               userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
-
-               //
-               query = session.createQuery("from DBUserImpl as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
-               query.setString("filter", userNameFilter);
-            }
-            else
-            {
-               query = session.createQuery("from DBUserImpl as user left join user.roles role where role.name=:name");
-            }
-            query.setString("name", roleName);
-            query.setFirstResult(offset);
-            query.setMaxResults(limit);
-
-            Iterator iterator = query.iterate();
-            Set result = Tools.toSet(iterator);
-
-            Set newResult = new HashSet();
-            Iterator cleaner = result.iterator();
-            while (cleaner.hasNext())
-            {
-               Object[] oArr = (Object[])cleaner.next();
-               newResult.add(oArr[0]);
-            }
-
-            return newResult;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find role  " + roleName;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("id cannot be null");
-      }
-   }
-
-   public void setRoles(User user, Set roles) throws IdentityException
-   {
-      if (!(user instanceof DBUserImpl))
-      {
-         throw new IllegalArgumentException("User is not a db user");
-      }
-
-      // We make a defensive copy and update with a new set
-      Set copy = new HashSet();
-      for (Iterator i = roles.iterator(); i.hasNext();)
-      {
-         Object o = i.next();
-         if (o instanceof DBRoleImpl)
-         {
-            copy.add(o);
-         }
-         else
-         {
-            throw new IllegalArgumentException("Only db roles can be accepted");
-         }
-      }
-
-      // Assign new roles
-      DBUserImpl ui = (DBUserImpl)user;
-      ui.setRoles(copy);
-   }
-
-   public Set getRoles(User user) throws IdentityException
-   {
-      if (!(user instanceof DBUserImpl))
-      {
-         throw new IllegalArgumentException("User is not a db user");
-      }
-
-      // We return an immutable set to avoid modifications
-      DBUserImpl ui = (DBUserImpl)user;
-      return Collections.unmodifiableSet(ui.getRoles());
-   }
-
-   /** Can be subclasses to provide testing in a non JTA environement. */
-   protected Session getCurrentSession()
-   {
-      if (sessionFactory == null)
-      {
-         throw new IllegalStateException("No session factory");
-      }
-      return sessionFactory.getCurrentSession();
-   }
-}

Copied: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java (from rev 5809, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateRoleModuleImpl.java	2006-12-12 18:42:45 UTC (rev 5809)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateRoleModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,459 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.portal.identity2.experimental.db;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.Criteria;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+import org.hibernate.criterion.Restrictions;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity2.Role;
+import org.jboss.portal.identity2.service.RoleModuleService;
+import org.jboss.portal.common.util.Tools;
+
+import javax.naming.InitialContext;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
+ * @author Roy Russo : roy at jboss dot org
+ * @version $Revision: 5448 $
+ * @portal.core
+ */
+public class HibernateRoleModuleImpl extends RoleModuleService
+{
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateRoleModuleImpl.class);
+
+   /** . */
+   protected String sessionFactoryJNDIName;
+
+   /** . */
+   protected SessionFactory sessionFactory;
+
+   public String getSessionFactoryJNDIName()
+   {
+      return sessionFactoryJNDIName;
+   }
+
+   public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+   {
+      this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+   }
+
+//   public SessionFactory getSessionFactory()
+//   {
+//      return sessionFactory;
+//   }
+
+   protected void startService() throws Exception
+   {
+      //
+      sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+      super.startService();
+   }
+
+   protected void stopService() throws Exception
+   {
+      sessionFactory = null;
+
+      super.stopService();
+
+      //
+
+   }
+
+   public Role findRoleByName(String name) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (name != null)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+            Criteria criteria = session.createCriteria(HibernateRoleImpl.ENTITY_NAME);
+            criteria.add(Restrictions.naturalId().set("name", name));
+            criteria.setCacheable(true);
+            Map roleMap = (Map)criteria.uniqueResult();
+            if (roleMap == null)
+            {
+               throw new IdentityException("No such role " + name);
+            }
+            return new HibernateRoleImpl(getSessionFactory(), roleMap);
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find role by name " + name;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("name cannot be null");
+      }
+   }
+
+   public Set findRolesByNames(String[] names) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (names != null)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+            StringBuffer queryString = new StringBuffer("from PortalRole as g where g.name=?");
+            for (int i = 1; i < names.length; i++)
+            {
+               queryString.append(" or g.name=?");
+            }
+            Query query = session.createQuery(queryString.toString());
+            for (int i = 0; i < names.length; i++)
+            {
+               query.setString(i, names[i]);
+            }
+            Iterator iterator = query.iterate();
+            return processRolesSet(Tools.toSet(iterator));
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find roles";
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("name cannot be null");
+      }
+   }
+
+   public Role findRoleById(String id) throws IllegalArgumentException, IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (id == null)
+      {
+         throw new IllegalArgumentException("The id is null");
+      }
+      try
+      {
+         return findRoleById(new Long(id));
+      }
+      catch (NumberFormatException e)
+      {
+         throw new IllegalArgumentException("Cannot parse id into an long " + id);
+      }
+   }
+
+   public Role findRoleById(Object id) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (id instanceof Long)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+            Map roleMap = (Map)session.get(HibernateRoleImpl.ENTITY_NAME, (Long)id);
+            if (roleMap == null)
+            {
+               throw new IdentityException("No role found for " + id);
+            }
+            return new HibernateRoleImpl(getSessionFactory(),roleMap);
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find role by id " + id;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("The id is not an long : " + id);
+      }
+   }
+
+   public Role createRole(String name, String displayName) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (name != null)
+      {
+         try
+         {
+            Map roleMap = new HashMap();
+            roleMap.put(HibernateRoleImpl.MAPPING_NAME, name);
+            getCurrentSession().save(HibernateRoleImpl.ENTITY_NAME, roleMap);
+            HibernateRoleImpl role = new HibernateRoleImpl(getSessionFactory(), roleMap);
+            role.setDisplayName(displayName);
+            return role;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot create role " + name;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("name cannot be null");
+      }
+   }
+
+   public void removeRole(Object id) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (id instanceof Long)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+            Map roleMap = (Map)session.load(HibernateRoleImpl.ENTITY_NAME, (Long)id);
+
+            //remove users asignments
+            Set usersSet = (Set)roleMap.get(HibernateRoleImpl.MAPPING_USERS);
+
+            if (usersSet != null)
+            {
+               Iterator users = usersSet.iterator();
+               while (users.hasNext())
+               {
+                  Map userMap = (Map)users.next();
+
+                  //make a new set of roles without this one
+                  Set newRoles = new HashSet();
+                  Set roles = (Set)userMap.get(HibernateUserImpl.MAPPING_ROLES);
+                  for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+                  {
+                     Map role = (Map)iterator.next();
+                     if (!(role.get(HibernateRoleImpl.MAPPING_ID)).equals(id))
+                     {
+                        newRoles.add(role);
+                     }
+                  }
+                  userMap.put(HibernateUserImpl.MAPPING_ROLES, newRoles);
+               }
+            }
+            session.delete(HibernateRoleImpl.ENTITY_NAME, roleMap);
+            session.flush();
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot remove role  " + id;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("The id is not an long : " + id);
+      }
+   }
+
+   public int getRolesCount() throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      try
+      {
+         Session session = getCurrentSession();
+         Query query = session.createQuery("select count(g.id) from PortalRole as g");
+         return ((Number)query.uniqueResult()).intValue();
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot count roles";
+         log.error(message, e);
+         throw new IdentityException(message, e);
+      }
+   }
+
+   public Set findRoles() throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      try
+      {
+         Session session = getCurrentSession();
+         Query query = session.createQuery("from PortalRole");
+         Iterator iterator = query.iterate();
+         return processRolesSet(Tools.toSet(iterator));
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find roles";
+         log.error(message, e);
+         throw new IdentityException(message, e);
+      }
+   }
+
+//   public Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter) throws IdentityException
+//   {
+//      //throw new UnsupportedOperationException("Not yet implemented");
+//      if (roleName != null)
+//      {
+//         try
+//         {
+//            Session session = getCurrentSession();
+//
+//            Query query;
+//            if (userNameFilter.trim().length() != 0)
+//            {
+//               //
+//               userNameFilter = "%" + userNameFilter.replaceAll("%", "") + "%";
+//
+//               //
+//               query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name" + " AND user.userName LIKE :filter");
+//               query.setString("filter", userNameFilter);
+//            }
+//            else
+//            {
+//               query = session.createQuery("from PortalUser as user left join user.roles role where role.name=:name");
+//            }
+//            query.setString("name", roleName);
+//            query.setFirstResult(offset);
+//            query.setMaxResults(limit);
+//
+//            Iterator iterator = query.iterate();
+//            Set result = processRolesSet(Tools.toSet(iterator));
+//
+//            Set newResult = new HashSet();
+//            Iterator cleaner = result.iterator();
+//            while (cleaner.hasNext())
+//            {
+//               Object[] oArr = (Object[])cleaner.next();
+//               newResult.add(oArr[0]);
+//            }
+//
+//            return newResult;
+//         }
+//         catch (HibernateException e)
+//         {
+//            String message = "Cannot find role  " + roleName;
+//            log.error(message, e);
+//            throw new IdentityException(message, e);
+//         }
+//      }
+//      else
+//      {
+//         throw new IllegalArgumentException("id cannot be null");
+//      }
+//   }
+
+   /**
+    * @deprecated
+    * @param user
+    * @param roles
+    * @throws IdentityException
+    */
+//   public void setRoles(User user, Set roles) throws IdentityException
+//   {
+//      //throw new UnsupportedOperationException("Not yet implemented");
+//      if (!(user instanceof HibernateUserImpl))
+//      {
+//         throw new IllegalArgumentException("User is not a HibernateUserImpl user");
+//      }
+//
+//      // We make a defensive copy with unwrapped maps and update with a new set
+//      Set copy = new HashSet();
+//      for (Iterator i = roles.iterator(); i.hasNext();)
+//      {
+//         Object o = i.next();
+//         if (o instanceof HibernateRoleImpl)
+//         {
+//            copy.add(((HibernateRoleImpl)o).getCurrentMap());
+//         }
+//         else
+//         {
+//            throw new IllegalArgumentException("Only HibernateRoleImpl roles can be accepted");
+//         }
+//      }
+//
+//      // Assign new roles
+//      HibernateUserImpl ui = (HibernateUserImpl)user;
+//      ui.setRoles(copy);
+//   }
+//
+//
+//   public Set getRoles(User user) throws IdentityException
+//   {
+//      //throw new UnsupportedOperationException("Not yet implemented");
+//      if (!(user instanceof HibernateUserImpl))
+//      {
+//         throw new IllegalArgumentException("User is not a db_old user");
+//      }
+//
+//      // We return an immutable set to avoid modifications
+//      HibernateUserImpl ui = (HibernateUserImpl)user;
+//      Set roles = ui.getRoleMapsSet();
+//      Set wrappers = new HashSet();
+//      for (Iterator iterator = roles.iterator(); iterator.hasNext();)
+//      {
+//         Map map = (Map)iterator.next();
+//         wrappers.add(new HibernateRoleImpl(getSessionFactory(), map));
+//      }
+//
+//      return wrappers;
+//   }
+
+   /**
+    * Process Set of Map objects and returns a Set of HibernateRoleImpl objects
+    * @param maps
+    * @return
+    * @throws Exception
+    */
+   private Set processRolesSet(Set maps) throws IdentityException
+   {
+      Set roles = new HashSet();
+      for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
+      {
+         Map roleMap = (Map)iterator1.next();
+         roles.add(new HibernateRoleImpl(getSessionFactory(),roleMap));
+      }
+      return roles;
+   }
+
+/**
+    * Can be subclasses to provide testing in a non JTA environement.
+    *
+    * @throws IllegalStateException if no session factory is present
+    */
+   protected Session getCurrentSession() throws IllegalStateException
+   {
+      return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+
+   }
+
+   protected SessionFactory getSessionFactory() throws IllegalStateException
+   {
+       if (sessionFactory == null)
+      {
+         throw new IllegalStateException("No session factory");
+      }
+      return sessionFactory;//.getCurrentSession();
+   }
+}

Copied: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserImpl.java (from rev 5746, trunk/identity/src/main/org/jboss/portal/identity2/db/DBUserImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/DBUserImpl.java	2006-11-30 22:53:29 UTC (rev 5746)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,324 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.portal.identity2.experimental.db;
+
+import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.Tools;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.EntityMode;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * User interface implementation.
+ *
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 5448 $
+ */
+public class HibernateUserImpl
+   implements User
+{
+
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserImpl.class);
+
+   //names used in hibernate.hbm.xml file to map fields
+   public static final String ENTITY_NAME = "PortalUser";
+   public static final String MAPPING_DYNAMIC_PROPERTY_MAP = "dynamic";
+   public static final String MAPPING_ROLES = "roles";
+   public static final String MAPPING_ID = "key";
+   public static final String MAPPING_USER_NAME = "userName";
+   public static final String MAPPING_PASSWORD = "password";
+
+   //list of fields used for mapping
+   public static final Set restrictedFieldNames = buildRestrictedFields();
+
+   private static Set buildRestrictedFields()
+   {
+      Set set = new HashSet();
+      set.add(MAPPING_DYNAMIC_PROPERTY_MAP);
+      set.add(MAPPING_ROLES);
+      set.add(MAPPING_ID);
+      set.add(MAPPING_USER_NAME);
+      set.add(MAPPING_PASSWORD);
+
+      return Collections.unmodifiableSet(set);
+   }
+
+   private SessionFactory sessionFactory;
+
+   private Map currentMap;
+
+   /*
+    * Transient fields.
+    */
+
+   private HibernateUserImpl()
+   {
+
+   }
+
+   /**
+    * Initializes Hibernate user object. initialContent map should be already persisted in hibernate Session 
+    * @param sf
+    * @param initialContent
+    * @throws IdentityException
+    */
+   public HibernateUserImpl(SessionFactory sf, Map initialContent) throws IdentityException
+   {
+      if (sf == null)
+      {
+         throw new IdentityException("SessionFactory is null");
+      }
+      if (initialContent == null)
+      {
+         throw new IdentityException("Map is null");
+      }
+      this.sessionFactory = sf;
+      this.currentMap = initialContent;
+      //persist();
+   }
+
+   // ***
+   //
+   // API
+   //
+   // ***
+
+   public Object getId()
+   {
+      return getCurrentMap().get(MAPPING_ID);
+   }
+
+   public String getUserName()
+   {
+      return (String)getCurrentMap().get(MAPPING_USER_NAME);
+   }
+
+   public void updatePassword(String password)
+   {
+      if (password == null)
+      {
+         throw new IllegalArgumentException("Password is null");
+      }
+      getCurrentMap().put(MAPPING_PASSWORD, Tools.md5AsHexString(password));
+      persist();
+   }
+
+   public boolean validatePassword(String password)
+   {
+      if (password != null)
+      {
+         String hashedPassword = Tools.md5AsHexString(password);
+         return hashedPassword.equals(getPassword());
+      }
+      return false;
+   }
+
+   public void setPassword(String pass)
+   {
+      getCurrentMap().put(MAPPING_PASSWORD, pass);
+      persist();
+   }
+
+   // ***
+   //
+   // SPI
+   //
+   // ***
+
+   public void setUserName(String userName)
+   {
+      if (userName == null)
+      {
+         throw new IllegalArgumentException("userName is null");
+      }
+      getCurrentMap().put(MAPPING_USER_NAME, userName);
+      persist();
+   }
+
+   public Map getCurrentMap()
+   {
+      return currentMap;
+   }
+
+   //properties
+   public Map getProperties()
+   {
+      return Collections.unmodifiableMap(getDynamic());
+   }
+
+   public void setDynamicProperties(Map props)
+   {
+      getCurrentMap().put(MAPPING_DYNAMIC_PROPERTY_MAP, props);
+      persist();
+   }
+
+   public void setDynamicProperty(String name, String value)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("property name is null");
+      }
+      getDynamic().put(name, value);
+      persist();
+   }
+
+   public String getDynamicProperty(String name)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("property name is null");
+      }
+      return (String)getDynamic().get(name);
+   }
+
+   public boolean hasDynamicPropertyValue(String name)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("property name is null");
+      }
+
+      return getDynamic().containsKey(name);
+   }
+
+   //fields
+   public String getFieldValue(String name)
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("name is null");
+      }
+      return (String)getCurrentMap().get(name);
+   }
+
+   public void setFieldValue(String name, String value) throws IdentityException
+   {
+      if (name == null)
+      {
+         throw new IllegalArgumentException("property name is null");
+      }
+      if (restrictedFieldNames.contains(name))
+      {
+         throw new IdentityException("Cannot set field name: " + name + " as it's restricted one");
+      }
+      getCurrentMap().put(name, value);
+      persist();
+   }
+
+   //roles
+
+   public Set getRoleMapsSet()
+   {
+      return Collections.unmodifiableSet(getRolesSet());
+   }
+
+
+   public void setRoles(Set roles)
+   {
+      if (roles == null)
+      {
+         throw new IllegalArgumentException("roles set is null");
+      }
+      getCurrentMap().put(MAPPING_ROLES, roles);
+      persist();
+   }
+
+   public void addRole(Map map)
+   {
+      getRolesSet().add(map);
+      persist();
+   }
+
+   public String getPassword()
+   {
+      return (String)getCurrentMap().get(MAPPING_PASSWORD);
+   }
+
+   // ********
+   //
+   // Internal
+   //
+   // ********
+
+
+   protected SessionFactory getSessionFactory()
+   {
+      return sessionFactory;
+   }
+
+   protected void setSessionFactory(SessionFactory sessionFactory)
+   {
+      this.sessionFactory = sessionFactory;
+   }
+
+   protected Map getDynamic()
+   {
+      Map props = (Map)getCurrentMap().get(MAPPING_DYNAMIC_PROPERTY_MAP);
+      if (props == null)
+      {
+         props = new HashMap();
+         getCurrentMap().put(MAPPING_DYNAMIC_PROPERTY_MAP, props);
+      }
+      return props;
+   }
+
+   protected Set getRolesSet()
+   {
+      Set roles = (Set)getCurrentMap().get(MAPPING_ROLES);
+      if (roles == null)
+      {
+         roles = new HashSet();
+         getCurrentMap().put(MAPPING_ROLES, roles);
+      }
+      return roles;
+   }
+
+   protected void persist()
+   {
+      getCurrentSession().save(ENTITY_NAME, currentMap);
+   }
+
+
+   public String toString()
+   {
+      return "User[" + getId() + "," + getUserName() + "]";
+   }
+
+   /**
+    * Can be subclasses to provide testing in a non JTA environement.
+    */
+   protected Session getCurrentSession()
+   {
+      if (sessionFactory == null)
+      {
+         throw new IllegalStateException("No session factory");
+      }
+      return sessionFactory.getCurrentSession().getSession(EntityMode.MAP);
+   }
+}

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -1,315 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.service.UserModuleService;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.identity.NoSuchUserException;
-import org.jboss.portal.common.util.JNDI;
-import org.jboss.portal.common.util.Tools;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Query;
-import org.hibernate.HibernateException;
-
-import javax.naming.InitialContext;
-import java.io.Serializable;
-import java.util.Set;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
- * @version $Revision: 5448 $
- * @portal.core
- */
-public class HibernateUserModuleImpl extends UserModuleService
-{
-
-   /** . */
-   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserModuleImpl.class);
-   /** . */
-   protected SessionFactory sessionFactory;
-
-   /** . */
-   protected String sessionFactoryJNDIName;
-
-   /** . */
-   protected String jndiName;
-
-   /** . */
-   protected JNDI.Binding jndiBinding;
-
-   public HibernateUserModuleImpl()
-   {
-   }
-
-   protected void startService() throws Exception
-   {
-      //
-      sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
-
-      //
-      if (jndiName != null)
-      {
-         jndiBinding = new JNDI.Binding(jndiName, this);
-         jndiBinding.bind();
-      }
-   }
-
-   protected void stopService() throws Exception
-   {
-      if (jndiBinding != null)
-      {
-         jndiBinding.unbind();
-         jndiBinding = null;
-      }
-
-      //
-      sessionFactory = null;
-   }
-
-   public SessionFactory getSessionFactory()
-   {
-      return sessionFactory;
-   }
-
-   public String getSessionFactoryJNDIName()
-   {
-      return sessionFactoryJNDIName;
-   }
-
-   public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
-   {
-      this.sessionFactoryJNDIName = sessionFactoryJNDIName;
-   }
-
-   public String getJNDIName()
-   {
-      return jndiName;
-   }
-
-   public void setJNDIName(String jndiName)
-   {
-      this.jndiName = jndiName;
-   }
-
-   public User findUserByUserName(String userName) throws IdentityException
-   {
-      if (userName != null)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-            Query query = session.createQuery("from DBDBUserImpl where userName=:userName");
-            query.setParameter("userName", userName);
-            query.setCacheable(true);
-            DBUserImpl user = (DBUserImpl)query.uniqueResult();
-            if (user == null)
-            {
-               throw new NoSuchUserException("No such user " + userName);
-            }
-            return user;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find user by name " + userName;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("user name cannot be null");
-      }
-   }
-
-   public User findUserById(String id) throws IllegalArgumentException, IdentityException, NoSuchUserException
-   {
-      if (id == null)
-      {
-         throw new IllegalArgumentException("The id is null");
-      }
-      try
-      {
-         return findUserById(new Long(id));
-      }
-      catch (NumberFormatException e)
-      {
-         throw new IllegalArgumentException("Cannot parse id into an long " + id);
-      }
-   }
-
-   public User findUserById(Object id) throws IllegalArgumentException, IdentityException, NoSuchUserException
-   {
-      if (id instanceof Long)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-            DBUserImpl user = (DBUserImpl)session.get(DBUserImpl.class, (Long)id);
-            if (user == null)
-            {
-               throw new NoSuchUserException("No user found for " + id);
-            }
-            return user;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot find user by id " + id;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("The id is not an long : " + id);
-      }
-   }
-
-   public User createUser(String userName, String password, String realEmail) throws IdentityException
-   {
-      if (userName != null)
-      {
-         try
-         {
-            DBUserImpl user = new DBUserImpl(userName);
-            user.updatePassword(password);
-            user.setRealEmail(realEmail);
-            Session session = getCurrentSession();
-            session.save(user);
-            return user;
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot create user " + userName;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("name cannot be null");
-      }
-   }
-
-   public void removeUser(Object id) throws IdentityException
-   {
-      if (id instanceof Long)
-      {
-         try
-         {
-            Session session = getCurrentSession();
-            DBUserImpl user = (DBUserImpl)session.load(DBUserImpl.class, (Serializable)id);
-            if (user == null)
-            {
-               throw new NoSuchUserException("No such user " + id);
-            }
-            session.delete(user);
-            session.flush();
-         }
-         catch (HibernateException e)
-         {
-            String message = "Cannot remove user " + id;
-            log.error(message, e);
-            throw new IdentityException(message, e);
-         }
-      }
-      else
-      {
-         throw new IllegalArgumentException("The id is not an long : " + id);
-      }
-   }
-
-   public Set findUsers(int offset, int limit) throws IdentityException
-   {
-      try
-      {
-         Session session = getCurrentSession();
-         Query query = session.createQuery("from DBDBUserImpl");
-         query.setFirstResult(offset);
-         query.setMaxResults(limit);
-         Iterator iterator = query.iterate();
-         return Tools.toSet(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find user range [" + offset + "," + limit + "]";
-         log.error(message, e);
-         throw new IdentityException(message, e);
-      }
-   }
-
-   public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException
-   {
-      try
-      {
-         // Remove all occurences of % and add ours
-         filter = "%" + filter.replaceAll("%", "") + "%";
-
-         //
-         Session session = getCurrentSession();
-         Query query = session.createQuery("from DBDBUserImpl as u where u.userName like :filter");
-         query.setString("filter", filter);
-         query.setFirstResult(offset);
-         query.setMaxResults(limit);
-         Iterator iterator = query.iterate();
-         return Tools.toSet(iterator);
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot find user range [" + offset + "," + limit + "]";
-         log.error(message, e);
-         throw new IdentityException(message, e);
-      }
-   }
-
-   public int getUserCount() throws IdentityException
-   {
-      try
-      {
-         Session session = getCurrentSession();
-         Query query = session.createQuery("select count(u.key) from DBDBUserImpl as u");
-         return ((Number)query.uniqueResult()).intValue();
-      }
-      catch (HibernateException e)
-      {
-         String message = "Cannot count users";
-         log.error(message, e);
-         throw new IdentityException(message, e);
-      }
-   }
-
-   /**
-    * Can be subclasses to provide testing in a non JTA environement.
-    *
-    * @throws IllegalStateException if no session factory is present
-    */
-   protected Session getCurrentSession() throws IllegalStateException
-   {
-      if (sessionFactory == null)
-      {
-         throw new IllegalStateException("No session factory");
-      }
-      return sessionFactory.getCurrentSession();
-   }
-}

Copied: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java (from rev 5809, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserModuleImpl.java	2006-12-12 18:42:45 UTC (rev 5809)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,329 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.portal.identity2.experimental.db;
+
+import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity2.service.UserModuleService;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.common.util.Tools;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+
+import javax.naming.InitialContext;
+import java.io.Serializable;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet </a>
+ * @version $Revision: 5448 $
+ * @portal.core
+ */
+public class HibernateUserModuleImpl extends UserModuleService
+{
+   /** . */
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserModuleImpl.class);
+   /** . */
+   protected SessionFactory sessionFactory;
+
+   /** . */
+   protected String sessionFactoryJNDIName;
+
+   protected void startService() throws Exception
+   {
+      //
+      sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+      super.startService();
+   }
+
+   protected void stopService() throws Exception
+   {
+
+      //
+      sessionFactory = null;
+      super.stopService();
+   }
+
+//   public SessionFactory getSessionFactory()
+//   {
+//      return sessionFactory;
+//   }
+
+   public String getSessionFactoryJNDIName()
+   {
+      return sessionFactoryJNDIName;
+   }
+
+   public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+   {
+      this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+   }
+
+   public User findUserByUserName(String userName) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+
+       if (userName != null)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+            //TODO: use contants
+            Query query = session.createQuery("from PortalUser where userName=:userName");
+            query.setParameter("userName", userName);
+            //query.setCacheable(true);
+            Map userMap = (Map)query.uniqueResult();
+            if (userMap == null)
+            {
+               throw new NoSuchUserException("No such user " + userName);
+            }
+            return new HibernateUserImpl(getSessionFactory(), userMap);
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find user by name " + userName;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("user name cannot be null");
+      }
+   }
+
+   public User findUserById(String id) throws IllegalArgumentException, IdentityException, NoSuchUserException
+   {
+      if (id == null)
+      {
+         throw new IllegalArgumentException("The id is null");
+      }
+      try
+      {
+         return findUserById(new Long(id));
+      }
+      catch (NumberFormatException e)
+      {
+         throw new IllegalArgumentException("Cannot parse id into an long " + id);
+      }
+   }
+
+   public User findUserById(Object id) throws IllegalArgumentException, IdentityException, NoSuchUserException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (id instanceof Long)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+            Map userMap = (Map)session.get(HibernateUserImpl.ENTITY_NAME, (Long)id);
+            if (userMap == null)
+            {
+               throw new NoSuchUserException("No user found for " + id);
+            }
+            return new HibernateUserImpl(getSessionFactory(),userMap);
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot find user by id " + id;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("The id is not an long : " + id);
+      }
+   }
+
+   public User createUser(String userName, String password) throws IdentityException
+   {
+      if (userName != null)
+      {
+         try
+         {
+            Map mapUser = new HashMap();
+            mapUser.put(HibernateUserImpl.MAPPING_USER_NAME, userName);
+            mapUser.put(HibernateUserImpl.MAPPING_DYNAMIC_PROPERTY_MAP, new HashMap());
+            mapUser.put(HibernateUserImpl.MAPPING_ROLES, new HashSet());
+            //persist
+            getCurrentSession().save(HibernateUserImpl.ENTITY_NAME, mapUser);
+            //create wrapper
+            HibernateUserImpl user = new HibernateUserImpl(getSessionFactory(), mapUser);
+            user.updatePassword(password);
+            return user;
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot create user " + userName;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("name cannot be null");
+      }
+   }
+
+   public void removeUser(Object id) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      if (id instanceof Long)
+      {
+         try
+         {
+            Session session = getCurrentSession();
+            Map mapUser = (Map)session.load(HibernateUserImpl.ENTITY_NAME, (Serializable)id);
+
+
+            if (mapUser == null)
+            {
+               throw new NoSuchUserException("No such user " + id);
+            }
+            session.delete(HibernateUserImpl.ENTITY_NAME, mapUser);
+            session.flush();
+         }
+         catch (HibernateException e)
+         {
+            String message = "Cannot remove user " + id;
+            log.error(message, e);
+            throw new IdentityException(message, e);
+         }
+      }
+      else
+      {
+         throw new IllegalArgumentException("The id is not an long : " + id);
+      }
+   }
+
+   public Set findUsers(int offset, int limit) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      try
+      {
+         Session session = getCurrentSession();
+         //TODO: Use constants
+         Query query = session.createQuery("from PortalUser");
+         query.setFirstResult(offset);
+         query.setMaxResults(limit);
+         Iterator iterator = query.iterate();
+         return processUsersSet(Tools.toSet(iterator));
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find user range [" + offset + "," + limit + "]";
+         log.error(message, e);
+         throw new IdentityException(message, e);
+      }
+   }
+
+   public Set findUsersFilteredByUserName(String filter, int offset, int limit) throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      try
+      {
+         // Remove all occurences of % and add ours
+         filter = "%" + filter.replaceAll("%", "") + "%";
+
+         //
+         Session session = getCurrentSession();
+         //TODO: use constants
+         Query query = session.createQuery("from PortalUser as u where u.userName like :filter");
+         query.setString("filter", filter);
+         query.setFirstResult(offset);
+         query.setMaxResults(limit);
+         Iterator iterator = query.iterate();
+         return processUsersSet(Tools.toSet(iterator));
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot find user range [" + offset + "," + limit + "]";
+         log.error(message, e);
+         throw new IdentityException(message, e);
+      }
+   }
+
+   public int getUserCount() throws IdentityException
+   {
+      //throw new UnsupportedOperationException("Not yet implemented");
+      try
+      {
+         Session session = getCurrentSession();
+         Query query = session.createQuery("select count(u.key) from PortalUser as u");
+         return ((Number)query.uniqueResult()).intValue();
+      }
+      catch (HibernateException e)
+      {
+         String message = "Cannot count users";
+         log.error(message, e);
+         throw new IdentityException(message, e);
+      }
+   }
+
+   /**
+    * Process Set of Map objects and returns a Set of HibernateUserImpl objects
+    * @param maps
+    * @return Set
+    * @throws IdentityException
+    */
+   private Set processUsersSet(Set maps) throws IdentityException
+   {
+      Set users = new HashSet();
+      for (Iterator iterator1 = maps.iterator(); iterator1.hasNext();)
+      {
+         Map userMap = (Map)iterator1.next();
+         users.add(new HibernateUserImpl(getSessionFactory(),userMap));
+      }
+      return users;
+   }
+
+
+
+   /**
+    * Can be subclasses to provide testing in a non JTA environement.
+    *
+    * @throws IllegalStateException if no session factory is present
+    * @return Session
+    */
+   protected Session getCurrentSession() throws IllegalStateException
+   {
+      return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+
+   }
+
+   protected SessionFactory getSessionFactory() throws IllegalStateException
+   {
+       if (sessionFactory == null)
+      {
+         throw new IllegalStateException("No session factory");
+      }
+      return sessionFactory;//.getCurrentSession();
+   }
+}

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -1,110 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
- * contributors as indicated by the @authors tag. See the                     *
- * copyright.txt in the distribution for a full listing of                    *
- * individual contributors.                                                   *
- *                                                                            *
- * 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.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.db.DBUserImpl;
-import org.jboss.portal.identity2.User;
-import org.jboss.portal.identity2.service.UserProfileModuleService;
-
-import java.util.Map;
-
-/**
- * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
- * @version $Revision: 1.1 $
- */
-public class HibernateUserProfileModuleImpl extends UserProfileModuleService
-{
-   public Object getProperty(User user, String propertyName)
-   {
-      if (user == null)
-      {
-         throw new IllegalArgumentException("User cannot be null");
-      }
-      if (propertyName == null)
-      {
-         throw new IllegalArgumentException("Property name need to have value");
-      }
-
-      DBUserImpl dbUser = null;
-
-      if (user instanceof DBUserImpl)
-      {
-         dbUser = (DBUserImpl)user;
-      }
-      else
-      {
-         throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
-      }
-
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public void setProperty(User user, String propertyName, Object propertyValue)
-   {
-      if (user == null)
-      {
-         throw new IllegalArgumentException("User cannot be null");
-      }
-      if (propertyName == null)
-      {
-         throw new IllegalArgumentException("Property name need to have value");
-      }
-
-      DBUserImpl dbUser = null;
-
-      if (user instanceof DBUserImpl)
-      {
-         dbUser = (DBUserImpl)user;
-      }
-      else
-      {
-         throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
-      }
-
-      //if value is null reset property
-
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   public Map getProperties(User user)
-   {
-      if (user == null)
-      {
-         throw new IllegalArgumentException("User cannot be null");
-      }
-
-      DBUserImpl dbUser = null;
-
-      if (user instanceof DBUserImpl)
-      {
-         dbUser = (DBUserImpl)user;
-      }
-      else
-      {
-         throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
-      }
-
-
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-}

Copied: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java (from rev 5809, trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/HibernateUserProfileModuleImpl.java	2006-12-12 18:42:45 UTC (rev 5809)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/HibernateUserProfileModuleImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,173 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * 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.jboss.portal.identity2.experimental.db;
+
+import org.jboss.portal.identity2.experimental.db.HibernateUserImpl;
+import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity2.service.UserProfileModuleService;
+import org.hibernate.SessionFactory;
+import org.hibernate.Session;
+
+import javax.naming.InitialContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class HibernateUserProfileModuleImpl extends UserProfileModuleService
+{
+
+   /** . */
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(HibernateUserProfileModuleImpl.class);
+   /** . */
+   protected SessionFactory sessionFactory;
+
+   /** . */
+   protected String sessionFactoryJNDIName;
+
+   protected void startService() throws Exception
+   {
+      //
+      sessionFactory = (SessionFactory)new InitialContext().lookup(sessionFactoryJNDIName);
+
+      super.startService();
+
+   }
+
+   protected void stopService() throws Exception
+   {
+      //
+      sessionFactory = null;
+      super.stopService();
+   }
+
+//   public SessionFactory getSessionFactory()
+//   {
+//      return sessionFactory;
+//   }
+
+   public String getSessionFactoryJNDIName()
+   {
+      return sessionFactoryJNDIName;
+   }
+
+   public void setSessionFactoryJNDIName(String sessionFactoryJNDIName)
+   {
+      this.sessionFactoryJNDIName = sessionFactoryJNDIName;
+   }
+
+   public Object getProperty(User user, String propertyName)
+   {
+      if (user == null)
+      {
+         throw new IllegalArgumentException("User cannot be null");
+      }
+      if (propertyName == null)
+      {
+         throw new IllegalArgumentException("Property name need to have value");
+      }
+
+      HibernateUserImpl dbUser = null;
+
+      if (user instanceof HibernateUserImpl)
+      {
+         dbUser = (HibernateUserImpl)user;
+      }
+      else
+      {
+         throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
+      }
+
+      throw new UnsupportedOperationException("Not yet implemented");
+   }
+
+   public void setProperty(User user, String propertyName, Object propertyValue)
+   {
+      if (user == null)
+      {
+         throw new IllegalArgumentException("User cannot be null");
+      }
+      if (propertyName == null)
+      {
+         throw new IllegalArgumentException("Property name need to have value");
+      }
+
+      HibernateUserImpl dbUser = null;
+
+      if (user instanceof HibernateUserImpl)
+      {
+         dbUser = (HibernateUserImpl)user;
+      }
+      else
+      {
+         throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
+      }
+
+      //if value is null reset property
+
+      throw new UnsupportedOperationException("Not yet implemented");
+   }
+
+   public Map getProperties(User user)
+   {
+      if (user == null)
+      {
+         throw new IllegalArgumentException("User cannot be null");
+      }
+
+      HibernateUserImpl dbUser = null;
+
+      if (user instanceof HibernateUserImpl)
+      {
+         dbUser = (HibernateUserImpl)user;
+      }
+      else
+      {
+         throw new IllegalArgumentException("This UserProfileModule implementation support only DBDBUserImpl objects");
+      }
+
+
+      throw new UnsupportedOperationException("Not yet implemented");
+   }
+
+   /**
+    * Can be subclasses to provide testing in a non JTA environement.
+    *
+    * @throws IllegalStateException if no session factory is present
+    */
+   protected Session getCurrentSession() throws IllegalStateException
+   {
+      return getSessionFactory().getCurrentSession();//.getSession(EntityMode.MAP);
+
+   }
+
+   protected SessionFactory getSessionFactory() throws IllegalStateException
+   {
+       if (sessionFactory == null)
+      {
+         throw new IllegalStateException("No session factory");
+      }
+      return sessionFactory;//.getCurrentSession();
+   }
+}

Added: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/IdentitySessionFactoryBinder.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/IdentitySessionFactoryBinder.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/IdentitySessionFactoryBinder.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -0,0 +1,119 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* 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.jboss.portal.identity2.experimental.db;
+
+import org.jboss.portal.jems.hibernate.SessionFactoryBinder;
+import org.jboss.portal.identity2.info.ProfileInfo;
+import org.jboss.portal.identity2.config.metadata.profile.ProfileMetaData;
+import org.jboss.portal.identity2.config.metadata.ConfigurationParser;
+import org.jboss.portal.identity2.config.info.ProfileInfoSupport;
+
+/**
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentitySessionFactoryBinder extends SessionFactoryBinder
+{
+
+   private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(IdentitySessionFactoryBinder.class);
+
+   private String profileConfigFile;
+
+   private String mappingTemplateFile;
+
+   private String mappingOutputFile;
+
+   private String mappingPattern;
+
+   private ProfileInfo profileInfo;
+
+   protected void createService() throws Exception
+   {
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+
+
+      //parse profile config
+      ProfileMetaData meta = ConfigurationParser.parseProfileConfiguration(getProfileConfigFile());
+      profileInfo = new ProfileInfoSupport(meta);
+
+      //process files
+      HibernateHelper.generateProfileMappings(getMappingTemplateFile(), getMappingOutputFile(), getMappingPattern(), profileInfo, tcl);
+
+      //create configuration
+      super.createService();
+
+      //set MAP entity mode
+      config.setProperty("hibernate.default_entity_mode","dynamic-map");
+
+      //inject generated mappings into configuration
+      config.addFile(getMappingOutputFile());
+
+
+   }
+
+
+   protected void startService() throws Exception
+   {
+      //super.startService();    //To change body of overridden methods use File | Settings | File Templates.
+   }
+
+
+   public String getProfileConfigFile()
+   {
+      return profileConfigFile;
+   }
+
+   public void setProfileConfigFile(String profileConfigFile)
+   {
+      this.profileConfigFile = profileConfigFile;
+   }
+
+   public String getMappingTemplateFile()
+   {
+      return mappingTemplateFile;
+   }
+
+   public void setMappingTemplateFile(String mappingTemplateFile)
+   {
+      this.mappingTemplateFile = mappingTemplateFile;
+   }
+
+   public String getMappingOutputFile()
+   {
+      return mappingOutputFile;
+   }
+
+   public void setMappingOutputFile(String mappingOutputFile)
+   {
+      this.mappingOutputFile = mappingOutputFile;
+   }
+
+   public String getMappingPattern()
+   {
+      return mappingPattern;
+   }
+
+   public void setMappingPattern(String mappingPattern)
+   {
+      this.mappingPattern = mappingPattern;
+   }
+}

Deleted: trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/ProfileMapImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity2/db/ProfileMapImpl.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/identity2/experimental/db/ProfileMapImpl.java	2006-12-13 15:13:33 UTC (rev 5829)
@@ -1,275 +0,0 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* 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.jboss.portal.identity2.db;
-
-import org.jboss.portal.identity2.ProfileMap;
-import org.jboss.portal.identity2.db.DBUserImpl;
-
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collection;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-
-/**
- * A mutable map that expose user properties.
- *
- * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
- * @version $Revision: 5448 $
- */
-public class ProfileMapImpl implements ProfileMap
-{
-
-   /** . */
-   private DBUserImpl user;
-
-   public ProfileMapImpl(DBUserImpl user)
-   {
-      if (user == null)
-      {
-         throw new IllegalArgumentException();
-      }
-      this.user = user;
-   }
-
-   public boolean isReadOnly(Object key)
-   {
-      if (key == null)
-      {
-         return false;
-      }
-      if (key instanceof String == false)
-      {
-         throw new ClassCastException("Key must be a string");
-      }
-      DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)DBUserImpl.ACCESSORS.get(key);
-      return accessor != null && !accessor.isWritable();
-   }
-
-   public int size()
-   {
-      return DBUserImpl.ACCESSORS.size() + user.getDynamic().size();
-   }
-
-   public boolean isEmpty()
-   {
-      return false;
-   }
-
-   /** @throws ClassCastException if the key is not an instance of string */
-   public boolean containsKey(Object key) throws ClassCastException
-   {
-      if (key == null)
-      {
-         return false;
-      }
-      if (key instanceof String == false)
-      {
-         throw new ClassCastException("Key must be a string");
-      }
-      DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)DBUserImpl.ACCESSORS.get(key);
-      if (accessor != null)
-      {
-         return true;
-      }
-      return user.getDynamic().containsKey(key);
-   }
-
-   /** @throws ClassCastException if the value is not an instance of string */
-   public boolean containsValue(Object value) throws ClassCastException
-   {
-      if (value == null)
-      {
-         throw new NullPointerException("Key cannot be null");
-      }
-      if (value instanceof String == false)
-      {
-         throw new ClassCastException("Value must be a string");
-      }
-      for (Iterator i = DBUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
-      {
-         DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)i.next();
-         Object value2 = accessor.get(user);
-         if (value == value2 || value.equals(value2))
-         {
-            return true;
-         }
-      }
-      return user.getDynamic().containsValue(value);
-   }
-
-   /** @throws ClassCastException if the key is not an instance of string */
-   public Object get(Object key)
-   {
-      if (key == null)
-      {
-         return null;
-      }
-      if (key instanceof String == false)
-      {
-         throw new ClassCastException("Key must be a string");
-      }
-      DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)DBUserImpl.ACCESSORS.get(key);
-      if (accessor != null)
-      {
-         return accessor.get(user);
-      }
-      return user.getDynamic().get(key);
-   }
-
-   /**
-    * Put a value in the dynamic map.
-    * <p/>
-    * If the key is not an instance of string then an IllegalArgumentException is thrown. If the value is mapped to an
-    * accessor of a non writable field then an IllegalArgumentException is thrown. If the value is mapped to an accessor
-    * of a non nullable field and the field is null then an IllegalArgumentException is thrown.
-    *
-    * @throws IllegalArgumentException
-    */
-   public Object put(Object key, Object newValue) throws IllegalArgumentException
-   {
-      if (key == null)
-      {
-         return null;
-      }
-      if (key instanceof String == false)
-      {
-         throw new ClassCastException("Key is not a String");
-      }
-      DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)DBUserImpl.ACCESSORS.get(key);
-      if (accessor != null)
-      {
-         if (newValue == null && !accessor.isNullable())
-         {
-            throw new NullPointerException("Key " + key + " is not nullable");
-         }
-         if (!accessor.isWritable())
-         {
-            throw new IllegalArgumentException("Key " + key + " is not modifiable");
-         }
-         else
-         {
-            Object oldValue = accessor.get(user);
-            accessor.set(user, (String)newValue);
-            return oldValue;
-         }
-      }
-      if (newValue instanceof String == false)
-      {
-         throw new ClassCastException("Dynamic value must be a string");
-      }
-      return user.getDynamic().put(key, newValue);
-   }
-
-   /**
-    * Only affect dynamic properties, otherwise it throws an IllegalArgumentException.
-    *
-    * @throws IllegalArgumentException if the key is a not a dynamic property
-    */
-   public Object remove(Object key) throws IllegalArgumentException
-   {
-      if (key instanceof String == false)
-      {
-         throw new ClassCastException("Key is not a String");
-      }
-      DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)DBUserImpl.ACCESSORS.get(key);
-      if (accessor != null)
-      {
-         throw new IllegalArgumentException("Key " + key + " is not removable");
-      }
-      return user.getDynamic().remove(key);
-   }
-
-   /** Clear only dynamic properties. */
-   public void clear()
-   {
-      user.getDynamic().clear();
-   }
-
-   public Set keySet()
-   {
-      // Get
-      Set set = new HashSet(size());
-
-      //
-      set.addAll(user.getDynamic().keySet());
-      set.addAll(DBUserImpl.ACCESSORS.keySet());
-      return set;
-   }
-
-   public Collection values()
-   {
-      ArrayList collection = new ArrayList(size());
-      for (Iterator i = DBUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
-      {
-         DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)i.next();
-         collection.add(accessor.get(user));
-      }
-      collection.addAll(user.getDynamic().values());
-      return collection;
-   }
-
-   /** Returns an immutable collection of entries. */
-   public Set entrySet()
-   {
-      Map copy = new HashMap(user.getDynamic());
-      for (Iterator i = DBUserImpl.ACCESSORS.values().iterator(); i.hasNext();)
-      {
-         DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)i.next();
-         copy.put(accessor.getPropertyName(), accessor.get(user));
-      }
-      return Collections.unmodifiableMap(copy).entrySet();
-   }
-
-   public void putAll(Map map)
-   {
-      // todo : check all properties ok with changes before proceeding
-      for (Iterator i = map.entrySet().iterator(); i.hasNext();)
-      {
-         Entry entry = (Entry)i.next();
-         Object key = entry.getKey();
-         if (key instanceof String)
-         {
-            Object value = entry.getValue();
-            DBUserImpl.PropertyAccessor accessor = (DBUserImpl.PropertyAccessor)DBUserImpl.ACCESSORS.get(key);
-            if (accessor != null)
-            {
-               if (accessor.isWritable())
-               {
-                  accessor.set(user, (String)value);
-               }
-               else
-               {
-                  // julien : Do something better ?
-               }
-            }
-            else
-            {
-               user.getDynamic().put(key, value);
-            }
-         }
-      }
-   }
-}




More information about the portal-commits mailing list