incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r164131 - in /incubator/graffito/trunk/applications/browser: ./ src/java/org/apache/portals/graffito/portlets/ src/java/org/apache/portals/graffito/portlets/actions/ src/java/org/apache/portals/graffito/portlets/dto/ src/java/org/apache/portals/graffito/portlets/resources/ src/java/org/apache/portals/graffito/portlets/util/ src/webapp/WEB-INF/ src/webapp/WEB-INF/actions/ src/webapp/WEB-INF/tabs/ src/webapp/WEB-INF/velocity/ src/webapp/WEB-INF/view/security/
Date Thu, 21 Apr 2005 22:02:58 GMT
Author: clombart
Date: Thu Apr 21 15:02:56 2005
New Revision: 164131

URL: http://svn.apache.org/viewcvs?rev=164131&view=rev
Log:
Add permission management - still on dev.
Code clean-up should be interesting for the DTO management

Added:
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/SecurityAction.java
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/SecurityDTO.java
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/SecurityDTOUtil.java
    incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-browser.vm
    incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-permission.vm
Removed:
    incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security.vm
Modified:
    incubator/graffito/trunk/applications/browser/.classpath
    incubator/graffito/trunk/applications/browser/project.xml
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/PortletActionHandler.java
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/BrowserDTO.java
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/resources/messages.properties
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/BrowserDTOUtil.java
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/ServiceUtil.java
    incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/TemplateUtil.java
    incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/actions/actions.xml
    incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/portlet.xml
    incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/tabs/tabs.xml
    incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/velocity/graffito-macros.vm

Modified: incubator/graffito/trunk/applications/browser/.classpath
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/.classpath?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/.classpath (original)
+++ incubator/graffito/trunk/applications/browser/.classpath Thu Apr 21 15:02:56 2005
@@ -13,6 +13,8 @@
   </classpathentry>
   <classpathentry kind="var" path="MAVEN_REPO/portlet-api/jars/portlet-api-1.0.jar">
   </classpathentry>
+  <classpathentry kind="var" path="MAVEN_REPO/jetspeed2/jars/jetspeed-api-2.0-M3-dev.jar">
+  </classpathentry>
   <classpathentry kind="var" path="MAVEN_REPO/jetspeed2/jars/jetspeed-commons-2.0-M3-dev.jar">
   </classpathentry>
   <classpathentry kind="var" path="MAVEN_REPO/jetspeed2/jars/jetspeed-components-2.0-M3-dev.jar">

Modified: incubator/graffito/trunk/applications/browser/project.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/project.xml?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/project.xml (original)
+++ incubator/graffito/trunk/applications/browser/project.xml Thu Apr 21 15:02:56 2005
@@ -41,6 +41,16 @@
 		</dependency>
 		<dependency>
 			<groupId>jetspeed2</groupId>
+			<artifactId>jetspeed-api</artifactId>
+			<version>2.0-M3-dev</version>
+			<type>jar</type>
+			<properties>
+				<war.bundle>false</war.bundle>
+			</properties>
+		</dependency>
+		
+		<dependency>
+			<groupId>jetspeed2</groupId>
 			<artifactId>jetspeed-commons</artifactId>
 			<version>2.0-M3-dev</version>
 			<type>jar</type>

Modified: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java
(original)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/BrowserPortlet.java
Thu Apr 21 15:02:56 2005
@@ -24,13 +24,14 @@
 
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
-import javax.print.ServiceUI;
+
 
 import org.apache.portals.graffito.model.CmsObject;
 import org.apache.portals.graffito.model.Document;
 import org.apache.portals.graffito.model.Folder;
 import org.apache.portals.graffito.portlets.dto.BrowserDTO;
 import org.apache.portals.graffito.portlets.util.BrowserDTOUtil;
+import org.apache.portals.graffito.portlets.util.SecurityDTOUtil;
 import org.apache.portals.graffito.portlets.util.ServiceUtil;
 import org.apache.portals.graffito.portlets.util.TemplateUtil;
 
@@ -58,9 +59,13 @@
     private static final String DOCUMENT_TYPES_PARAM = "DocumentTypes";
     
     
-    /** Velocity variable to set the browser info object in the Velocity context */
+    /** Velocity variable to set the browser dto in the Velocity context */
     private static final String VELOCITY_BROWSER_DTO = "browserDTO";
     
+    /** Velocity variable to set the security dto in the Velocity context */
+    private static final String VELOCITY_SECURITY_DTO = "securityDTO";
+    
+    
     /** Velocity variable used to access to the browser templates */    
     private static final String VELOCITY_TEMPLATE_UTIL = "templateUtil";
     
@@ -187,7 +192,7 @@
         this.selectEditTemplate(browserDTO, request, response);
         velocityContext.put(VELOCITY_BROWSER_DTO, browserDTO);
         velocityContext.put(VELOCITY_TEMPLATE_UTIL, new TemplateUtil());
-        
+        velocityContext.put(VELOCITY_SECURITY_DTO, SecurityDTOUtil.getSecurityDTO(request));
         super.doEdit(request, response);
     }
 
@@ -371,7 +376,16 @@
             throw new PortletException("Failed to read the init paramater : template.upload.content");
         }
         TemplateUtil.setTemplateUploadContent(param);        
+
+        param = portletConfig.getInitParameter("template.edit.permission");
+        if (null == param)
+        {
+            throw new PortletException("Failed to read the init paramater : template.edit.permission");
+        }
+        TemplateUtil.setTemplateEditPermission(param);        
         
+        
+                
     }
 
 }

Modified: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/PortletActionHandler.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/PortletActionHandler.java?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/PortletActionHandler.java
(original)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/PortletActionHandler.java
Thu Apr 21 15:02:56 2005
@@ -98,10 +98,10 @@
     /**
      * Process an action from a portlet
      * 
-     * @param request
-     * @param response
+     * @param request The portlet request
+     * @param response The portlet response
      * 
-     * @return 
+     * @return 1 when the action has been executed, -1 if not. 
      * @throws PortletException   
      */
     public int processAction(ActionRequest request, ActionResponse response) throws PortletException
@@ -110,7 +110,15 @@
         return executePortletAction(portletActionInfo);
     }
     
-    private PortletActionInfo getSelectedAction(ActionRequest request, ActionResponse response)
throws PortletException
+    /**
+     * Get information the selected action
+     * @param request The portlet request
+     * @param response The response request
+     * @return information on the selected action ({@link PortletActionInfo})
+     * 
+     * @throws PortletException
+     */
+    public PortletActionInfo getSelectedAction(ActionRequest request, ActionResponse response)
throws PortletException
     {
         //-------------------------------------------------------------------------------------------
         // ! MULTIPART REQUEST
@@ -152,12 +160,19 @@
             }
             catch (FileUploadException e)
             {
-                throw new PortletException("Impossible to selection the action portlet",
e);                
+                throw new PortletException("Impossible to select the action portlet", e);
               
             }
             
         }
     }
     
+    /**
+     * Execute the desised action 
+     * 
+     * @param portletActionInfo
+     * @return 1 if the action is executed correctly, -1 when portlet info is null or the
the action class is not found
+     * @throws PortletException
+     */
     private int executePortletAction(PortletActionInfo portletActionInfo) throws PortletException
     {
         try

Added: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/SecurityAction.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/SecurityAction.java?rev=164131&view=auto
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/SecurityAction.java
(added)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/actions/SecurityAction.java
Thu Apr 21 15:02:56 2005
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.portals.graffito.portlets.actions;
+
+import java.security.Permission;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletException;
+
+import org.apache.jetspeed.security.SecurityException;
+import org.apache.portals.graffito.ContentPermissionService;
+import org.apache.portals.graffito.exception.ContentManagementException;
+import org.apache.portals.graffito.model.CmsPermission;
+import org.apache.portals.graffito.portlets.dto.BrowserDTO;
+import org.apache.portals.graffito.portlets.dto.SecurityDTO;
+import org.apache.portals.graffito.portlets.util.BrowserDTOUtil;
+import org.apache.portals.graffito.portlets.util.SecurityDTOUtil;
+import org.apache.portals.graffito.portlets.util.ServiceUtil;
+import org.apache.portals.graffito.portlets.util.TemplateUtil;
+
+
+
+/**
+ *  Portlet Action used to manage the Graffito Folders
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe
</a>
+ * @version $Id: Exp $
+ */
+public class SecurityAction extends GraffitoAction
+{
+
+    /**
+     * Create/instantiate a new empty permission
+     *  
+     * @param actionInfo The action info 
+     * @throws PortletException when it is not possible to create a new permission
+     */
+    public void create(PortletActionInfo actionInfo) throws PortletException
+    {
+        try
+        {
+            ActionRequest request = actionInfo.getActionRequest();           
+            
+            BrowserDTO browserDTO = BrowserDTOUtil.getBrowserDTO(request);
+            
+            ContentPermissionService permissionService = ServiceUtil.getPermissionService();
+            
+            CmsPermission cmsPermission = permissionService.createPermission(browserDTO.getUri(),
CmsPermission.ALL);
+            SecurityDTO securityDTO =  new SecurityDTO(SecurityDTO.INSERT, browserDTO.getUri(),
cmsPermission);
+            SecurityDTOUtil.setSecurityDTO(request, securityDTO);
+            
+            browserDTO.setTemplate(TemplateUtil.getTemplateEditPermission());
+            
+            
+        }
+        catch (ContentManagementException e)
+        {
+            throw new PortletException("Impossible to create a folder ", e);
+        }
+    }   
+        
+    
+    /**
+     * Save (insert or update a new permission 
+     * @param actionInfo The action info 
+     * @throws PortletException when it is not possible to save the permission
+     */
+    public void save(PortletActionInfo actionInfo) throws PortletException
+    {
+        try
+        {
+            ActionRequest request = actionInfo.getActionRequest();
+            SecurityDTO securityDTO = SecurityDTOUtil.getSecurityDTO(request);
+            
+            String permissionName =  request.getParameter("permissionName");
+            
+            String[] actionValues = request.getParameterValues("actions");
+            String actions = "";
+            for (int i=0; i<actionValues.length; i++)
+            {
+                if (i>0)
+                {
+                    actions += ",";
+                }
+                actions = actions + actionValues[i];
+            }
+            
+            String attributes = request.getParameter("attributes");
+            String principal = request.getParameter("principal");
+            
+            ContentPermissionService permissionService = ServiceUtil.getPermissionService();
+            if (securityDTO.isInsert())
+            {
+                if (attributes != null && ! attributes.equals(""))
+                {
+                    permissionName = permissionName + "/" + attributes;
+                }
+                CmsPermission permission =  permissionService.createPermission(permissionName,
actions );
+                permissionService.addPermission((Permission) permission);
+                
+                permissionService.grantPermission(principal, permission);               

+            }
+            BrowserDTO browserDTO = BrowserDTOUtil.getBrowserDTO(request);
+
+            browserDTO = BrowserDTOUtil.cleanBrowserDTO(request);
+            browserDTO.setTemplate(TemplateUtil.getTemplateEditFolder());
+            
+        }
+        catch (Exception e)
+        {
+            throw new PortletException("Impossible to insert a permission ", e);
+        }
+    }
+
+    /**
+     * Delete a permission
+     *  
+     * @param actionInfo The action info 
+     * @throws PortletException when it is not possible to create a new permission
+     */
+    public void delete(PortletActionInfo actionInfo) throws PortletException
+    {
+        try
+        {
+            ActionRequest request = actionInfo.getActionRequest();
+            // The http request contains an array of permissions to delete
+            // each string in this array is structured as 'permissionName_permissionAction'
+            String[] permissionToDelete = request.getParameterValues("selectedPermissions");
+            ContentPermissionService permissionService = ServiceUtil.getPermissionService();
+                        
+            for (int i = 0; i<permissionToDelete.length; i++)
+            {                 
+                String[] permissionDescription = permissionToDelete[i].split("_"); 
+                CmsPermission cmsPermission = permissionService.createPermission(permissionDescription[0],
permissionDescription[1]);               
+                permissionService.removePermission((Permission) cmsPermission);         
      
+            }
+            BrowserDTO browserDTO = BrowserDTOUtil.getBrowserDTO(request);
+            browserDTO = BrowserDTOUtil.cleanBrowserDTO(request);
+            browserDTO.setTemplate(TemplateUtil.getTemplateEditFolder());            
+        }
+        catch (Exception e)
+        {
+            throw new PortletException("Impossible to delete a permission", e);
+        }
+    }
+
+}

Modified: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/BrowserDTO.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/BrowserDTO.java?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/BrowserDTO.java
(original)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/BrowserDTO.java
Thu Apr 21 15:02:56 2005
@@ -12,9 +12,11 @@
  */
 package org.apache.portals.graffito.portlets.dto;
 
+import java.security.Permissions;
 import java.util.ArrayList;
 import java.util.Collection;
 
+
 import org.apache.portals.graffito.model.CmsObject;
 import org.apache.portals.graffito.model.Document;
 import org.apache.portals.graffito.model.Folder;
@@ -58,7 +60,7 @@
         
     /** Operation made on the displayed cms object (insert, update, delete) */
     private String operation;
-    
+            
     /** Insert operation */
     public static final String INSERT = "insert";
     
@@ -74,6 +76,7 @@
     /** Template used to view an HTML or text document */
     public static String templateViewHtmlText;
         
+    private Permissions permissions;
     
     /**
      * Contructor 
@@ -187,7 +190,7 @@
     {
         return currentServer;
     }
-    
+        
     /**
      * 
      * @param currentServer The current server to set
@@ -196,6 +199,24 @@
     {
         this.currentServer = currentServer;
     }
+    
+    /**    
+     * @return The permissions associated to the current cms object
+     */
+    public Permissions getPermissions()
+    {
+        return permissions;
+    }
+    
+    /**
+     * Set the permissions
+     * @param permissions The permissions to set
+     */
+    public void setPermissions(Permissions permissions)
+    {
+        this.permissions = permissions;    
+    }
+    
     
     public ArrayList getFolderPath()
     {

Added: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/SecurityDTO.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/SecurityDTO.java?rev=164131&view=auto
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/SecurityDTO.java
(added)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/dto/SecurityDTO.java
Thu Apr 21 15:02:56 2005
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.portals.graffito.portlets.dto;
+
+import java.security.Permission;
+import java.security.Permissions;
+import java.util.ArrayList;
+import java.util.Collection;
+
+
+import org.apache.portals.graffito.model.CmsObject;
+import org.apache.portals.graffito.model.CmsPermission;
+import org.apache.portals.graffito.model.Document;
+import org.apache.portals.graffito.model.Folder;
+import org.apache.portals.graffito.model.Server;
+
+/**
+ * Information on the current cms object permission.
+ * This is the DTO used between the velocity template and the portlet methods
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe
</a>
+ * @version $Id: Exp $
+ */
+public class SecurityDTO
+{   
+    /** Current uri */
+    private String  uri;
+
+    /** The permission to set to the cms object */
+    private CmsPermission cmsPermission;
+    
+    /** Operation made on the displayed cms object (insert, update, delete) */
+    private String operation;
+            
+    /** Insert operation */
+    public static final String INSERT = "insert";
+    
+    /** Update operation */
+    public static final String UPDATE = "update";
+    
+    /** Delete operation */
+    public static final String DELETE = "delete";
+    
+    
+    /**
+     * Contructor 
+     * 
+     * @param operation The current operation (add, delete, update a permission) 
+     * @param uri The current uri   
+     * @param cmsPermission The current permission
+     */
+    public SecurityDTO (String operation, String uri, CmsPermission cmsPermission)
+    {
+         this.operation = operation;
+         this.uri = uri;
+         this.cmsPermission = cmsPermission;
+    }
+    
+    
+    
+    public String getUri()
+    {
+        return uri;
+    }
+    public void setUri(String uri)
+    {
+        this.uri = uri;
+    }
+    /**    
+     * @return The permission associated to the current cms object
+     */
+    public CmsPermission getPermission()
+    {
+        return cmsPermission;
+    }
+    
+    /**
+     * Set the permission
+     * @param permission The permission to set
+     */
+    public void setPermission(CmsPermission cmsPermission)
+    {
+        this.cmsPermission = cmsPermission;    
+    }
+        
+    public String getOperation()
+    {
+        return operation;
+    }
+    
+    public void setOperation(String operation)
+    {
+        this.operation = operation;
+    }
+        
+    public boolean isUpdate()
+    {
+        if (this.operation == null)
+        {
+            return false ;
+        }        
+        return this.operation.equals(UPDATE);
+    }
+    
+    public boolean isInsert()
+    {
+        
+        if (this.operation == null)
+        {
+            return false ;
+        }
+        return this.operation.equals(INSERT);
+    }
+            
+}
\ No newline at end of file

Modified: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/resources/messages.properties
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/resources/messages.properties?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/resources/messages.properties
(original)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/resources/messages.properties
Thu Apr 21 15:02:56 2005
@@ -14,7 +14,11 @@
 div.folders = Folders
 div.folder = Folder
 div.documents = Documents 
+div.security = Apply access control in :
 div.server = Server
+div.permission = Permission
+
+div.newpermission= Add new permission for : 
 
 edit.tab.select=Select
 edit.tab.type=Type
@@ -24,16 +28,25 @@
 edit.tab.creationdate=Creation Date
 edit.tab.modificationdate=Modification Date
 
+edit.tab.scope=Scope
+edit.tab.actions=Actions
+edit.tab.principals= Users - Groups - Roles
+
+
 field.name = Name
 field.title= Title
 field.description= Description
 field.type= Document Type
 field.owner = Owner
 field.language = Document Language
+field.permissionActions = Actions
+field.permissionAttributes = Scope
+field.permissionPrincipals =  User - Group - Role
 
 link.addfolder= Add Folder
 link.adddocument = Add Document
 link.delete = Delete
+link.addPermission = Add Permission
 
 file.upload=Select a file to upload
 
@@ -41,8 +54,10 @@
 tab.folder-edit.metadata = Folder Info
 tab.document-edit.content= Document Content
 tab.document-edit.metadata = Document Info
+tab.security = Security
 
 info.nocontent= No content found in this folder.
+info.nopermission= No permission found
 error.servers=No content server found
 
 document.type.upload = Updload a Document 
@@ -52,4 +67,13 @@
 
 
 document.en = English
-document.fr = French
\ No newline at end of file
+document.fr = French
+
+permission.simple=Apply only on the current cms object
+permission.recursive=Apply on all documents & each subfolders
+permission.wildcard = Apply on this level (not on subfolders)
+
+permission.actions.all = All actions
+permission.actions.view = View
+permission.actions.edit = Edit
+permission.actions.insert = Insert

Modified: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/BrowserDTOUtil.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/BrowserDTOUtil.java?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/BrowserDTOUtil.java
(original)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/BrowserDTOUtil.java
Thu Apr 21 15:02:56 2005
@@ -15,6 +15,7 @@
  */
 package org.apache.portals.graffito.portlets.util;
 
+import java.security.Permissions;
 import java.util.List;
 
 import javax.portlet.PortletException;
@@ -24,9 +25,8 @@
 import javax.portlet.RenderResponse;
 
 
-import org.apache.jetspeed.services.JetspeedPortletServices;
-import org.apache.jetspeed.services.PortletServices;
 import org.apache.portals.graffito.ContentModelService;
+import org.apache.portals.graffito.ContentPermissionService;
 import org.apache.portals.graffito.ContentServerService;
 import org.apache.portals.graffito.exception.ContentManagementException;
 import org.apache.portals.graffito.model.CmsObject;
@@ -42,8 +42,8 @@
  */
 public class BrowserDTOUtil
 {
-    /** Portlet session attribute name used to set the Browser info */
-    private static final String SESSION_BROWSER_INFO = "graffito.browser.info";
+    /** Portlet session attribute name used to set the Browser dto */
+    private static final String SESSION_BROWSER_DTO = "graffito.browser.dto";
 
     /**
      * Get the Browser DTO found in the portlet session
@@ -53,7 +53,7 @@
      */
     public static BrowserDTO getBrowserDTO(PortletRequest request)
     {
-        return (BrowserDTO) request.getPortletSession().getAttribute(SESSION_BROWSER_INFO,
PortletSession.PORTLET_SCOPE);
+        return (BrowserDTO) request.getPortletSession().getAttribute(SESSION_BROWSER_DTO,
PortletSession.PORTLET_SCOPE);
     }
 
     /**
@@ -64,7 +64,7 @@
      */
     public static void setBrowserDTO(PortletRequest request, BrowserDTO browserDTO)
     {
-        request.getPortletSession().setAttribute(SESSION_BROWSER_INFO, browserDTO);
+        request.getPortletSession().setAttribute(SESSION_BROWSER_DTO, browserDTO);
     }
 
     /**
@@ -74,7 +74,7 @@
      */
     public static void removeBrowserDTO(PortletRequest request)
     {
-        request.getPortletSession().removeAttribute(SESSION_BROWSER_INFO);
+        request.getPortletSession().removeAttribute(SESSION_BROWSER_DTO);
     }
     
     /**
@@ -117,25 +117,30 @@
         {
             BrowserDTO browserDTO = new BrowserDTO(uri, documentTypes, documentLanguages);
             
-            PortletServices services = JetspeedPortletServices.getSingleton();
-            ContentModelService modelService =  (ContentModelService) services.getService("ContentModel");
-            ContentServerService serverService =  (ContentServerService) services.getService("ContentServer");
+            ContentModelService modelService =  ServiceUtil.getModelService();
+            ContentServerService serverService =  ServiceUtil.getServerService();
+            ContentPermissionService contentPermissionService = ServiceUtil.getPermissionService();
+            
+            String scopeServer = UriUtil.getServerScope(uri);
+            browserDTO.setCurrentServer(serverService.getServer(scopeServer));
+                        
             CmsObject cmsObject = modelService.getCmsObject(uri);
             browserDTO.setCurrentCmsObject(cmsObject);
+                        
             if ((cmsObject instanceof Folder) || (cmsObject == null)) // cms object is null
if the uri match to a server root
             {
                 browserDTO.setDocuments(modelService.getDocuments(uri));
                 browserDTO.setFolders(modelService.getFolders(uri));
-                browserDTO.setCurrentFolder(modelService.getFolder(uri));
-
+                browserDTO.setCurrentFolder(modelService.getFolder(uri));               

             }
             else
             {
-                browserDTO.setCurrentFolder(cmsObject.getParentFolder());
+                browserDTO.setCurrentFolder(cmsObject.getParentFolder());               

             }
-            String scopeServer = UriUtil.getServerScope(uri);
-            browserDTO.setCurrentServer(serverService.getServer(scopeServer));
 
+            Permissions permissions = contentPermissionService.getPermissions(uri);     
            
+            browserDTO.setPermissions(permissions);                          
+            
             return browserDTO;
 
         }

Added: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/SecurityDTOUtil.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/SecurityDTOUtil.java?rev=164131&view=auto
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/SecurityDTOUtil.java
(added)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/SecurityDTOUtil.java
Thu Apr 21 15:02:56 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.portals.graffito.portlets.util;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+
+import org.apache.portals.graffito.portlets.dto.SecurityDTO;
+
+
+/**
+ * Utility class used to manage SecurityDTO from the portlet session
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe
</a>
+ * @version $Id: Exp $
+ */
+public class SecurityDTOUtil
+{
+    /** Portlet session attribute name used to set the security dto */
+    private static final String SESSION_SECURITY_DTO = "graffito.security.dto";
+
+    /**
+     * Get the Security DTO found in the portlet session
+     * 
+     * @param request The portlet request
+     * @return The Security DTO found or null
+     */
+    public static SecurityDTO getSecurityDTO(PortletRequest request)
+    {
+        return (SecurityDTO) request.getPortletSession().getAttribute(SESSION_SECURITY_DTO,
PortletSession.PORTLET_SCOPE);
+    }
+
+    /**
+     * Set the a new Security DTO in the portlet session
+     *  
+     * @param request The portlet Request
+     * @param securityDTO the new Browser DTO
+     */
+    public static void setSecurityDTO(PortletRequest request, SecurityDTO securityDTO)
+    {
+        request.getPortletSession().setAttribute(SESSION_SECURITY_DTO, securityDTO);
+    }
+
+    /**
+     * Remove the current Browser DTO from the portlet session
+     * 
+     * @param request The portlet request
+     */
+    public static void removeSecurityDTO(PortletRequest request)
+    {
+        request.getPortletSession().removeAttribute(SESSION_SECURITY_DTO);
+    }
+    
+    
+}

Modified: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/ServiceUtil.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/ServiceUtil.java?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/ServiceUtil.java
(original)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/ServiceUtil.java
Thu Apr 21 15:02:56 2005
@@ -15,9 +15,11 @@
  */
 package org.apache.portals.graffito.portlets.util;
 
+import org.apache.jetspeed.security.UserManager;
 import org.apache.jetspeed.services.JetspeedPortletServices;
 import org.apache.jetspeed.services.PortletServices;
 import org.apache.portals.graffito.ContentModelService;
+import org.apache.portals.graffito.ContentPermissionService;
 import org.apache.portals.graffito.ContentServerService;
 
 /**
@@ -43,6 +45,18 @@
         return (ContentServerService) services.getService("ContentServer");
     }
 
+    public static ContentPermissionService getPermissionService()
+    {
+        PortletServices services = JetspeedPortletServices.getSingleton();
+        return (ContentPermissionService) services.getService("PermissionManager");
+    }
+    
+    public static UserManager getUserService()
+    {
+        PortletServices services = JetspeedPortletServices.getSingleton();
+        return (UserManager) services.getService("UserManager");
+    }    
+    
     public static String getUploadFolder()
     {
         return uploadFolder;
@@ -52,4 +66,7 @@
     {
         ServiceUtil.uploadFolder = uploadFolder;
     }
+
+
+    
 }

Modified: incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/TemplateUtil.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/TemplateUtil.java?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/TemplateUtil.java
(original)
+++ incubator/graffito/trunk/applications/browser/src/java/org/apache/portals/graffito/portlets/util/TemplateUtil.java
Thu Apr 21 15:02:56 2005
@@ -50,7 +50,8 @@
     /** Template used to insert a new uploaded document (set the content) */
     private static String templateUploadContent;
  
-    
+    /** Template used to edit a permission */
+    private static String templateEditPermission;
     
     public static String getTemplateViewFolder()
     {
@@ -136,5 +137,15 @@
     public static void setTemplateUploadContent(String templateUploadContent)
     {
         TemplateUtil.templateUploadContent = templateUploadContent;
+    }
+    
+    
+    public static String getTemplateEditPermission()
+    {
+        return templateEditPermission;
+    }
+    public static void setTemplateEditPermission(String templateEditPermission)
+    {
+        TemplateUtil.templateEditPermission = templateEditPermission;
     }
 }

Modified: incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/actions/actions.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/actions/actions.xml?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/actions/actions.xml (original)
+++ incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/actions/actions.xml Thu
Apr 21 15:02:56 2005
@@ -2,4 +2,5 @@
 	<action id="cmsobject" class="org.apache.portals.graffito.portlets.actions.CmsObjectAction"
/>		
 	<action id="folder" class="org.apache.portals.graffito.portlets.actions.FolderAction"
/>	
     <action id="document" class="org.apache.portals.graffito.portlets.actions.DocumentAction"
/>
+    <action id="security" class="org.apache.portals.graffito.portlets.actions.SecurityAction"
/>
 </actions>

Modified: incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/portlet.xml?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/portlet.xml (original)
+++ incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/portlet.xml Thu Apr 21
15:02:56 2005
@@ -93,7 +93,11 @@
 			<name>DocumentLanguages</name>			
 			<value>document.en,document.fr</value>
 		</init-param>
-		
+		<init-param>
+			<name>template.edit.permission</name>
+			<value>/WEB-INF/view/security/security-permission.vm</value>
+		</init-param>	
+			
 		<expiration-cache>-1</expiration-cache>
 		<supports>
 			<mime-type>text/html</mime-type>

Modified: incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/tabs/tabs.xml
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/tabs/tabs.xml?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/tabs/tabs.xml (original)
+++ incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/tabs/tabs.xml Thu Apr
21 15:02:56 2005
@@ -2,11 +2,11 @@
 	<tab id="folder-edit">
 	    <page id="children" label="tab.folder-edit.children" view= "/WEB-INF/view/folder/folder-children.vm"
/>
   	    <page id="metadata" label="tab.folder-edit.metadata" view= "/WEB-INF/view/folder/folder-metadata.vm"
/>
-  	    <page id="security" label="tab.security" view= "/WEB-INF/view/security/security.vm"
/>		
+  	    <page id="security" label="tab.security" view= "/WEB-INF/view/security/security-browser.vm"
/>		
 	</tab>	
 	<tab id="document-edit">
 	    <page id="content" label="tab.document-edit.content" view= "/WEB-INF/view/document/document-content.vm"
/>
   	    <page id="metadata" label="tab.document-edit.metadata" view= "/WEB-INF/view/document/document-edit-metadata.vm"
/>
-		<page id="security" label="tab.security" view= "/WEB-INF/view/security/security.vm"
/>		
+		<page id="security" label="tab.security" view= "/WEB-INF/view/security/security-browser.vm"
/>		
 	</tab>
 </tabs>

Modified: incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/velocity/graffito-macros.vm
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/velocity/graffito-macros.vm?rev=164131&r1=164130&r2=164131&view=diff
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/velocity/graffito-macros.vm
(original)
+++ incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/velocity/graffito-macros.vm
Thu Apr 21 15:02:56 2005
@@ -75,6 +75,51 @@
 	</tr>
 #end
 
+#macro (formFieldMultiSelectDescription $label $elements $descriptionKeys $id $MESSAGES $ERRORS)
+	#if ($ERRORS)
+		#set ($eflag = "$!ERRORS.get($id)")
+	#else
+		#set ($eflag = "")
+	#end
+	<tr>
+        <th class="portlet-section-alternate"><font class="portlet-form-field-label">$!MESSAGES.getString($label)</font></th>
			
+		<td>
+ 		  <select name="$id" multiple="true" class="portlet-form-field-label">		
+		          #foreach($element in $elements)
+                        #set($index = $velocityCount - 1)
+					    <option value="$element">
+							$MESSAGES.getString($descriptionKeys.get($index))								
+					    </option>
+  				  #end
+		  </select> 
+		</td>
+	</tr>
+#end
+
+
+ 
+#macro (formFieldSelectDescription $label $elements $descriptionKeys $id $MESSAGES $ERRORS)
+	#if ($ERRORS)
+		#set ($eflag = "$!ERRORS.get($id)")
+	#else
+		#set ($eflag = "")
+	#end
+	
+	<tr>
+        <th class="portlet-section-alternate"><font class="portlet-form-field-label">$!MESSAGES.getString($label)</font></th>
			
+		<td>
+ 		  <select name="$id" class="portlet-form-field-label">		
+		          #foreach($element in $elements)
+                        #set($index = $velocityCount - 1)
+					    <option value="$element">
+							$MESSAGES.getString($descriptionKeys.get($index))								
+					    </option>
+  				  #end
+		  </select> 
+		</td>
+	</tr>
+#end
+
 #macro (formFieldTextArea $content $id $MESSAGES $ERRORS)
 	#if ($ERRORS)
 		#set ($eflag = "$!ERRORS.get($id)")
@@ -154,4 +199,32 @@
 	<font class="portlet-section-text">$document.getDescription()</font>
 	<br><br><br>
     
+#end
+
+#macro (permissionAttributes $cmsPermission $MESSAGES)
+     #set($attributes = $MESSAGES.getString("permission.simple"))
+	 #if ($cmsPermission.isRecursive())	
+		#set($attributes = $MESSAGES.getString("permission.recursive"))
+	 #end
+
+	 #if ($cmsPermission.isApplyToChildren())
+		#set($attributes = $MESSAGES.getString("permission.wildcard")) 
+	 #end	 
+	 $attributes
+#end
+
+#macro (permissionPrincipals $cmsPermission)
+	
+	#set($principals  = $cmsPermission.getPrincipalFullPaths())
+	#set($allPrincipals = "")
+	#foreach($principal in $principals)
+		#if ($velocityCount == 1)
+			#set($allPrincipals = $principal)
+		#else	
+		    #set($allPrincipals = "$allPrincipals, $principal") 
+		#end	
+	#end
+	
+	$allPrincipals
+	
 #end

Added: incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-browser.vm
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-browser.vm?rev=164131&view=auto
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-browser.vm
(added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-browser.vm
Thu Apr 21 15:02:56 2005
@@ -0,0 +1,66 @@
+#*
+Copyright 2004 The Apache Software Foundation
+
+Licensed 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.
+*#
+
+#**
+
+@author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+@version $Id:  Exp $
+
+*#
+#set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))
+#set ($permissions = $browserDTO.getPermissions())
+#set ($document = $browserDTO.getCurrentCmsObject())
+
+<form action="$renderResponse.createActionURL()" method="post">
+    <input type="hidden" name="uri" value="$document.getUri()" size="100" maxlength="100"/>
+	#set ($count = 0)
+	#if($permission.isEmpty())
+		<div class="portlet-msg-info">$MESSAGES.getString('info.nopermission')</div>
+	#else
+	<table>
+			
+		<tr>
+			<th class="portlet-section-header">$MESSAGES.getString('edit.tab.select')</th>
+			<th class="portlet-section-header">$MESSAGES.getString('edit.tab.scope')</th>
+			<th class="portlet-section-header">$MESSAGES.getString('edit.tab.actions')</th>
+			<th class="portlet-section-header">$MESSAGES.getString('edit.tab.principals')</th>
+		</tr>
+
+		#foreach ($permission in $permissions.elements())
+			#set ($count = $count + 1)				
+			#set ($cssClass = "portlet-section-alternate")
+			#if (($count % 2)==0)
+				#set ($cssClass = "portlet-section-body")
+			#end	
+			<tr>
+				<td class="$cssClass"><input type="checkbox" name="selectedPermissions" value="$permission.getName()_$permission.getActions()"
/></td>
+				<td class="$cssClass">#permissionAttributes($permission $MESSAGES)</td>
+				<td class="$cssClass">$permission.getActions()</td>
+				<td class="$cssClass">#permissionPrincipals($permission)</td>
+			</tr>
+			
+		#end
+		
+	</table>	
+	#end
+	
+	<div class="portlet-menu">
+		<input type="submit" name="portletAction_security.create" value="$MESSAGES.getString('link.addPermission')"
class="portlet-dlg-icon-label" />	
+		<input type="submit" name="portletAction_security.delete" value="$MESSAGES.getString('link.delete')"
class="portlet-dlg-icon-label" />	
+	</div>
+	
+</form>
+#ErrorMessages($ERRORS)

Added: incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-permission.vm
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-permission.vm?rev=164131&view=auto
==============================================================================
--- incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-permission.vm
(added)
+++ incubator/graffito/trunk/applications/browser/src/webapp/WEB-INF/view/security/security-permission.vm
Thu Apr 21 15:02:56 2005
@@ -0,0 +1,44 @@
+#*
+Copyright 2004 The Apache Software Foundation
+
+Licensed 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.
+*#
+
+#**
+
+@author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+@version $Id:  Exp $
+
+*#
+#set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))
+#set ($cmsPermission = $securityDTO.getPermission())
+
+#if($securityDTO.isInsert())
+   <div class="portlet-menu">$MESSAGES.getString('div.newpermission') #cmsPathLink($browserDTO.getCurrentServer()
$browserDTO.getFolderPath() $renderResponse $MESSAGES ) </div>
+#end
+<div class="portlet-section-header">$MESSAGES.getString('div.permission')</div>
+
+<form action="$renderResponse.createActionURL()" method="post">
+    <input type="hidden" name="permissionName" value="$!cmsPermission.getName()" size="100"
maxlength="100"/>	
+  	<table border="0" cellspacing="2" cellpadding="3">		    		
+	   #formFieldMultiSelectDescription('field.permissionActions' ['all', 'view', 'edit'] ['permission.actions.all',
'permission.actions.view', 'permission.actions.edit'] 'actions' $MESSAGES $ERRORS)
+	   #formFieldSelectDescription('field.permissionAttributes' ['*', '-', ''] ['permission.wildcard',
'permission.recursive', 'permission.simple'] 'attributes' $MESSAGES $ERRORS)
+       #formFieldInput('field.permissionPrincipals' "#permissionPrincipals($permission)"
"25" 'principal' $MESSAGES $ERRORS)				
+   	</table>
+   	<div class="portlet-section-footer">
+ 		<input type="submit" name="portletAction_security.save" value="Save" class="portlet-dlg-icon-label"/>
+
+   	</div>
+</form>
+
+#ErrorMessages($ERRORS)



Mime
View raw message