Author: taylor
Date: Wed Nov 30 13:05:10 2005
New Revision: 350051

URL: http://svn.apache.org/viewcvs?rev=350051&view=rev
Log:
cleanup of Portal Administrator
* handle failures 
* default admin user

Modified:
    
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
    
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
    portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties

Modified: 
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java?rev=350051&r1=350050&r2=350051&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
 (original)
+++ 
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/administration/PortalAdministrationImpl.java
 Wed Nov 30 13:05:10 2005
@@ -31,6 +31,8 @@
 import javax.security.auth.Subject;
 
 import org.apache.commons.configuration.Configuration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.exception.JetspeedException;
@@ -72,6 +74,8 @@
 
 public class PortalAdministrationImpl implements PortalAdministration
 {
+    private final static Log log = 
LogFactory.getLog(PortalAdministrationImpl.class);
+    
     /** administration services */
     protected Configuration config;
     protected UserManager userManager;
@@ -92,6 +96,8 @@
     protected Map defaultRules;
     /** name of PSML Folder Template to clone from when registering new user */
     protected String folderTemplate;
+    /** default administrative user */
+    protected String adminUser;
         
     public PortalAdministrationImpl( UserManager userManager,
                                      RoleManager roleManager,
@@ -135,6 +141,11 @@
         }
         this.folderTemplate = 
             
config.getString(PortalConfigurationConstants.PSML_TEMPLATE_FOLDER);
+        this.adminUser = 
config.getString(PortalConfigurationConstants.USERS_DEFAULT_ADMIN);
+        
+        System.out.println("admin user = " + adminUser);
+        System.out.println("roles = " + defaultRoles);
+        System.out.println("folder template = " + folderTemplate);
     }
     
     public void registerUser(String userName, String password)
@@ -243,7 +254,7 @@
             final String innerUserName = userName;
             final PageManager innerPageManager = pageManager;
             final String innerUser = userName;
-            User powerUser = userManager.getUser("admin"); // TODO: DO NOT 
HARD CODE ADMIN USER
+            User powerUser = userManager.getUser(this.adminUser);
             JetspeedException pe = (JetspeedException) 
Subject.doAsPrivileged(powerUser.getSubject(), new PrivilegedAction()
                 {
                     public Object run() 
@@ -274,12 +285,23 @@
                 
             if(pe != null)
             {
+                // rollback user creation and cascade roles, groups, etc
+                try
+                {
+                    userManager.removeUser(userName);
+                }
+                catch (Exception e)
+                {
+                    log.error("Registration Error: Failed to rollback user " + 
userName);
+                }
+                log.error("Registration Error: Failed to create user folders 
for " + userName + ", " + pe.toString());
                 throw pe;
             }
                         
         }
         catch (Exception e) 
         {
+            log.error("Registration Error: Failed to create registered user " 
+ userName + ", " + e.toString());
             throw new RegistrationException(e); 
         }        
     }

Modified: 
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java?rev=350051&r1=350050&r2=350051&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
 (original)
+++ 
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/administration/PortalConfigurationConstants.java
 Wed Nov 30 13:05:10 2005
@@ -64,4 +64,7 @@
     /** Registration default profiling rules assigned during registration or 
new user creation **/        
     static final String REGISTRATION_RULES_DEFAULT = 
"registration.rules.default";
     
+    /** Users */
+    static final String USERS_DEFAULT_ADMIN = "default.admin.user";
+    static final String USERS_DEFAULT_GUEST = "default.user.principal";
 }

Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties?rev=350051&r1=350050&r2=350051&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties 
(original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/conf/jetspeed.properties Wed 
Nov 30 13:05:10 2005
@@ -64,7 +64,7 @@
 # if no user has been setup, default.user.principal will be
 # automatically added via HttpRequestContext.setUserPrincpal()
 default.user.principal=guest
-
+default.admin.user=admin
 
 # -------------------------------------------------------------------
 #  L O G 4 J - L O G G I N G



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to