roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r571534 - in /roller/branches/roller_4.1_dev/apps/weblogger: src/java/org/apache/roller/weblogger/ui/core/security/ src/java/org/apache/roller/weblogger/ui/struts2/editor/ web/WEB-INF/jsps/core/ web/WEB-INF/jsps/editor/ web/roller-ui/
Date Fri, 31 Aug 2007 18:32:42 GMT
Author: snoopdave
Date: Fri Aug 31 11:32:36 2007
New Revision: 571534

URL: http://svn.apache.org/viewvc?rev=571534&view=rev
Log:
More progress on externalizable user management. Work is essentially complete, Roller UI is
working with the new user manager and migration SQL is in place. Next, more testing.

http://opensource.atlassian.com/projects/roller/browse/ROL-1534

Modified:
    roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
    roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java
    roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MembersInvite.java
    roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/core/MainMenu.jsp
    roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/Members.jsp
    roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/MembersInvite.jsp
    roller/branches/roller_4.1_dev/apps/weblogger/web/roller-ui/login-redirect.jsp

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java?rev=571534&r1=571533&r2=571534&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
Fri Aug 31 11:32:36 2007
@@ -1,6 +1,6 @@
 package org.apache.roller.weblogger.ui.core.security;
 
-import java.util.Iterator;
+import java.util.List;
 import org.acegisecurity.GrantedAuthority;
 import org.acegisecurity.GrantedAuthorityImpl;
 import org.acegisecurity.userdetails.UserDetails;
@@ -10,7 +10,6 @@
 import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.UserManager;
-import org.apache.roller.weblogger.pojos.UserRole;
 import org.apache.roller.weblogger.pojos.User;
 import org.springframework.dao.DataAccessException;
 import org.springframework.dao.DataAccessResourceFailureException;
@@ -38,11 +37,11 @@
                 throw new UsernameNotFoundException("ERROR no user: " + userName);
             }
 
-            GrantedAuthority[] authorities = new GrantedAuthorityImpl[umgr.getRoles(userData).size()];
+            List<String> roles = umgr.getRoles(userData);
+            GrantedAuthority[] authorities = new GrantedAuthorityImpl[roles.size()];
             int i = 0;
-            for (Iterator it = umgr.getRoles(userData).iterator(); it.hasNext();) {
-                UserRole role = (UserRole) it.next();
-                authorities[i++] = new GrantedAuthorityImpl(role.getRole());
+            for (String role : roles) {
+                authorities[i++] = new GrantedAuthorityImpl(role);
             }
 
             return new org.acegisecurity.userdetails.User(userData.getUserName(), userData.getPassword(),
true, authorities);

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java?rev=571534&r1=571533&r2=571534&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/Members.java
Fri Aug 31 11:32:36 2007
@@ -22,8 +22,11 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.pojos.User;
@@ -75,7 +78,7 @@
         
         int removed = 0;
         int changed = 0;
-        List<WeblogPermission>  permsList = new ArrayList<WeblogPermission>();
+        List<WeblogPermission> permsList = new ArrayList<WeblogPermission>();
         try {
             UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();   
             List<WeblogPermission> permissions = userMgr.getWeblogPermissions(getActionWeblog());
@@ -88,7 +91,7 @@
         
             for (WeblogPermission perms : permsList) {
                 
-                String sval = getParameter("perm-" + perms.getWeblog().getId());
+                String sval = getParameter("perm-" + perms.getUser().getId());
                 if (sval != null) {
                     boolean error = false;
                     User user = getAuthenticatedUser();
@@ -161,5 +164,15 @@
 
     public void setParameters(Map parameters) {
         this.parameters = parameters;
+    }
+    
+    public List<WeblogPermission> getWeblogPermissions() {
+        try {
+            return WebloggerFactory.getWeblogger().getUserManager().getWeblogPermissions(getActionWeblog());
+        } catch (WebloggerException ex) {
+            // serious problem, but not much we can do here
+            log.error("ERROR getting weblog permissions", ex);
+        }
+        return new ArrayList<WeblogPermission>();
     }
 }

Modified: roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MembersInvite.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MembersInvite.java?rev=571534&r1=571533&r2=571534&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MembersInvite.java
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MembersInvite.java
Fri Aug 31 11:32:36 2007
@@ -43,7 +43,7 @@
     private String userName = null;
     
     // permissions being given to user
-    private String permissionsMask = null;
+    private String permissionString = null;
     
     
     public MembersInvite() {
@@ -126,7 +126,7 @@
         
         // if no errors then send the invitation
         if(!hasActionErrors()) try {
-            WeblogPermission perm = new WeblogPermission(getActionWeblog(), user, getPermissionsMask());
+            WeblogPermission perm = new WeblogPermission(getActionWeblog(), user, getPermissionString());
             perm.setPending(true);
             umgr.grantWeblogPermission(perm);
             WebloggerFactory.getWeblogger().flush();
@@ -166,12 +166,12 @@
         this.userName = userId;
     }
 
-    public String getPermissionsMask() {
-        return permissionsMask;
+    public String getPermissionString() {
+        return permissionString;
     }
 
-    public void setPermissionsMask(String permission) {
-        this.permissionsMask = permission;
+    public void setPermissionString(String permission) {
+        this.permissionString = permission;
     }
     
 }

Modified: roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/core/MainMenu.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/core/MainMenu.jsp?rev=571534&r1=571533&r2=571534&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/core/MainMenu.jsp (original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/core/MainMenu.jsp Fri Aug
31 11:32:36 2007
@@ -29,7 +29,7 @@
     
     <s:iterator id="invite" value="pendingPermissions">
         <s:text name="yourWebsites.youAreInvited" >
-            <s:param value="#invite.website.handle" />
+            <s:param value="#invite.weblog.handle" />
         </s:text>
         
         <s:url action="menu!accept" id="acceptInvite">
@@ -61,7 +61,7 @@
 
         <div class="yourWeblogBox">  
 
-            <span class="mm_weblog_name"><img src='<c:url value="/images/folder.png"/>'
/>&nbsp;<s:property value="#perms.website.name" /></span>
+            <span class="mm_weblog_name"><img src='<c:url value="/images/folder.png"/>'
/>&nbsp;<s:property value="#perms.weblog.name" /></span>
                 
             <table class="mm_table" width="100%" cellpadding="0" cellspacing="0">
                <tr>
@@ -71,31 +71,31 @@
                        
                        <tr>
                            <td class="mm_subtable_label"><s:text name='yourWebsites.weblog'
/></td>
-                           <td><a href='<s:property value="#perms.website.URL"
/>'>
-                               <s:property value="#perms.website.absoluteURL" />
+                           <td><a href='<s:property value="#perms.weblog.URL"
/>'>
+                               <s:property value="#perms.weblog.absoluteURL" />
                            </a></td>                          
                        </tr>
                        
                        <tr>
                            <td class="mm_subtable_label"><s:text name='yourWebsites.permission'
/></td>
-                           <td><s:if test="#perms.permissionMask == 0" >LIMITED</s:if>
-                           <s:if test="#perms.permissionMask == 1" >AUTHOR</s:if>
-                           <s:if test="#perms.permissionMask == 3" >ADMIN</s:if></td>
+                           <td><s:if test='#perms.hasAction("admin")'  >ADMIN</s:if>
+                           <s:if test='#perms.hasAction("post")'       >AUTHOR</s:if>
+                           <s:if test='#perms.hasAction("edit_draft")' >LIMITED</s:if></td>
                        </tr>
                        
                        <tr>
                            <td class="mm_subtable_label"><s:text name='yourWebsites.description'
/></td>   
-                           <td><s:property value="#perms.website.description" escape="false"
/></td>
+                           <td><s:property value="#perms.weblog.description" escape="false"
/></td>
                        </tr>
 
                        <tr>
                            <td class="mm_subtable_label"><s:text name='yourWebsites.userCount'
/></td>   
-                           <td><s:property value="#perms.website.userCount" /></td>
+                           <td><s:property value="#perms.weblog.userCount" /></td>
                        </tr>
 
                        <tr>
                            <td class="mm_subtable_label"><s:text name='yourWebsites.todaysHits'
/></td>   
-                           <td><s:property value="#perms.website.todaysHits" /></td>
+                           <td><s:property value="#perms.weblog.todaysHits" /></td>
                        </tr>
                        
                    </table>
@@ -105,7 +105,7 @@
                <td class="mm_table_actions" width="20%" align="left" >
 
                        <s:url action="entryAdd" namespace="/roller-ui/authoring" id="newEntry">
-                           <s:param name="weblog" value="#perms.website.handle" />
+                           <s:param name="weblog" value="#perms.weblog.handle" />
                        </s:url>
                        <img src='<s:url value="/images/table_edit.png"/>' />
                        <s:a href="%{newEntry}"><s:text name="yourWebsites.newEntry"
/></s:a>
@@ -113,24 +113,24 @@
 
                        <%-- Show Entries link with count, TODO: show N/M where N is draft,
M is published --%>
                        <s:url action="entries" namespace="/roller-ui/authoring" id="editEntries">
-                           <s:param name="weblog" value="#perms.website.handle" />
+                           <s:param name="weblog" value="#perms.weblog.handle" />
                        </s:url>
                        <img src='<s:url value="/images/table_multiple.png"/>' />
-                       <s:a href="%{editEntries}"><s:text name="yourWebsites.editEntries"
/> (<s:property value="#perms.website.entryCount" />)</s:a> 
+                       <s:a href="%{editEntries}"><s:text name="yourWebsites.editEntries"
/> (<s:property value="#perms.weblog.entryCount" />)</s:a> 
                        <br />
 
                        <%-- Show Comments link with count, TODO: show N/M where N is pending,
M is approved --%>
                        <s:url action="comments" namespace="/roller-ui/authoring" id="manageComments">
-                           <s:param name="weblog" value="#perms.website.handle" />
+                           <s:param name="weblog" value="#perms.weblog.handle" />
                        </s:url>
                        <img src='<s:url value="/images/page_white_edit.png"/>' />
-                       <s:a href="%{manageComments}"><s:text name="yourWebsites.manageComments"
/> (<s:property value="#perms.website.commentCount" />)</s:a> 
+                       <s:a href="%{manageComments}"><s:text name="yourWebsites.manageComments"
/> (<s:property value="#perms.weblog.commentCount" />)</s:a> 
                        <br />
                        
                        <%-- Only adming get access to theme and config settings --%>
-                       <s:if test="#perms.permissionMask == 3">
+                       <s:if test='#perms.hasAction("admin")'>
                            <s:url action="themeEdit" namespace="/roller-ui/authoring"
id="weblogTheme">
-                               <s:param name="weblog" value="#perms.website.handle" />
+                               <s:param name="weblog" value="#perms.weblog.handle" />
                            </s:url>
                            <img src='<s:url value="/roller-ui/images/layout.png"/>'
/>
                            <a href='<s:property value="weblogTheme" />'>
@@ -138,7 +138,7 @@
                            <br />
                            
                            <s:url action="weblogConfig" namespace="/roller-ui/authoring"
id="manageWeblog">
-                               <s:param name="weblog" value="#perms.website.handle" />
+                               <s:param name="weblog" value="#perms.weblog.handle" />
                            </s:url>
                            <img src='<s:url value="/images/cog.png"/>' />
                            <a href='<s:property value="manageWeblog" />'>
@@ -146,11 +146,11 @@
                            <br />
                        </s:if>
 
-                       <%-- authors and limited bloggers can resign, but admin cannot
resign if he/she is the last admin in the blog --%>
-                       <s:if test="#perms.permissionMask == 0 || #perms.permissionMask
== 1 || #perms.website.adminUserCount > 1">
+                       <%-- don't allow last admin to resign from blog --%>
+                       <s:if test='!(#perms.hasAction("admin") && #perms.weblog.adminUserCount
== 1)'>
                           <img src='<c:url value="/images/delete.png"/>' />
                           <s:url action="menu!resign" id="resignWeblog">
-                               <s:param name="websiteId" value="#perms.website.id" />
+                               <s:param name="websiteId" value="#perms.weblog.id" />
                           </s:url>
                           <a href='<s:property value="resignWeblog" />'>
                               <s:text name='yourWebsites.resign' />

Modified: roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/Members.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/Members.jsp?rev=571534&r1=571533&r2=571534&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/Members.jsp (original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/Members.jsp Fri
Aug 31 11:32:36 2007
@@ -67,7 +67,7 @@
                <s:text name="memberPermissions.remove" />
            </th>
         </tr>
-        <s:iterator id="perm" value="actionWeblog.permissions" status="rowstatus">
+        <s:iterator id="perm" value="weblogPermissions" status="rowstatus">
             <s:if test="#perm.pending">
                 <tr class="rollertable_pending">
             </s:if>
@@ -84,22 +84,22 @@
                 </td>               
                 <td class="rollertable">
                     <input type="radio" 
-                        <s:if test="#perm.permissionMask == 3">checked</s:if>
-                        name='perm-<s:property value="#perm.id" />' value="3" />
+                        <s:if test='#perm.hasAction("admin")'>checked</s:if>
+                        name='perm-<s:property value="#perm.user.id" />' value="admin"
/>
                 </td>
                 <td class="rollertable">
 	                <input type="radio" 
-                        <s:if test="#perm.permissionMask == 1">checked</s:if>
-                        name='perm-<s:property value="#perm.id" />' value="1" />
+                        <s:if test='#perm.hasAction("post")'>checked</s:if>
+                        name='perm-<s:property value="#perm.user.id" />' value="post"
/>
                 </td>                
                 <td class="rollertable">
                     <input type="radio" 
-                        <s:if test="#perm.permissionMask == 0">checked</s:if>
-                        name='perm-<s:property value="#perm.id" />' value="0" />
+                        <s:if test='#perm.hasAction("edit_draft")'>checked</s:if>
+                        name='perm-<s:property value="#perm.user.id" />' value="edit_draft"
/>
                 </td>                
                 <td class="rollertable">
                     <input type="radio" 
-                        name='perm-<s:property value="#perm.id" />' value="-1" />
+                        name='perm-<s:property value="#perm.user.id" />' value="-1"
/>
                 </td>
            </tr>
        </s:iterator>

Modified: roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/MembersInvite.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/MembersInvite.jsp?rev=571534&r1=571533&r2=571534&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/MembersInvite.jsp
(original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/web/WEB-INF/jsps/editor/MembersInvite.jsp
Fri Aug 31 11:32:36 2007
@@ -48,11 +48,11 @@
     <div style="clear:left">
        <label for="userName" class="formrow" />
            <s:text name="inviteMember.permissions" /></label>
-       <input type="radio" name="permissionsMask" value="3"  />
+       <input type="radio" name="permissionString" value="admin"  />
        <s:text name="inviteMember.administrator" />
-       <input type="radio" name="permissionsMask" value="1" checked />
+       <input type="radio" name="permissionString" value="post" checked />
        <s:text name="inviteMember.author" />
-       <input type="radio" name="permissionsMask" value="0" />
+       <input type="radio" name="permissionString" value="edit_draft" />
        <s:text name="inviteMember.limited" />
     </div>  
          

Modified: roller/branches/roller_4.1_dev/apps/weblogger/web/roller-ui/login-redirect.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_4.1_dev/apps/weblogger/web/roller-ui/login-redirect.jsp?rev=571534&r1=571533&r2=571534&view=diff
==============================================================================
--- roller/branches/roller_4.1_dev/apps/weblogger/web/roller-ui/login-redirect.jsp (original)
+++ roller/branches/roller_4.1_dev/apps/weblogger/web/roller-ui/login-redirect.jsp Fri Aug
31 11:32:36 2007
@@ -22,7 +22,7 @@
 <%@ page import="java.util.List" %>
 <%
 User user = RollerSession.getRollerSession(request).getAuthenticatedUser();
-List websites = WebloggerFactory.getWeblogger().getUserManager().getWebsites(user, Boolean.TRUE,
null, null, null, 0, Integer.MAX_VALUE);
+List websites = WebloggerFactory.getWeblogger().getUserManager().getWebsites(user, true);
 
 if (websites.size() == 1) {
     Weblog website = (Weblog) websites.get(0);



Mime
View raw message