[seam-commits] Seam SVN: r8138 - in trunk/examples/seamspace: src/org/jboss/seam/example/seamspace and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu May 8 02:11:45 EDT 2008


Author: shane.bryzak at jboss.com
Date: 2008-05-08 02:11:45 -0400 (Thu, 08 May 2008)
New Revision: 8138

Modified:
   trunk/examples/seamspace/resources/import.sql
   trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java
   trunk/examples/seamspace/view/imagepermissiondetail.page.xml
   trunk/examples/seamspace/view/imagepermissiondetail.xhtml
Log:
completed permission management views, fixed invalid sample passwords

Modified: trunk/examples/seamspace/resources/import.sql
===================================================================
--- trunk/examples/seamspace/resources/import.sql	2008-05-08 02:17:52 UTC (rev 8137)
+++ trunk/examples/seamspace/resources/import.sql	2008-05-08 06:11:45 UTC (rev 8138)
@@ -7,9 +7,9 @@
 insert into MemberRole (roleid, name) values (2, 'admin');
 
 insert into MemberAccount (accountid, username, passwordhash, enabled, member_id) values (1, 'demo', '/9Se/pfHeUH8FJ4asBD6jQ==', 1, 1);
-insert into MemberAccount (accountid, username, passwordhash, enabled, member_id) values (2, 'duke', '97291c29cc69a65890424d0f97db28f2', 1, 2);
-insert into MemberAccount (accountid, username, passwordhash, enabled, member_id) values (3, 'shadowman', 'd76acda33fcfede62a8a6979df88e690', 1, 3);
-insert into MemberAccount (accountid, username, passwordhash, enabled, member_id) values (4, 'mona', '0a7adfe58071398e15b5177f4ace8493', 1, 4);
+insert into MemberAccount (accountid, username, passwordhash, enabled, member_id) values (2, 'duke', 'lykcKcxppliQQk0Pl9so8g==', 1, 2);
+insert into MemberAccount (accountid, username, passwordhash, enabled, member_id) values (3, 'shadowman', '12rNoz/P7eYqiml534jmkA==', 1, 3);
+insert into MemberAccount (accountid, username, passwordhash, enabled, member_id) values (4, 'mona', 'Cnrf5YBxOY4VtRd/Ss6Ekw==', 1, 4);
 
 insert into AccountMembership (accountid, memberof) values (1, 2);
 insert into AccountMembership (accountid, memberof) values (2, 1);

Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java	2008-05-08 02:17:52 UTC (rev 8137)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java	2008-05-08 06:11:45 UTC (rev 8138)
@@ -14,6 +14,8 @@
 import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Scope;
 import org.jboss.seam.core.Conversation;
+import org.jboss.seam.security.Role;
+import org.jboss.seam.security.SimplePrincipal;
 import org.jboss.seam.security.management.IdentityManager;
 import org.jboss.seam.security.permission.Permission;
 import org.jboss.seam.security.permission.PermissionManager;
@@ -110,8 +112,34 @@
    
    public void applyPermissions()
    {
-      // TODO apply permission changes here
+      List<Permission> permissions = new ArrayList<Permission>();
+
+      for (String role : selectedRoles)
+      {
+         Principal r = new Role(role);
+         for (String action : selectedActions)
+         {            
+            permissions.add(new Permission(target, action, r));
+         }
+      }
       
+      for (Member friend : selectedFriends)
+      {
+         MemberAccount acct = (MemberAccount) entityManager.createQuery(
+               "select a from MemberAccount a where a.member = :member")
+               .setParameter("member", friend)
+               .getSingleResult();
+         
+         Principal p = new SimplePrincipal(acct.getUsername());
+         
+         for (String action : selectedActions)
+         {
+            permissions.add(new Permission(target, action, p));
+         }
+      }
+      
+      permissionManager.grantPermissions(permissions);
+      
       Conversation.instance().end();
    }
    

Modified: trunk/examples/seamspace/view/imagepermissiondetail.page.xml
===================================================================
--- trunk/examples/seamspace/view/imagepermissiondetail.page.xml	2008-05-08 02:17:52 UTC (rev 8137)
+++ trunk/examples/seamspace/view/imagepermissiondetail.page.xml	2008-05-08 06:11:45 UTC (rev 8138)
@@ -2,6 +2,8 @@
           "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
           "http://jboss.com/products/seam/pages-1.2.dtd">
 
-<page action="#{permissionSearch.refresh}">
-
+<page>
+    <navigation from-action="#{imagePermission.applyPermissions}">
+          <redirect view-id="/imagepermissions.xhtml"/>
+    </navigation>
 </page>
\ No newline at end of file

Modified: trunk/examples/seamspace/view/imagepermissiondetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/imagepermissiondetail.xhtml	2008-05-08 02:17:52 UTC (rev 8137)
+++ trunk/examples/seamspace/view/imagepermissiondetail.xhtml	2008-05-08 06:11:45 UTC (rev 8138)
@@ -27,7 +27,8 @@
       	    <h3>Recipients</h3>
       	    
       	    <p>
-      	      Select the roles and/or friends that you wish to grant permissions for the following image:
+      	      Select the roles and/or friends that you wish to grant permissions for the following image
+      	      (Ctrl-click to select multiple):
       	    </p>
       	    
       	    <br class="clear"/>




More information about the seam-commits mailing list