[seam-commits] Seam SVN: r8132 - in trunk/examples/seamspace: view and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed May 7 11:08:05 EDT 2008


Author: shane.bryzak at jboss.com
Date: 2008-05-07 11:08:05 -0400 (Wed, 07 May 2008)
New Revision: 8132

Added:
   trunk/examples/seamspace/view/imagepermissiondetail.page.xml
   trunk/examples/seamspace/view/imagepermissiondetail.xhtml
Removed:
   trunk/examples/seamspace/view/permissiondetail.xhtml
Modified:
   trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/FriendAction.java
   trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java
   trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java
   trunk/examples/seamspace/view/friendcomment.xhtml
   trunk/examples/seamspace/view/friendrequest.xhtml
   trunk/examples/seamspace/view/imagepermissions.page.xml
   trunk/examples/seamspace/view/imagepermissions.xhtml
Log:
permission details view for member images

Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/FriendAction.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/FriendAction.java	2008-05-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/FriendAction.java	2008-05-07 15:08:05 UTC (rev 8132)
@@ -23,7 +23,7 @@
 import org.jboss.seam.security.Identity;
 
 @Scope(CONVERSATION)
- at Name("friend")
+ at Name("friendAction")
 public class FriendAction implements Serializable
 {
    private static final long serialVersionUID = 4565339001481077911L;

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-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/ImagePermission.java	2008-05-07 15:08:05 UTC (rev 8132)
@@ -3,6 +3,8 @@
 import static org.jboss.seam.ScopeType.CONVERSATION;
 
 import java.io.Serializable;
+import java.security.Principal;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.persistence.EntityManager;
@@ -13,6 +15,7 @@
 import org.jboss.seam.annotations.Scope;
 import org.jboss.seam.core.Conversation;
 import org.jboss.seam.security.management.IdentityManager;
+import org.jboss.seam.security.permission.Permission;
 import org.jboss.seam.security.permission.PermissionManager;
 import org.jboss.seam.security.permission.action.PermissionSearch;
 
@@ -26,9 +29,7 @@
    private List<Member> selectedFriends;
    private List<String> selectedActions;
    
-   private List<String> availableRoles;
    private List<Member> availableFriends;   
-   private List<String> availableActions;
    
    @In IdentityManager identityManager;
    @In PermissionManager permissionManager;
@@ -39,19 +40,42 @@
    
    private MemberImage target; 
    
+   private Principal recipient;
+   
    @SuppressWarnings("unchecked")
    @Begin(nested = true)
    public void createPermission()
    {
       target = (MemberImage) permissionSearch.getTarget();
       
-      availableRoles = identityManager.listRoles();
+      selectedFriends = new ArrayList<Member>();
+      
       availableFriends = entityManager.createQuery(
             "select f.friend from MemberFriend f where f.member = :member and f.authorized = true")
             .setParameter("member", target.getMember())
-            .getResultList();
+            .getResultList();      
+   }
+   
+   @Begin(nested = true)
+   public void editPermission()
+   {
+      target = (MemberImage) permissionSearch.getTarget();
+      recipient = permissionSearch.getSelectedPermission().getRecipient();
+            
+      List<Permission> permissions = permissionManager.listPermissions(target);
       
-      availableActions = permissionManager.listAvailableActions(target); 
+      selectedActions = new ArrayList<String>();
+      
+      for (Permission permission : permissions)
+      {
+         if (permission.getRecipient().equals(recipient))
+         {
+            if (!selectedActions.contains(permission.getAction()))
+            {
+               selectedActions.add(permission.getAction());
+            }
+         }
+      }
    }
 
    public List<String> getSelectedRoles()
@@ -86,23 +110,23 @@
    
    public void applyPermissions()
    {
+      // TODO apply permission changes here
       
-      
       Conversation.instance().end();
    }
    
-   public List<String> getAvailableRoles()
+   public List<Member> getAvailableFriends()
    {
-      return availableRoles;
+      return availableFriends;
    }
    
-   public List<Member> getAvailableFriends()
+   public MemberImage getTarget()
    {
-      return availableFriends;
+      return target;
    }
    
-   public List<String> getAvailableActions()
+   public Principal getRecipient()
    {
-      return availableActions;
+      return recipient;
    }
 }

Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java	2008-05-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java	2008-05-07 15:08:05 UTC (rev 8132)
@@ -9,6 +9,12 @@
 import javax.persistence.Lob;
 import javax.persistence.ManyToOne;
 
+import org.jboss.seam.annotations.security.permission.Permission;
+import org.jboss.seam.annotations.security.permission.Permissions;
+
+ at Permissions({
+   @Permission(action = "view")
+})
 @Entity
 public class MemberImage implements Serializable
 {

Modified: trunk/examples/seamspace/view/friendcomment.xhtml
===================================================================
--- trunk/examples/seamspace/view/friendcomment.xhtml	2008-05-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/view/friendcomment.xhtml	2008-05-07 15:08:05 UTC (rev 8132)
@@ -45,7 +45,7 @@
               <h:inputTextarea id="comment" value="#{friendComment.comment}"/><br/>
 
               <div class="buttons">
-                <h:commandButton action="#{friend.saveComment}" value="Add comment" styleClass="action"/>            
+                <h:commandButton action="#{friendAction.saveComment}" value="Add comment" styleClass="action"/>            
                 <h:commandButton value="Preview" styleClass="action"/>                            
               </div>
               

Modified: trunk/examples/seamspace/view/friendrequest.xhtml
===================================================================
--- trunk/examples/seamspace/view/friendrequest.xhtml	2008-05-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/view/friendrequest.xhtml	2008-05-07 15:08:05 UTC (rev 8132)
@@ -39,7 +39,7 @@
             <h:inputTextarea id="introduction" value="#{friendRequest.introduction}"/><br/>
 
             <div class="buttons">
-              <h:commandButton action="#{friend.saveRequest}" value="Send request" styleClass="action"/>
+              <h:commandButton action="#{friendAction.saveRequest}" value="Send request" styleClass="action"/>
             </div>
 
             <br class="clear"/>

Added: trunk/examples/seamspace/view/imagepermissiondetail.page.xml
===================================================================
--- trunk/examples/seamspace/view/imagepermissiondetail.page.xml	                        (rev 0)
+++ trunk/examples/seamspace/view/imagepermissiondetail.page.xml	2008-05-07 15:08:05 UTC (rev 8132)
@@ -0,0 +1,7 @@
+<!DOCTYPE page PUBLIC
+          "-//JBoss/Seam Pages Configuration DTD 1.2//EN"
+          "http://jboss.com/products/seam/pages-1.2.dtd">
+
+<page action="#{permissionSearch.refresh}">
+
+</page>
\ No newline at end of file

Added: trunk/examples/seamspace/view/imagepermissiondetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/imagepermissiondetail.xhtml	                        (rev 0)
+++ trunk/examples/seamspace/view/imagepermissiondetail.xhtml	2008-05-07 15:08:05 UTC (rev 8132)
@@ -0,0 +1,88 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:ui="http://java.sun.com/jsf/facelets"
+    xmlns:h="http://java.sun.com/jsf/html"
+    xmlns:f="http://java.sun.com/jsf/core"
+    xmlns:rich="http://richfaces.org/rich"       
+    xmlns:s="http://jboss.com/products/seam/taglib">
+
+  <ui:composition template="template.xhtml">
+  
+    <ui:define name="head">
+      <link href="style/security.css" rel="stylesheet" type="text/css"/>
+    </ui:define>  
+   
+    <ui:define name="content">
+        
+      <div id="contentMain">
+
+  	    <h2>Permission Details</h2>  
+  	    
+  	    <hr/>
+  	    
+  	    <h:messages globalOnly="true"/>
+
+  	    <h:form>
+          <s:fragment rendered="#{imagePermission.recipient eq null}">  	    
+      	    <h3>Recipients</h3>
+      	    
+      	    <p>
+      	      Select the roles and/or friends that you wish to grant permissions for the following image:
+      	    </p>
+      	    
+      	    <br class="clear"/>
+      	    
+            <div class="thumbnail">
+              <h:graphicImage value="/content/images?id=#{permissionSearch.target.imageId}&amp;width=90"/>
+            </div>        	      	    
+            
+            <br class="clear"/>
+      	    
+      	    <div class="formRow">
+      	      <h:outputLabel for="roles" value="Roles" styleClass="formLabel"/>
+      	      <div class="selectMany">
+      	        <h:selectManyListbox id="roles" value="#{imagePermission.selectedRoles}" styleClass="roles" size="4">
+      	          <s:selectItems value="#{identityManager.listRoles()}" var="role" label="#{role}"/>
+      	        </h:selectManyListbox>
+      	      </div>
+      	      <div class="validationError"><h:message for="actions"/></div>
+      	    </div>
+      	    
+      	    <div class="formRow">
+      	      <h:outputLabel for="friends" value="Friends" styleClass="formLabel"/>
+      	      <div class="selectMany">
+      	        <h:selectManyListbox id="friends" value="#{imagePermission.selectedFriends}" styleClass="roles" size="6">
+      	          <s:selectItems value="#{imagePermission.availableFriends}" var="friend" label="#{friend.memberName}"/>
+      	          <s:convertEntity />
+      	        </h:selectManyListbox>
+      	      </div>
+      	      <div class="validationError"><h:message for="friends"/></div>
+      	    </div>
+      	    
+      	  </s:fragment>
+                            
+          <div class="formRow">            
+            <h:outputLabel for="actions" value="Actions allowed" styleClass="formLabel"/>
+            <div class="selectMany">
+              <h:selectManyCheckbox id="actions" value="#{imagePermission.selectedActions}" layout="pageDirection" styleClass="roles">
+                <s:selectItems value="#{permissionManager.listAvailableActions(imagePermission.target)}" var="action" label="#{action}"/>
+              </h:selectManyCheckbox>
+            </div>
+            <div class="validationError"><h:message for="actions"/></div>
+          </div>
+                                                
+          <div class="formButtons">
+            <h:commandButton value="Save" action="#{imagePermission.applyPermissions}" styleClass="formButton"/>
+            <s:button view="/imagepermissions.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
+          </div>
+    
+          <br class="clear"/>
+  	    
+  	    </h:form>
+
+	    </div>
+	    
+    </ui:define>
+    
+  </ui:composition>
+</html>

Modified: trunk/examples/seamspace/view/imagepermissions.page.xml
===================================================================
--- trunk/examples/seamspace/view/imagepermissions.page.xml	2008-05-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/view/imagepermissions.page.xml	2008-05-07 15:08:05 UTC (rev 8132)
@@ -3,5 +3,7 @@
           "http://jboss.com/products/seam/pages-1.2.dtd">
 
 <page action="#{permissionSearch.refresh}">
-
+    <navigation from-action="#{imagePermission.createPermission}">
+          <redirect view-id="/imagepermissiondetail.xhtml"/>
+    </navigation>
 </page>
\ No newline at end of file

Modified: trunk/examples/seamspace/view/imagepermissions.xhtml
===================================================================
--- trunk/examples/seamspace/view/imagepermissions.xhtml	2008-05-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/view/imagepermissions.xhtml	2008-05-07 15:08:05 UTC (rev 8132)
@@ -6,13 +6,13 @@
     xmlns:s="http://jboss.com/products/seam/taglib">
 
   <ui:composition template="template.xhtml">
-  
+
     <ui:define name="head">
       <link href="style/security.css" rel="stylesheet" type="text/css"/>
-    </ui:define>  
-   
+    </ui:define>
+
     <ui:define name="content">
-        
+
       <script type="text/javascript">
         function confirmRevoke()
         {
@@ -22,26 +22,28 @@
 
       <div id="contentMain">
 
-  	    <h2>Image Permissions</h2>  
-  	    
+  	    <h2>Image Permissions</h2>
+
   	    <div style="float: left">
   	      <h3>Managing permissions for image:</h3>
   	    </div>
-  	      	    
-        <div class="thumbnail" style="float:right">
+
+        <br class="clear"/>
+
+        <div class="thumbnail">
           <h:graphicImage value="/content/images?id=#{permissionSearch.target.imageId}&amp;width=90"/>
-        </div>  	        	    
-    	  
+        </div>
+
     	  <br class="clear"/>
-  	      	    
-        <s:button action="#{imagePermission.createPermission}" 
-          styleClass="newpermission" 
+
+        <s:button action="#{imagePermission.createPermission}"
+          styleClass="newpermission"
           rendered="#{s:hasPermission(permissionSearch.target, 'seam.grant-permission')}"/>
-  	    
-        <h:dataTable 
+
+        <h:dataTable
             id="threads"
-            value="#{permissions}" 
-            var="permission" 
+            value="#{permissions}"
+            var="permission"
             styleClass="security"
             cellspacing="0"
             headerClass="header"
@@ -63,15 +65,15 @@
             <f:facet name="header">
               Action
             </f:facet>
-            <s:link value="Revoke All" action="#{permissionSearch.revokeSelected}" 
+            <s:link value="Revoke All" action="#{permissionSearch.revokeSelected}"
                     rendered="#{s:hasPermission(permissionSearch.target, 'seam.revoke-permission')}"
                     onclick="return confirmRevoke()"/>
           </h:column>
-  	    </h:dataTable>  	    
+  	    </h:dataTable>
 
 	    </div>
-	    
+
     </ui:define>
-    
+
   </ui:composition>
 </html>

Deleted: trunk/examples/seamspace/view/permissiondetail.xhtml
===================================================================
--- trunk/examples/seamspace/view/permissiondetail.xhtml	2008-05-07 15:07:06 UTC (rev 8131)
+++ trunk/examples/seamspace/view/permissiondetail.xhtml	2008-05-07 15:08:05 UTC (rev 8132)
@@ -1,63 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-    xmlns:ui="http://java.sun.com/jsf/facelets"
-    xmlns:h="http://java.sun.com/jsf/html"
-    xmlns:f="http://java.sun.com/jsf/core"
-    xmlns:rich="http://richfaces.org/rich"       
-    xmlns:s="http://jboss.com/products/seam/taglib">
-
-  <ui:composition template="template.xhtml">
-  
-    <ui:define name="head">
-      <link href="style/security.css" rel="stylesheet" type="text/css"/>
-    </ui:define>  
-   
-    <ui:define name="content">
-        
-      <div id="contentMain">
-
-  	    <h2>Permission Details</h2>  
-  	    
-  	    <h:messages globalOnly="true"/>
-  	    
-  	    <h3>Granting permissions for: #{permissionSearch.target}</h3>
-  	    
-  	    <h:form>
-  	    
-          <div class="formRow">
-            <h:outputLabel for="recipient" value="Recipient" styleClass="formLabel"/>
-            <h:inputText id="recipient" value="#{permissionAction.recipient}"/>
-            <div class="validationError"><h:message for="recipient"/></div>
-          </div>  
-          
-          <div class="formRow">
-            <h:outputLabel for="action" value="Action" styleClass="formLabel"/>
-            <h:inputText id="action" value="#{permissionAction.action}"/>
-            <div class="validationError"><h:message for="action"/></div>
-          </div>            
-                            
-          <div class="formRow">            
-            <h:outputLabel for="actions" value="Allowable actions" styleClass="formLabel"/>
-            <div class="selectMany">
-              <h:selectManyCheckbox id="actions" value="#{permissionAction.actions}" layout="pageDirection" styleClass="roles">
-                <s:selectItems value="#{permissionManager.listAvailableActions(permissionAction.target)}" var="action" label="#{action}"/>
-              </h:selectManyCheckbox>
-            </div>
-            <div class="validationError"><h:message for="actions"/></div>
-          </div>
-                                                
-          <div class="formButtons">
-            <h:commandButton value="Save" action="#{permissionAction.save}" styleClass="formButton"/>
-            <s:button view="/permissionmanager.xhtml" value="Cancel" propagation="end" styleClass="formButton"/>
-          </div>
-    
-          <br class="clear"/>
-  	    
-  	    </h:form>
-
-	    </div>
-	    
-    </ui:define>
-    
-  </ui:composition>
-</html>




More information about the seam-commits mailing list