Author: dimuthul
Date: Fri Jan 11 01:15:28 2008
New Revision: 12138

Log:

Fixing issue IDENTITY-72


Modified:
   
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/SetDefaultUserStoreAction.java
   
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserStoreAction.java
   trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
   
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/realmconfigurations.jsp
   trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/userstore.jsp
   trunk/solutions/identity/modules/identity-provider/conf/wso2identity.hbm.xml
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/RealmConfigAdmin.java
   
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserTrustedRPDO.java

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/SetDefaultUserStoreAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/SetDefaultUserStoreAction.java
  (original)
+++ 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/SetDefaultUserStoreAction.java
  Fri Jan 11 01:15:28 2008
@@ -21,14 +21,13 @@
 import org.wso2.solutions.identity.IdentityProviderConstants;
 import org.wso2.solutions.identity.IdentityProviderException;
 import org.wso2.solutions.identity.admin.RealmConfigAdmin;
-import org.wso2.solutions.identity.admin.STSConfigAdmin;
 import org.wso2.solutions.identity.i18n.Messages;
 
 public class SetDefaultUserStoreAction extends ManagedAction {
 
     private static final long serialVersionUID = 5197582050072207667L;
 
-    private static Log log = LogFactory.getLog(STSConfigAdmin.class);
+    private static Log log = 
LogFactory.getLog(SetDefaultUserStoreAction.class);
 
     private final static Messages messages = Messages
             .getInstance(IdentityProviderConstants.RESOURCES);

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserStoreAction.java
==============================================================================
--- 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserStoreAction.java
        (original)
+++ 
trunk/solutions/identity/modules/admin-ui/src/main/java/org/wso2/solutions/identity/admin/ui/action/ShowUserStoreAction.java
        Fri Jan 11 01:15:28 2008
@@ -18,11 +18,12 @@
 
 import java.util.Set;
 
-import org.wso2.solutions.identity.persistence.IPPersistenceManager;
+import org.wso2.solutions.identity.admin.RealmConfigAdmin;
 import org.wso2.solutions.identity.persistence.dataobject.RealmConfigurationDO;
 import org.wso2.usermanager.readwrite.DefaultRealm;
 
-public class ShowUserStoreAction extends ManagedAction {
+public class ShowUserStoreAction
+        extends ManagedAction {
 
     private static final long serialVersionUID = 8265273506039256750L;
 
@@ -33,9 +34,11 @@
     private String configName;
 
     private boolean showEditStore = false;
-    
+
     private boolean showStoreProperties = false;
 
+    private boolean deletableStore = false;
+
     public String getRealmClassName() {
         return realmClassName;
     }
@@ -46,21 +49,27 @@
             return ERROR;
         }
 
-        IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
-        RealmConfigurationDO config = 
db.getRealmConfiguration(this.configName);
+        RealmConfigAdmin admin = new RealmConfigAdmin();
+        RealmConfigurationDO config = 
admin.getRealmConfiguration(this.configName);
         realmClassName = config.getRealm().getClassName();
         configProperties = config.getConfigProperties();
         if (configProperties.size() == 0) {
             this.addInfoMessage(getText("no_user_store_config"));
             this.showEditStore = false;
             this.showStoreProperties = false;
-        } else if(realmClassName.equals(DefaultRealm.class.getName())){
+        } else if (realmClassName.equals(DefaultRealm.class.getName())) {
             this.showEditStore = false;
             this.showStoreProperties = true;
-        }else {
+        } else {
             this.showEditStore = true;
             this.showStoreProperties = true;
         }
+
+        if ((!config.isEffective())
+                && (!realmClassName.equals(DefaultRealm.class.getName()))) {
+            this.deletableStore = true;
+        }
+
         this.loadMessages();
         return SUCCESS;
     }
@@ -89,4 +98,8 @@
         this.showStoreProperties = showStoreProperties;
     }
 
+    public boolean isDeletableStore() {
+        return deletableStore;
+    }
+
 }

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml
==============================================================================
--- trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml     
(original)
+++ trunk/solutions/identity/modules/admin-ui/src/main/resources/struts.xml     
Fri Jan 11 01:15:28 2008
@@ -175,6 +175,13 @@
                        <result name="success" 
type="redirect">ShowRealmConfigurations.action</result>
                        <result name="error" 
type="redirect">ShowRealmConfigurations.action</result>
                </action>
+               
+               <action name="DeleteUserStore" 
class="org.wso2.solutions.identity.admin.ui.action.DeleteUserStoreAction">
+                       <result name="success" 
type="redirect">ShowRealmConfigurations.action</result>
+                       <result name="error" 
type="redirect">ShowRealmConfigurations.action</result>
+               </action>
+               
+                
 
                <!--  User Store configuration : END -->
 

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/realmconfigurations.jsp
==============================================================================
--- 
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/realmconfigurations.jsp
       (original)
+++ 
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/realmconfigurations.jsp
       Fri Jan 11 01:15:28 2008
@@ -44,17 +44,19 @@
 
 
                                <table cellpadding="0" cellspacing="0" 
border="0" class="data-table">
-                                       <tr><th>Configuration 
name</th><th>Realm Class</th><th>Enabled</th></tr>
+                                       <tr><th>Configuration 
name</th><th>Realm Class</th><th>Enabled</th><th>Delete</th></tr>
                                
                                        <s:iterator value="realmConfigurations">
                                        
                                                <s:url id="showRealmConfigUrl" 
namespace="/" action="ShowUserStore">
                                                <s:param name="configName" 
value="%{name}" />
                                                </s:url>
+                                               
                                                <tr><td><s:a 
href="%{showRealmConfigUrl}"><s:property value="name"/></s:a></td>
+                                               
                                                <td><s:property 
value="realm"/><br/></td>
                                                <s:if test="%{effective}">
-                                                       <td><s:property 
value="effective"/></td>        
+                                                       <td><s:property 
value="effective"/></td>
                                                </s:if>
                                                <s:else>
                                                        <s:url 
id="setDefaultUserStore" namespace="/" action="SetDefaultUserStore">

Modified: 
trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/userstore.jsp
==============================================================================
--- trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/userstore.jsp 
(original)
+++ trunk/solutions/identity/modules/admin-ui/src/main/webapp/jsp/userstore.jsp 
Fri Jan 11 01:15:28 2008
@@ -60,9 +60,15 @@
                                        <s:if test="showEditStore">
                                                <s:a 
href="%{showRealmConfigUrl}">Edit</s:a>
                                        </s:if>
-                                  
+                                       
                                </s:if>
                                
+                               <s:if test="deletableStore">
+                                       <s:url id="deleteRealmConfigUrl" 
namespace="/" action="DeleteUserStore">
+                                       <s:param name="configName" 
value="configName" />
+                                       </s:url>
+                                       <s:a 
href="%{deleteRealmConfigUrl}">Delete</s:a>
+                           </s:if>
                        </td>
                </tr>
        </table>

Modified: 
trunk/solutions/identity/modules/identity-provider/conf/wso2identity.hbm.xml
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/conf/wso2identity.hbm.xml    
    (original)
+++ 
trunk/solutions/identity/modules/identity-provider/conf/wso2identity.hbm.xml    
    Fri Jan 11 01:15:28 2008
@@ -145,7 +145,7 @@
         <property name="name" column="name" not-null="true" unique="true"/>
                <property name="effective" column="effective" not-null="true"/>
         <many-to-one name="realm" column="realm_id" not-null="true" 
lazy="false"/>
-       <set name="configProperties"  lazy="false">
+           <set name="configProperties" lazy="false" cascade="all">
             <key column="realm_config_id"/>
             <one-to-many 
class="org.wso2.solutions.identity.persistence.dataobject.RealmConfigurationPropertyDO"/>
         </set>
@@ -162,8 +162,8 @@
         <property name="lastUpdatedTime" type="timestamp" 
column="c_last_updated" not-null="true"/>
 
         <property name="name" column="name" not-null="true"/>
-       <property name="value" column="value" not-null="true"/>
-        <many-to-one name="config" column="realm_config_id" not-null="true"  
lazy="false"/>
+           <property name="value" column="value" not-null="true"/>
+        <many-to-one name="config" column="realm_config_id" lazy="false"/>
    </class>
 
     <!-- #################################################### -->

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/RealmConfigAdmin.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/RealmConfigAdmin.java
    (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/admin/RealmConfigAdmin.java
    Fri Jan 11 01:15:28 2008
@@ -64,7 +64,7 @@
         // Now reset claim mappings
         ClaimsAdmin claimsAdmin = new ClaimsAdmin();
         claimsAdmin.resetClaimMappings();
-        
+
         RealmConfigurationDO effectiveConfig = db
                 .getEffectiveRealmConfiguration();
         effectiveConfig.setEffective(false);
@@ -73,26 +73,25 @@
         config.setEffective(true);
         db.update(config);
 
-        
-        //Disable user registration for WSAS sample, JDBC and LDAP realms
+        // Disable user registration for WSAS sample, JDBC and LDAP realms
         String realmClassName = config.getRealm().getClassName();
-        if(realmClassName.equals(JDBCRealm.class.getName()) ||
-               realmClassName.equals(LDAPRealm.class.getName()) ||
-               realmClassName.equals(WSASRealm.class.getName())) {
+        if (realmClassName.equals(JDBCRealm.class.getName())
+                || realmClassName.equals(LDAPRealm.class.getName())
+                || realmClassName.equals(WSASRealm.class.getName())) {
             ParameterAdmin paramAdmin = new ParameterAdmin();
-            if(paramAdmin.getParameter(
-                    
IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION) 
-                        != null) {
-                    paramAdmin.removeParam(
-                            
IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION);
+            if (paramAdmin
+                    
.getParameter(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION) != 
null) {
+                paramAdmin
+                        
.removeParam(IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION);
             }
             return true;
         } else if (realmClassName.equals(DefaultRealm.class.getName())) {
             ParameterAdmin paramAdmin = new ParameterAdmin();
-            paramAdmin.createOrUpdatearameter(
-                    
IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION,
-                    null);
-            
+            paramAdmin
+                    .createOrUpdatearameter(
+                            
IdentityProviderConstants.PARAM_NAME_ALLOW_USER_REGISTRATION,
+                            null);
+
         }
         return false;
     }
@@ -108,10 +107,17 @@
             throws IdentityProviderException {
         IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
         Iterator ite = properties.iterator();
-        while(ite.hasNext()){
-            RealmConfigurationPropertyDO rdo = 
(RealmConfigurationPropertyDO)ite.next();
+        while (ite.hasNext()) {
+            RealmConfigurationPropertyDO rdo = (RealmConfigurationPropertyDO) 
ite
+                    .next();
             db.update(rdo);
         }
     }
 
+    public void deleteRealmConfiguration(RealmConfigurationDO config)
+            throws IdentityProviderException {
+        IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
+        db.delete(config);
+    }
+
 }

Modified: 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserTrustedRPDO.java
==============================================================================
--- 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserTrustedRPDO.java
    (original)
+++ 
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/persistence/dataobject/UserTrustedRPDO.java
    Fri Jan 11 01:15:28 2008
@@ -8,7 +8,6 @@
     private UserPersonalRelyingPartyIdentifier identifier = null;
 
     private Set ppidValues;
-    
   
 
     public UserPersonalRelyingPartyIdentifier getIdentifier() {

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

Reply via email to