Author: dimuthul
Date: Sat Feb 16 18:20:57 2008
New Revision: 13823

Log:

Adding UserProfile stuff.



Added:
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/UserProfileAdmin.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/UserProfileDAO.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserProfileDO.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserProfileValuesDO.java

Added: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/UserProfileAdmin.java
==============================================================================
--- (empty file)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/UserProfileAdmin.java
    Sat Feb 16 18:20:57 2008
@@ -0,0 +1,39 @@
+package org.wso2.solutions.identity.admin;
+
+import org.wso2.solutions.identity.IdentityProviderException;
+import org.wso2.solutions.identity.persistence.IPPersistenceManager;
+import org.wso2.solutions.identity.persistence.dataobject.UserProfileDO;
+import org.wso2.solutions.identity.persistence.dataobject.UserProfileValuesDO;
+
+public class UserProfileAdmin {
+
+    IPPersistenceManager dbman = null;
+
+    public UserProfileAdmin() throws IdentityProviderException {
+        dbman = IPPersistenceManager.getPersistanceManager();
+    }
+
+    public void addUserProfile(UserProfileDO userProfile)
+            throws IdentityProviderException {
+        dbman.create(userProfile);
+    }
+    
+    public void deleteUserProfile(String userId, String profileName)
+            throws IdentityProviderException {
+        UserProfileDO userProfile = dbman.getUserProfile(userId, profileName);
+        dbman.delete(userProfile);
+    }
+       
+    public UserProfileDO[] getUserProfiles(String userId){
+        return dbman.getUserProfiles(userId);
+    } 
+    
+    public UserProfileValuesDO[] getUserProfileValues(String userId,String 
profileName){
+        return dbman.getUserProfileValues(userId, profileName);
+    }
+    
+    public void setUserProfileValues(UserProfileValuesDO[] values){
+        //TODO
+    }
+    
+}

Added: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/UserProfileDAO.java
==============================================================================
--- (empty file)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dao/UserProfileDAO.java
    Sat Feb 16 18:20:57 2008
@@ -0,0 +1,97 @@
+package org.wso2.solutions.identity.persistence.dao;
+
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.wso2.solutions.identity.persistence.HibernateConfig;
+import org.wso2.solutions.identity.persistence.dataobject.UserProfileDO;
+import org.wso2.solutions.identity.persistence.dataobject.UserProfileValuesDO;
+
+
+
+public class UserProfileDAO
+        extends BaseDAO {
+
+    public UserProfileDAO(HibernateConfig config) {
+        super(config);
+    }
+
+    public UserProfileDO[] getUserProfiles(String userId) {
+        String username = null;
+        Session session = hbConfig.getCurrentSession();
+        Transaction tx = session.beginTransaction();
+        UserProfileDO[] profileDOs = new UserProfileDO[0];
+        try {
+            String stmt = "from UserProfileDO as profile where profile.userId 
= '"
+                    + userId + "'";
+
+            Query query = session.createQuery(stmt);
+            List lst = query.list();
+            profileDOs = (UserProfileDO[]) lst
+                    .toArray(new UserProfileDO[lst.size()]);
+        } catch (Throwable e) {
+            tx.rollback();
+            String msg = messages
+                    .getMessage("errorQuerryingRegisteredInfoCardInfo");
+            log.error(msg, e);
+            throw new RuntimeException(msg, e);
+        } finally {
+            hbConfig.closeSession();
+        }
+
+        return profileDOs;
+    }
+
+    public UserProfileDO getUserProfile(String userId, String profileName) {
+        String username = null;
+        Session session = hbConfig.getCurrentSession();
+        Transaction tx = session.beginTransaction();
+        UserProfileDO profileDO = null;
+        try {
+            String stmt = "from UserProfileDO as profile where profile.userId 
= '"
+                    + userId + "' and profile.profileName = '"+profileName+"'";
+
+            Query query = session.createQuery(stmt);
+            profileDO = (UserProfileDO) query.uniqueResult();
+        } catch (Throwable e) {
+            tx.rollback();
+            String msg = messages
+                    .getMessage("errorQuerryingRegisteredInfoCardInfo");
+            log.error(msg, e);
+            throw new RuntimeException(msg, e);
+        } finally {
+            hbConfig.closeSession();
+        }
+
+        return profileDO;
+    }
+    
+    public UserProfileValuesDO[] getUserProfileValues(String userId,String 
profileName){
+        String username = null;
+        Session session = hbConfig.getCurrentSession();
+        Transaction tx = session.beginTransaction();
+        UserProfileValuesDO[] profileValues = new UserProfileValuesDO[0];
+        try {
+            String stmt = "from UserProfileValuesDO as value where 
value.profile.userId = '"
+                    + userId + "' and value.profile.profileName = 
'"+profileName+"'";
+
+            Query query = session.createQuery(stmt);
+            List lst = query.list();
+            profileValues = (UserProfileValuesDO[])lst.toArray(new 
UserProfileValuesDO[lst.size()]);
+            
+        } catch (Throwable e) {
+            tx.rollback();
+            String msg = messages
+                    .getMessage("errorQuerryingRegisteredInfoCardInfo");
+            log.error(msg, e);
+            throw new RuntimeException(msg, e);
+        } finally {
+            hbConfig.closeSession();
+        }
+
+        return profileValues;
+    }
+
+}

Added: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserProfileDO.java
==============================================================================
--- (empty file)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserProfileDO.java
      Sat Feb 16 18:20:57 2008
@@ -0,0 +1,47 @@
+package org.wso2.solutions.identity.persistence.dataobject;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class UserProfileDO  extends AbstractDataObject {
+
+    private String userId = null;
+    private String profileName = null;
+    private boolean isDefault = false;
+    private Set profileProperties = new HashSet();
+    
+    public String getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+    
+    public String getProfileName() {
+        return profileName;
+    }
+    
+    public void setProfileName(String profileName) {
+        this.profileName = profileName;
+    }
+
+    public boolean getIsDefault() {
+        return isDefault;
+    }
+
+    public void setIsDefault(boolean isDefault) {
+        this.isDefault = isDefault;
+    }
+
+    public Set getProfileProperties() {
+        return profileProperties;
+    }
+
+    public void setProfileProperties(Set profileProperties) {
+        this.profileProperties = profileProperties;
+    }
+    
+    
+       
+}

Added: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserProfileValuesDO.java
==============================================================================
--- (empty file)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserProfileValuesDO.java
        Sat Feb 16 18:20:57 2008
@@ -0,0 +1,29 @@
+package org.wso2.solutions.identity.persistence.dataobject;
+
+public class UserProfileValuesDO  extends AbstractDataObject {
+    
+    private UserProfileDO profile = null;
+    private String attributeName = null;
+    private String attributeValue = null;
+    
+    public UserProfileDO getProfile() {
+        return profile;
+    }
+    public void setProfile(UserProfileDO profile) {
+        this.profile = profile;
+    }
+    public String getAttributeName() {
+        return attributeName;
+    }
+    public void setAttributeName(String attributeName) {
+        this.attributeName = attributeName;
+    }
+    public String getAttributeValue() {
+        return attributeValue;
+    }
+    public void setAttributeValue(String attributeValue) {
+        this.attributeValue = attributeValue;
+    }
+      
+
+}

_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev

Reply via email to