roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r424422 - in /incubator/roller/branches/roller_3.0: src/org/apache/roller/ui/admin/struts/actions/UserAdminAction.java web/WEB-INF/jsps/admin/UserAdmin.jsp
Date Fri, 21 Jul 2006 19:06:35 GMT
Author: snoopdave
Date: Fri Jul 21 12:06:34 2006
New Revision: 424422

URL: http://svn.apache.org/viewvc?rev=424422&view=rev
Log:
Fixing incorrect titles

Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/UserAdminAction.java
    incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/admin/UserAdmin.jsp

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/UserAdminAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/UserAdminAction.java?rev=424422&r1=424421&r2=424422&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/UserAdminAction.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/UserAdminAction.java
Fri Jul 21 12:06:34 2006
@@ -1,20 +1,20 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-*  contributor license agreements.  The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.  For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
 
 package org.apache.roller.ui.admin.struts.actions;
 
@@ -53,332 +53,298 @@
 /////////////////////////////////////////////////////////////////////////////
 /**
  * Actions for administering a user allow user query, edit, and delete of users.
- * 
+ *
  * @struts.action name="userAdminForm" path="/roller-ui/admin/user"
  *  	scope="request" parameter="method"
- * 
+ *
  * @struts.action-forward name="adminUser.page" path=".UserAdmin"
  */
-public final class UserAdminAction extends UserBaseAction
-{
-    private static Log mLogger = 
-        LogFactory.getFactory().getInstance(UserAdminAction.class);
-
+public final class UserAdminAction extends UserBaseAction {
+    private static Log mLogger =
+            LogFactory.getFactory().getInstance(UserAdminAction.class);
+    
     //-----------------------------------------------------------------------
-    /** 
-     * Show query for user page or, if userName specified in request, 
+    /**
+     * Show query for user page or, if userName specified in request,
      * show the admin user page for the specified user.
      */
     public ActionForward edit(
-        ActionMapping       mapping,
-        ActionForm          actionForm,
-        HttpServletRequest  request,
-        HttpServletResponse response)
-        throws IOException, ServletException
-    {
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException {
         ActionForward forward = mapping.findForward("adminUser.page");
-        try
-        {
+        try {
             UserData user = null;
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
             RollerSession rollerSession = RollerSession.getRollerSession(request);
-            if (rollerSession.isGlobalAdminUser() )
-            {
+            if (rollerSession.isGlobalAdminUser() ) {
                 UserAdminForm userForm = (UserAdminForm)actionForm;
-                UserManager mgr = RollerFactory.getRoller().getUserManager(); 
-                if (userForm!=null 
-                      && userForm.getUserName()!=null && !userForm.isNewUser())
-                {
+                UserManager mgr = RollerFactory.getRoller().getUserManager();
+                if (userForm!=null
+                        && userForm.getUserName()!=null && !userForm.isNewUser())
{
                     ActionMessages msgs = getErrors(request);
                     msgs = (msgs == null) ? new ActionMessages() : msgs;
-                    user = mgr.getUserByUserName(userForm.getUserName(), null);         
          
-                    if (user != null)
-                    {
-                        userForm.copyFrom(user, request.getLocale());                   
    
+                    user = mgr.getUserByUserName(userForm.getUserName(), null);
+                    if (user != null) {
+                        userForm.copyFrom(user, request.getLocale());
                         // User must set new password twice
                         userForm.setPasswordText(null);
                         userForm.setPasswordConfirm(null);
-                    }
-                    else
-                    {
+                    } else {
                         msgs.add(ActionErrors.GLOBAL_ERROR,
-                            new ActionMessage("userAdmin.invalidNewUserName"));
+                                new ActionMessage("userAdmin.invalidNewUserName"));
                         userForm.setUserName("");
                     }
-                    if (request.getSession().getAttribute("cookieLogin")!=null) 
-                    {
-                        // TODO: make it possible to change passwords 
+                    if (request.getSession().getAttribute("cookieLogin")!=null) {
+                        // TODO: make it possible to change passwords
                         // regardless of remember me
-                        msgs.add(ActionErrors.GLOBAL_ERROR, 
+                        msgs.add(ActionErrors.GLOBAL_ERROR,
                                 new ActionMessage("userAdmin.cookieLogin"));
                     }
                     saveErrors(request, msgs);
                 }
                 request.setAttribute("model", new UserAdminPageModel(
-                    request, response, mapping, userForm, user));
-            }
-            else
-            {
+                        request, response, mapping, userForm, user));
+            } else {
                 forward = mapping.findForward("access-denied");
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             mLogger.error("ERROR in action",e);
             throw new ServletException(e);
         }
         return forward;
     }
-
+    
     //-----------------------------------------------------------------------
-    /** 
-     * Process POST of edited user data, may cause delete of user. 
+    /**
+     * Process POST of edited user data, may cause delete of user.
      */
     public ActionForward update(
-        ActionMapping       mapping,
-        ActionForm          actionForm,
-        HttpServletRequest  request,
-        HttpServletResponse response)
-        throws IOException, ServletException
-    {
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException {
         ActionForward forward = mapping.findForward("adminUser.page");
         ActionMessages msgs = new ActionMessages();
-        try
-        {
+        try {
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
-            RollerSession rollerSession = 
-                RollerSession.getRollerSession(request);
-            if (rollerSession.isGlobalAdminUser() )
-            {
+            RollerSession rollerSession =
+                    RollerSession.getRollerSession(request);
+            if (rollerSession.isGlobalAdminUser() ) {
                 UserManager mgr = RollerFactory.getRoller().getUserManager();
                 UserAdminForm userForm = (UserAdminForm)actionForm;
                 
                 if (userForm.isNewUser()) {
                     UserData user = new UserData();
-                    userForm.copyTo(user, request.getLocale()); 
+                    userForm.copyTo(user, request.getLocale());
                     user.setId(null);
                     user.setDateCreated(new java.util.Date());
                     user.setEnabled(Boolean.TRUE);
                     
                     // Check username and email addresses
                     msgs = validate(userForm, msgs);
-
+                    
                     // Must have matching passwords and confirm passwords
-                    if (    !StringUtils.isEmpty(userForm.getPasswordText()) 
-                         && !StringUtils.isEmpty(userForm.getPasswordConfirm()))
-                    {
+                    if (    !StringUtils.isEmpty(userForm.getPasswordText())
+                    && !StringUtils.isEmpty(userForm.getPasswordConfirm())) {
                         try {
-                            user.resetPassword(RollerFactory.getRoller(), 
-                               userForm.getPasswordText(), 
-                               userForm.getPasswordConfirm());
+                            user.resetPassword(RollerFactory.getRoller(),
+                                    userForm.getPasswordText(),
+                                    userForm.getPasswordConfirm());
                         } catch (RollerException e) {
-                            msgs.add(ActionErrors.GLOBAL_ERROR, 
-                            new ActionError("userSettings.passwordResetError"));
+                            msgs.add(ActionErrors.GLOBAL_ERROR,
+                                    new ActionError("userSettings.passwordResetError"));
                         }
                     } else {
-                        msgs.add(ActionErrors.GLOBAL_ERROR, 
-                            new ActionError("userSettings.needPasswordTwice"));
+                        msgs.add(ActionErrors.GLOBAL_ERROR,
+                                new ActionError("userSettings.needPasswordTwice"));
                     }
                     
                     // If no error messages, then add user
                     if (msgs.isEmpty()) {
                         try {
                             // Save new user to database
-                            mgr.addUser(user);                            
+                            mgr.addUser(user);
                             RollerFactory.getRoller().flush();
                             
-                            msgs.add(ActionMessages.GLOBAL_MESSAGE, 
-                                new ActionMessage("userSettings.saved"));
+                            msgs.add(ActionMessages.GLOBAL_MESSAGE,
+                                    new ActionMessage("userSettings.saved"));
                             saveMessages(request, msgs);
                             
                             // Operation complete, return to edit action
-                            userForm.setUserName(null); 
+                            userForm.setUserName(null);
                             userForm.setNewUser((false));
                             
                         } catch (RollerException e) {
                             // Add and commit failed, so show nice error message
-                            msgs.add(ActionErrors.GLOBAL_ERROR, 
-                                new ActionError(e.getMessage())); 
+                            msgs.add(ActionErrors.GLOBAL_ERROR,
+                                    new ActionError(e.getMessage()));
                             saveErrors(request, msgs);
                         }
                     } else {
                         saveErrors(request, msgs);
-                    } 
-                    return edit(mapping, actionForm, request, response);  
+                    }
+                    return edit(mapping, actionForm, request, response);
                     
                 } else {
                     
                     UserData user = mgr.getUser(userForm.getId());
-                    userForm.copyTo(user, request.getLocale()); 
-                
+                    userForm.copyTo(user, request.getLocale());
+                    
                     // Check username and email addresses
                     msgs = validate(userForm, msgs);
                     
-                    // If user set both password and passwordConfirm then reset 
-                    if (    !StringUtils.isEmpty(userForm.getPasswordText()) 
-                         && !StringUtils.isEmpty(userForm.getPasswordConfirm()))
-                    {
+                    // If user set both password and passwordConfirm then reset
+                    if (    !StringUtils.isEmpty(userForm.getPasswordText())
+                    && !StringUtils.isEmpty(userForm.getPasswordConfirm())) {
                         try {
-                            user.resetPassword(RollerFactory.getRoller(), 
-                               userForm.getPasswordText(), 
-                               userForm.getPasswordConfirm());
+                            user.resetPassword(RollerFactory.getRoller(),
+                                    userForm.getPasswordText(),
+                                    userForm.getPasswordConfirm());
                         } catch (RollerException e) {
-                            msgs.add(ActionErrors.GLOBAL_ERROR, 
-                                new ActionMessage(
+                            msgs.add(ActionErrors.GLOBAL_ERROR,
+                                    new ActionMessage(
                                     "userSettings.passwordResetError"));
                         }
                     } else if (!StringUtils.isEmpty(userForm.getPasswordText())
-                            || !StringUtils.isEmpty(userForm.getPasswordConfirm())) {
+                    || !StringUtils.isEmpty(userForm.getPasswordConfirm())) {
                         // But it's an error to specify only one of the two
-                        msgs.add(ActionErrors.GLOBAL_ERROR, 
-                            new ActionMessage(
+                        msgs.add(ActionErrors.GLOBAL_ERROR,
+                                new ActionMessage(
                                 "userSettings.needPasswordTwice"));
                     }
                     
                     if (msgs.isEmpty()) {
                         try {
-                           // Persist changes to user
+                            // Persist changes to user
                             mgr.saveUser(user);
                             RollerFactory.getRoller().flush();
                             
                             msgs.add(ActionMessages.GLOBAL_MESSAGE,
-                                new ActionMessage("userSettings.saved"));
+                                    new ActionMessage("userSettings.saved"));
                             saveMessages(request, msgs);
-
+                            
                             // Operation complete, return to edit action
-                            userForm.setUserName(null);  
+                            userForm.setUserName(null);
                             
                         } catch (RollerException e) {
-                            msgs.add(ActionErrors.GLOBAL_ERROR, 
-                                new ActionMessage(e.getMessage()));
+                            msgs.add(ActionErrors.GLOBAL_ERROR,
+                                    new ActionMessage(e.getMessage()));
                             saveErrors(request, msgs);
                         }
                     } else {
                         saveErrors(request, msgs);
-                    } 
+                    }
                 }
                 
-                return edit(mapping, actionForm, request, response);                
-            }
-            else
-            {
+                return edit(mapping, actionForm, request, response);
+            } else {
                 forward = mapping.findForward("access-denied");
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             mLogger.error("ERROR in action",e);
             throw new ServletException(e);
         }
         return forward;
     }
-
+    
     //-----------------------------------------------------------------------
     /**
-	 * Cancel from edit user. 
-	 */
-	public ActionForward cancel(
-		ActionMapping       mapping,
-		ActionForm          actionForm,
-		HttpServletRequest  request,
-		HttpServletResponse response)
-		throws IOException, ServletException
-	{
-         UserAdminForm userForm = (UserAdminForm)actionForm;
-         userForm.setUserName(null);         
-         userForm.setNewUser(false);
-         return edit(mapping, actionForm, request, response);
+     * Cancel from edit user.
+     */
+    public ActionForward cancel(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException {
+        UserAdminForm userForm = (UserAdminForm)actionForm;
+        userForm.setUserName(null);
+        userForm.setNewUser(false);
+        return edit(mapping, actionForm, request, response);
     }
     
     //-----------------------------------------------------------------------
     /**
-	 * Create new user. 
-	 */
-	public ActionForward newUser(
-		ActionMapping       mapping,
-		ActionForm          actionForm,
-		HttpServletRequest  request,
-		HttpServletResponse response)
-		throws IOException, ServletException
-	{
-         UserAdminForm userForm = (UserAdminForm)actionForm;
-         userForm.setNewUser(true);
-         userForm.setEnabled(Boolean.TRUE);
-         return edit(mapping, actionForm, request, response);
+     * Create new user.
+     */
+    public ActionForward newUser(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException {
+        UserAdminForm userForm = (UserAdminForm)actionForm;
+        userForm.setNewUser(true);
+        userForm.setEnabled(Boolean.TRUE);
+        return edit(mapping, actionForm, request, response);
     }
     
     //-----------------------------------------------------------------------
     /**
-	 * Rebuild a user's search index.
-	 */
-	public ActionForward index(
-		ActionMapping       mapping,
-		ActionForm          actionForm,
-		HttpServletRequest  request,
-		HttpServletResponse response)
-		throws IOException, ServletException
-	{
-		try
-		{
-			RollerRequest rreq = RollerRequest.getRollerRequest(request);
-             RollerSession rollerSession = RollerSession.getRollerSession(request);
-			if (rollerSession.isGlobalAdminUser() )
-			{
-				UserAdminForm uaf = (UserAdminForm)actionForm;
-				
-				// if admin requests an index be re-built, do it
-				IndexManager manager = RollerFactory.getRoller().getIndexManager();								 
-				manager.rebuildWebsiteIndex();
- 				request.getSession().setAttribute(
-					RollerSession.STATUS_MESSAGE,
-						"Successfully scheduled rebuild of index for");
-			}
-		}
-		catch (Exception e)
-		{
-			mLogger.error("ERROR in action",e);
-			throw new ServletException(e);
-		}
-		return edit(mapping, actionForm, request, response);
-	}
-
-    public class UserAdminPageModel extends BasePageModel 
-    {
+     * Rebuild a user's search index.
+     */
+    public ActionForward index(
+            ActionMapping       mapping,
+            ActionForm          actionForm,
+            HttpServletRequest  request,
+            HttpServletResponse response)
+            throws IOException, ServletException {
+        try {
+            RollerRequest rreq = RollerRequest.getRollerRequest(request);
+            RollerSession rollerSession = RollerSession.getRollerSession(request);
+            if (rollerSession.isGlobalAdminUser() ) {
+                UserAdminForm uaf = (UserAdminForm)actionForm;
+                
+                // if admin requests an index be re-built, do it
+                IndexManager manager = RollerFactory.getRoller().getIndexManager();
+                manager.rebuildWebsiteIndex();
+                request.getSession().setAttribute(
+                        RollerSession.STATUS_MESSAGE,
+                        "Successfully scheduled rebuild of index for");
+            }
+        } catch (Exception e) {
+            mLogger.error("ERROR in action",e);
+            throw new ServletException(e);
+        }
+        return edit(mapping, actionForm, request, response);
+    }
+    
+    public class UserAdminPageModel extends BasePageModel {
         private UserAdminForm userAdminForm = null;
         private List permissions = new ArrayList();
         
         public UserAdminPageModel(
-            HttpServletRequest request,
-            HttpServletResponse response,
-            ActionMapping mapping,
-            UserAdminForm form,
-            UserData user) throws RollerException
-        {
+                HttpServletRequest request,
+                HttpServletResponse response,
+                ActionMapping mapping,
+                UserAdminForm form,
+                UserData user) throws RollerException {
             super("dummy", request, response, mapping);
             userAdminForm = form;
             
-            if (user != null)
-            {
+            if (user != null) {
                 Roller roller = RollerFactory.getRoller();
                 permissions = roller.getUserManager().getAllPermissions(user);
             }
         }
-        public String getTitle() 
-        {
-            if (StringUtils.isEmpty(userAdminForm.getUserName())) 
-            {
+        public String getTitle() {
+            if (StringUtils.isEmpty(userAdminForm.getUserName()) && userAdminForm.isNewUser())
{
+                return bundle.getString("userAdmin.title.createNewUser");
+            } else if (StringUtils.isEmpty(userAdminForm.getUserName())) {
                 return bundle.getString("userAdmin.title.searchUser");
             }
             return MessageFormat.format(
-                    bundle.getString("userAdmin.title.editUser"), 
+                    bundle.getString("userAdmin.title.editUser"),
                     new Object[] { userAdminForm.getUserName() } );
         }
-        public List getPermissions()
-        {
+        public List getPermissions() {
             return permissions;
         }
-        public void setPermissions(List permissions)
-        {
+        public void setPermissions(List permissions) {
             this.permissions = permissions;
         }
     }

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/admin/UserAdmin.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/admin/UserAdmin.jsp?rev=424422&r1=424421&r2=424422&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/admin/UserAdmin.jsp (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/admin/UserAdmin.jsp Fri Jul 21 12:06:34
2006
@@ -66,10 +66,7 @@
             <p class="subtitle"><fmt:message key="userAdmin.subtitle.editUser" /></p>
             <p><fmt:message key="userAdmin.prompt.editUser" /></p>
         </c:when>
-        <c:otherwise>
-            <h1>
-                <fmt:message key="userAdmin.title.createNewUser" />
-            </h1>			
+        <c:otherwise>			
             <p class="subtitle"><fmt:message key="userAdmin.subtitle.createNewUser"
/></p>
         </c:otherwise>
     </c:choose>



Mime
View raw message