portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smi...@apache.org
Subject svn commit: r595431 [1/2] - in /portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed: decoration/ desktop/impl/ layout/ajax-xml/ layout/impl/
Date Thu, 15 Nov 2007 20:21:27 GMT
Author: smilek
Date: Thu Nov 15 12:21:24 2007
New Revision: 595431

URL: http://svn.apache.org/viewvc?rev=595431&view=rev
Log:
major improvements to desktop page editor (UI, config options, flow, no action layouts); support for create-new-page-on-edit

Modified:
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/userinfo.vm
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/AddPortletAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseUserAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/ChangePortletAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/MovePortletAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityConstraintsBehavior.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathBehavior.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletActionSecurityPathMergeBehavior.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/PortletPlacementContextImpl.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/RemovePortletAction.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/RolesSecurityBehavior.java
    portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/SecurityConstraintsAction.java

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationFactoryImpl.java Thu Nov 15 12:21:24 2007
@@ -33,6 +33,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.cache.CacheElement;
+import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.decoration.caches.SessionPathResolverCache;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
@@ -63,6 +65,9 @@
     private final ResourceValidator validator;
     private final PortletRegistry registry;
     
+    /** cache to hold decoration Properties objects **/
+    private JetspeedCache decorationConfigurationCache;
+    
     private ServletContext servletContext;
 
     private String defaultDesktopLayoutDecoration = null;
@@ -84,12 +89,20 @@
     public DecorationFactoryImpl( String decorationsPath, 
                                   ResourceValidator validator )
     {
-        this( null, decorationsPath, validator );
+        this( null, decorationsPath, validator, null );
+    }
+    
+    public DecorationFactoryImpl( String decorationsPath, 
+                                  ResourceValidator validator,
+                                  JetspeedCache decorationConfigurationCache )
+    {
+        this( null, decorationsPath, validator, decorationConfigurationCache );
     }
 
     public DecorationFactoryImpl( PortletRegistry registry,
-            String decorationsPath, 
-            ResourceValidator validator )
+                                  String decorationsPath, 
+                                  ResourceValidator validator,
+                                  JetspeedCache decorationConfigurationCache )
     {
         this.registry =  registry;
         this.decorationsPath = new Path( decorationsPath );
@@ -98,12 +111,18 @@
         this.portletDecorationsPath = getBasePath( Fragment.PORTLET );
         this.portletDecorationsPathStr = this.portletDecorationsPath.toString();
         this.validator = validator;
+        this.decorationConfigurationCache = decorationConfigurationCache;
     }
         
     public ResourceValidator getResourceValidator()
     {
         return validator;
-    }    
+    }
+    
+    protected JetspeedCache getDecorationConfigurationCache()
+    {
+    	return decorationConfigurationCache;
+    }
 
     public Theme getTheme( Page page, RequestContext requestContext )
     {
@@ -186,6 +205,50 @@
 
     }
 
+    protected Properties getCachedConfiguration( String name, String type )
+    {
+    	if ( decorationConfigurationCache == null )
+    	{
+    		if ( type.equals( Fragment.PORTLET ) )
+    		{
+    			return (Properties)this.portletDecoratorProperties.get( name );
+    		}
+    		else
+    		{
+    			return (Properties)this.layoutDecoratorProperties.get( name );
+    		}
+    	}
+    	CacheElement cachedElement = decorationConfigurationCache.get( getCachedConfigurationKey( type, name ) );
+        if (cachedElement != null)
+        	return (Properties)cachedElement.getContent();  
+        return null;
+    }
+    protected void setCachedConfiguration( String name, String type, Properties props )
+    {
+    	if ( decorationConfigurationCache == null )
+    	{
+    		if ( type.equals( Fragment.PORTLET ) )
+    		{
+    			this.portletDecoratorProperties.put( name, props );
+    		}
+    		else
+    		{
+    			this.layoutDecoratorProperties.put( name, props );
+    		}
+    	}
+    	else
+    	{
+    		CacheElement cachedElement = decorationConfigurationCache.createElement( getCachedConfigurationKey( type, name ), props );
+    		cachedElement.setTimeToIdleSeconds(decorationConfigurationCache.getTimeToIdleSeconds());
+    		cachedElement.setTimeToLiveSeconds(decorationConfigurationCache.getTimeToLiveSeconds());
+    		decorationConfigurationCache.put( cachedElement );
+    	}
+    }
+    protected String getCachedConfigurationKey( String type, String name )
+    {
+    	return type + "."  + name;
+    }
+    
     /**
      * Gets the configuration (decorator.properties) object for the decoration.
      * @param name Name of the Decoration.
@@ -194,15 +257,7 @@
      */
     public Properties getConfiguration( String name, String type )
     {
-        Properties props = null;
-        if ( type.equals( Fragment.PORTLET ) )
-        {
-            props = (Properties)this.portletDecoratorProperties.get( name );
-        }
-        else
-        {
-            props = (Properties)this.layoutDecoratorProperties.get( name );
-        }        
+        Properties props = getCachedConfiguration( name, type );
         if ( props != null )
         {
             return props;
@@ -305,15 +360,9 @@
                 props.setProperty( Decoration.DESKTOP_SUPPORTED_PROPERTY, "false" );
             }
         }
-
-        if ( type.equals( Fragment.PORTLET ) )
-        {
-            this.portletDecoratorProperties.put( name, props );
-        }
-        else
-        {
-            this.layoutDecoratorProperties.put( name, props );
-        }
+        
+        setCachedConfiguration( name, type, props );
+        
         return props;
     }
     

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java Thu Nov 15 12:21:24 2007
@@ -20,6 +20,7 @@
 import java.util.Iterator;
 import java.util.ResourceBundle;
 import java.util.Set;
+import java.util.Random;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletContext;
@@ -52,6 +53,8 @@
  */
 public class JetspeedDesktopImpl implements JetspeedDesktop, ServletContextAware
 {
+	private static final Log log = LogFactory.getLog( JetspeedDesktopImpl.class );
+	
     private final static String EOL = "\r\n";   // html eol
     private final static String DOJO_CONFIG_LAYOUT_DECORATION_PATH_VAR_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".layoutDecorationPath";
     private final static String DOJO_CONFIG_LAYOUT_VAR_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".layoutName";
@@ -62,14 +65,19 @@
     private final static String DOJO_CONFIG_LOADING_IMGPROPS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".loadingImgProps";
     private final static String DOJO_CONFIG_PAGEEDITOR_LABELS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".pageEditorLabels";
     private final static String DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".pageEditorDialogLabels";
+    private final static String DOJO_CONFIG_PAGEEDITOR_SETTINGS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".pec";
     
     private final static String[] DESKTOP_LOADING_PROPERTY_NAMES = new String[] 
+                                                                 { "dir", "animated", "stepprefix", "stepextension", "steps"
+                                                                 };
+    private final static String[] DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES = new String[] 
                                                                  { "imgdir", "imganimated", "imgstepprefix", "imgstepextension", "imgsteps"
                                                                  };
     private final static String[] DESKTOP_ACTION_RESOURCE_NAMES = new String[] 
                                                                  { "menu", "tile", "untile", "heightexpand", "heightnormal",
     															   "restore", "removeportlet", "minimized", "maximized", "normal",
-    															   "help", "edit", "view", "print", "addportlet", "editpage", 
+    															   "help", "edit", "view", "print", "config", "edit_defaults", "about",
+    															   "addportlet", "editpage", 
     															   "movetiled", "moveuntiled", "loadpage", "loadpageeditor",
     															   "loadportletrender", "loadportletaction", "loadportletupdate"
     															 };
@@ -84,13 +92,64 @@
     	                                                           "newpage_title", "newpage_titleshort", "deletepage", "deletelayout",
     	                                                           "removeportlet", "ok", "cancel", "yes", "no"
                                                                  };
-    private final static String DESKTOP_LOADING_PROPERTY_NAME_PREFIX = "desktop.loading.";
-    private final static String DESKTOP_ACTION_RESOURCE_NAME_PREFIX = "desktop.action.";
-    private final static String DESKTOP_PAGEEDITOR_RESOURCE_NAME_PREFIX = "desktop.pageeditor.";
-    private final static String DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAME_PREFIX = "desktop.pageeditor.dialog.";
     
-    private static final Log log = LogFactory.getLog( JetspeedDesktopImpl.class );
+    private final static String DESKTOP_LOADING_NAME_PREFIX = "desktop.loading.";
+    private final static String DESKTOP_ACTION_NAME_PREFIX = "desktop.action.";
+    private final static String DESKTOP_PAGEEDITOR_NAME_PREFIX = "desktop.pageeditor.";
+    
+    private final static String DESKTOP_LOADING_IMG_NAME_PREFIX = DESKTOP_LOADING_NAME_PREFIX + "img.";
+    private final static String DESKTOP_ACTION_RESOURCE_NAME_PREFIX = DESKTOP_ACTION_NAME_PREFIX + "labels.";
+    private final static String DESKTOP_PAGEEDITOR_RESOURCE_NAME_PREFIX = DESKTOP_PAGEEDITOR_NAME_PREFIX + "labels.";
+    private final static String DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAME_PREFIX = DESKTOP_PAGEEDITOR_NAME_PREFIX + "dialog.labels.";
+    
+    private final static String DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.layout.decorator.editable";
+    private final static String DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_DEFAULT = "true";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.name.editable";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_DEFAULT = "true";
+    
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.columnsize.editable";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_DEFAULT = "true";
+    
+    private final static String DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.add.enabled";
+    private final static String DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_DEFAULT = "true";
+    private final static String DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED = DESKTOP_PAGEEDITOR_NAME_PREFIX + "portlet.add.enabled";
+    private final static String DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_DEFAULT = "true";
+    private final static String DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.portlet.decorator.editable";
+    private final static String DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_DEFAULT = "true";
+    private final static String DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "portlet.decorator.editable";
+    private final static String DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_DEFAULT = "true";
+    
+    private final static String DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT = DESKTOP_PAGEEDITOR_NAME_PREFIX + "movemode.isdefault";
+    private final static String DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_DEFAULT = "true";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.editable";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_DEFAULT = "false";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.toplevel.moveable";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_DEFAULT = "false";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.columnsize.editable";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_DEFAULT = "false";
+    
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.editor.role";
+    private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE_DEFAULT = null;
+    
+    private final static String DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.layout.depth.max";
+    private final static int DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_DEFAULT = 2;                     // allowed range is 0-15
 
+    private final static int DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_RESERVED =              0x000F;  // max layout depth (0-15) is first 4 bits
+    private final static int DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_TRUE =         0x0010;
+    private final static int DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_TRUE =                   0x0020;
+    private final static int DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_TRUE =             0x0040;
+    private final static int DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_TRUE =                       0x0080;
+    private final static int DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_TRUE =                    0x0100;
+    private final static int DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_TRUE =        0x0200;
+    private final static int DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_TRUE =             0x0400;
+    private final static int DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_TRUE =                     0x0800;
+    private final static int DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_TRUE =              0x1000;
+    private final static int DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_TRUE =     0x2000;
+    private final static int DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_TRUE =   0x4000;
+    // algorithm used below and on client-size doesn't allow for further expansion (i.e. allows for expansion up to 0x4000)
+    //   (i.e. use of 0x8000 would break algorithm - because it would introduce the possibility of values close to 0xFFFF)
+    //   - if needed, add another variable for a fresh set of flags (and adjust the dependencies)
+            
     private DecorationFactory decorationFactory;
         
     /** desktop pipeline servlet path */
@@ -105,20 +164,38 @@
     /** tool for directing output to html <head> */
     private HeaderResourceFactory headerResourceFactory;
     
+    /** cache to minimize production of generated desktop configuration content **/
     private JetspeedCache desktopContentCache;
-    
+        
     /** base portal URL to override default URL server info from servlet */
     private BasePortalURL baseUrlAccess = null;
     
-    public JetspeedDesktopImpl( DecorationFactory decorationFactory, HeaderResourceFactory headerResourceFactory, JetspeedCache desktopContentCache, String desktopServletPath, String defaultLayoutTemplateExtension )
+    public JetspeedDesktopImpl( DecorationFactory decorationFactory,
+    						    HeaderResourceFactory headerResourceFactory,
+    						    JetspeedCache desktopContentCache,
+    						    String desktopServletPath,
+    						    String defaultLayoutTemplateExtension )
     {
         this( decorationFactory, headerResourceFactory, desktopContentCache, desktopServletPath, defaultLayoutTemplateExtension, null, null, null );
     }
-    public JetspeedDesktopImpl( DecorationFactory decorationFactory, HeaderResourceFactory headerResourceFactory, JetspeedCache desktopContentCache, String desktopServletPath, String defaultLayoutTemplateExtension, String defaultDesktopLayoutDecoration, String defaultDesktopPortletDecoration )
+    public JetspeedDesktopImpl( DecorationFactory decorationFactory,
+                                HeaderResourceFactory headerResourceFactory,
+                                JetspeedCache desktopContentCache,
+                                String desktopServletPath,
+                                String defaultLayoutTemplateExtension,
+                                String defaultDesktopLayoutDecoration,
+                                String defaultDesktopPortletDecoration )
     {
-        this( decorationFactory, headerResourceFactory, desktopContentCache, desktopServletPath, defaultLayoutTemplateExtension, defaultDesktopLayoutDecoration, defaultDesktopPortletDecoration, null );
+    	this( decorationFactory, headerResourceFactory, desktopContentCache, desktopServletPath, defaultLayoutTemplateExtension, defaultDesktopLayoutDecoration, defaultDesktopPortletDecoration, null );
     }
-    public JetspeedDesktopImpl( DecorationFactory decorationFactory, HeaderResourceFactory headerResourceFactory, JetspeedCache desktopContentCache, String desktopServletPath, String defaultLayoutTemplateExtension, String defaultDesktopLayoutDecoration, String defaultDesktopPortletDecoration, BasePortalURL baseUrlAccess )
+    public JetspeedDesktopImpl( DecorationFactory decorationFactory,
+    		                    HeaderResourceFactory headerResourceFactory,
+    		                    JetspeedCache desktopContentCache,
+    		                    String desktopServletPath,
+    		                    String defaultLayoutTemplateExtension,
+    		                    String defaultDesktopLayoutDecoration,
+    		                    String defaultDesktopPortletDecoration,
+    		                    BasePortalURL baseUrlAccess )
     {
         this.decorationFactory = decorationFactory;
         this.headerResourceFactory = headerResourceFactory;
@@ -155,7 +232,7 @@
                 decorationFactory.setDefaultDesktopPortletDecoration( defaultDesktopPortletDecoration );
             }
         }
-        
+                
         this.baseUrlAccess = baseUrlAccess;
     }
 
@@ -203,7 +280,7 @@
 	            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_LAYOUT_DECORATION_PATH_VAR_NAME ).append( " = \"" ).append( desktopContext.getLayoutBasePath() ).append( "\";" ).append( EOL );
 	            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_LAYOUT_VAR_NAME ).append( " = \"" ).append( layoutDecorationName ).append( "\";" ).append( EOL );
 	            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PORTLET_DECORATIONS_PATH_VAR_NAME ).append( " = \"" ).append( portletDecorationsBasePath ).append( "\";" ).append( EOL );
-	            
+
 	            LayoutDecoration desktopLayoutDecoration = decorationFactory.getLayoutDecoration( layoutDecorationName, request );
 	            if ( desktopLayoutDecoration != null )
 	            {
@@ -212,7 +289,7 @@
 	                loadingPropsBuffer.append( "    " ).append( DOJO_CONFIG_LOADING_IMGPROPS_NAME ).append( " = { " );
 	                for ( int i = 0 ; i < DESKTOP_LOADING_PROPERTY_NAMES.length ; i++ )
 	                {
-	                    String propValue = desktopLayoutDecoration.getProperty( DESKTOP_LOADING_PROPERTY_NAME_PREFIX + DESKTOP_LOADING_PROPERTY_NAMES[ i ] );
+	                    String propValue = desktopLayoutDecoration.getProperty( DESKTOP_LOADING_IMG_NAME_PREFIX + DESKTOP_LOADING_PROPERTY_NAMES[ i ] );
 	                    if ( propValue != null )
 	                    {
 	                        if ( atLeastOneFound )
@@ -223,12 +300,18 @@
 	                        {
 	                        	atLeastOneFound = true;
 	                        }
-	                        loadingPropsBuffer.append( DESKTOP_LOADING_PROPERTY_NAMES[ i ] ).append( ": " ).append( propValue );
+	                        String usePropertyName = DESKTOP_LOADING_PROPERTY_NAMES[ i ];
+	                        if ( DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES != null && DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES.length > i && DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES[i] != null )
+	                        	usePropertyName = DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES[i];
+	                        	
+	                        loadingPropsBuffer.append( usePropertyName ).append( ": " ).append( propValue );
 	                    }
 	                }
 	                loadingPropsBuffer.append( " };" );
 	                if ( atLeastOneFound )
 	                	dojoConfigAddOn.append( loadingPropsBuffer.toString() ).append( EOL );
+	                
+	                addPageEditorSettings( dojoConfigAddOn, desktopLayoutDecoration );
 	            }
 	            else
 	            {
@@ -441,6 +524,135 @@
                 log.error( "Failed to write desktop layout decoration exception information to servlet output writer", ioe );
             }
         }
+    }
+    
+    private void addPageEditorSettings( StringBuffer dojoConfigAddOn, LayoutDecoration desktopLayoutDecoration )
+    {
+    	int[] pageEditorConfigFlags = new int[] { 0 };
+    	String propValue;
+
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_DEFAULT, DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_DEFAULT, DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_TRUE );
+
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_TRUE );
+
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_TRUE );
+
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT );
+    	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_DEFAULT, DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_TRUE );
+    	
+    	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX );
+    	Integer maxLayoutNestingObj = null;
+    	try
+    	{
+    		maxLayoutNestingObj = new Integer( propValue );
+    	}
+    	catch ( NumberFormatException ex )
+    	{
+    		maxLayoutNestingObj = new Integer( DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_DEFAULT );
+    	}
+    	int maxLayoutNesting = maxLayoutNestingObj.intValue();
+    	if ( maxLayoutNesting < 0 )
+    		maxLayoutNesting = 0;
+    	if ( maxLayoutNesting > DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_RESERVED )
+    		maxLayoutNesting = DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_RESERVED;
+    	pageEditorConfigFlags[0] += maxLayoutNesting;
+    	    	
+    	String allowEditNoactionsRole = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE );
+    	if ( allowEditNoactionsRole == null )
+    		allowEditNoactionsRole = DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE_DEFAULT;
+    	if ( allowEditNoactionsRole == null )
+    		allowEditNoactionsRole = "";
+    	char[] allowEditNoactionsRoleChars = allowEditNoactionsRole.toCharArray();
+    	int allowEditNoactionsRoleCharsLen = ( ( allowEditNoactionsRoleChars == null ) ? 0 : allowEditNoactionsRoleChars.length );
+    	Random rnd = new Random();
+    	int extrasCount = ( allowEditNoactionsRoleCharsLen > 0 ? getRandom( rnd, 2, 5 ) : getRandom( rnd, 5, 8 ) );
+    	int hexLen = 1 + extrasCount + allowEditNoactionsRoleCharsLen;
+    	int addedExtras = 0;
+    	int nextRoleChar = 0;
+    	StringBuffer pageEditorSettings = new StringBuffer();
+    	for ( int i = 0 ; i < hexLen ; i++ )
+    	{   // here we "mix-up" (obfuscate) the way this information is provided to the client-side
+    		//    this is done to avoid obvious display of certain strings in content, like "manager" or "admin"
+    		int rndVal = getRandom( rnd, 0x1000, 0xFFFD );
+    		boolean isRndValEven = ( (rndVal % 2) == 0 );
+    		int rndValTens = (int)Math.floor( rndVal / 10 );
+    		int rndValTensEven = ( ( ( rndValTens % 2 ) == 1 ) ? Math.max( rndValTens - 1, 2 ) : rndValTens );
+    		int valToHex;
+    		if ( i == 0 )
+    		{
+    			valToHex = pageEditorConfigFlags[0];
+    		}
+    		else if ( addedExtras < extrasCount && ( ( ( i % 2 ) == 1 ) || nextRoleChar >= allowEditNoactionsRoleCharsLen ) )
+    		{
+    			if ( ! isRndValEven )
+    				rndVal++;
+    			valToHex = getRandom( rnd, 0x0A00, 0xDFFF );
+    			if ( (valToHex % 2) == 1 )
+    				valToHex = valToHex + 1;
+    			pageEditorSettings.append( ", " );
+    			addedExtras++;
+    		}
+    		else
+    		{
+    			//log.info( "char '" + allowEditNoactionsRoleChars[nextRoleChar] + "' numericval=" + (int)allowEditNoactionsRoleChars[nextRoleChar] + " hex=" + Integer.toHexString( (int)allowEditNoactionsRoleChars[nextRoleChar] ) + " hexLshift4=" + Integer.toHexString( (int)allowEditNoactionsRoleChars[nextRoleChar] << 4 ) + " hexLshift4+1=" + Integer.toHexString( ((int)allowEditNoactionsRoleChars[nextRoleChar] << 4 ) | 0x0001 ) );
+    			valToHex = ( ((int)allowEditNoactionsRoleChars[nextRoleChar] << 4 ) | 0x0001 );
+    			pageEditorSettings.append( ", " );
+    			nextRoleChar++;
+    		}
+    		String rndValHex = Integer.toHexString( 0x10000 | rndVal ).substring( 1 );
+    		
+    		String realValHex = Integer.toHexString( 0x10000 | ( valToHex + rndValTensEven ) ).substring( 1 );
+    		if ( isRndValEven && i > 0 )
+    			pageEditorSettings.append( "0x" ).append( realValHex ).append( rndValHex );
+    		else
+    			pageEditorSettings.append( "0x" ).append( rndValHex ).append( realValHex );
+    	}
+    	dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PAGEEDITOR_SETTINGS_NAME ).append( " = [ " ).append( pageEditorSettings.toString() ).append( " ];" ).append( EOL );
+    }
+    private int getRandom( Random rnd, int minValueInclusive, int maxValueExclusive )
+    {
+    	if ( minValueInclusive > maxValueExclusive )
+    		throw new IllegalArgumentException( "minValueInclusive (" + minValueInclusive + ") cannot be greater than maxValueExclusive (" + maxValueExclusive + ")" );
+
+    	int diff = (int)( maxValueExclusive - minValueInclusive );
+    	if ( diff == 0 )
+    		return minValueInclusive;
+
+    	double sample = rnd.nextDouble();
+    	int result = (int)( sample * diff + minValueInclusive );
+    	result = ( ( result != maxValueExclusive ) ? result : ( result - 1 ) );
+    	return result;
+    }
+    
+    private void processBooleanFlagProperty( int[] flags, Object propVal, Object propValDefault, int propIsTrueBit )
+    {
+        String boolStr = ( ( propVal == null ) ? ( ( propValDefault == null ) ? (String)null : propValDefault.toString() ) : propVal.toString() );
+        if ( boolStr != null && boolStr.toLowerCase().equals( "true" ) )
+        	flags[0] |= propIsTrueBit;
     }
 
     private String getCachedContent( String cacheKey )

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm Thu Nov 15 12:21:24 2007
@@ -71,6 +71,8 @@
 #foreach ($meta in $page.Metadata.Fields)
 	<metadata name="$meta.Name" xml:lang="$meta.Locale.toString()">$!meta.Value</metadata>
 #end
+  <npe>$pageQualifiedForCreateNewPageOnEdit</npe>
+  <uIA>$userIsAnonymous</uIA>
 #foreach ($action in $page.getRootContentFragment().decoration.actions)
      <action id="${action.ActionName}" type="${action.ActionType}" name="${action.Name}" url="${action.Action}"/>    
 #end

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/userinfo.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/userinfo.vm?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/userinfo.vm (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/userinfo.vm Thu Nov 15 12:21:24 2007
@@ -26,4 +26,11 @@
 		#end
 		</userinfo>
 	#end
+	#if($roles.size() > 0)
+	    <roles>
+		#foreach( $roleName in $roles )
+    		<role>$roleName</role>
+		#end
+		</roles>
+	#end
 </js>

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/AddPortletAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/AddPortletAction.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/AddPortletAction.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/AddPortletAction.java Thu Nov 15 12:21:24 2007
@@ -25,6 +25,7 @@
 import org.apache.jetspeed.ajax.AJAXException;
 import org.apache.jetspeed.ajax.AjaxAction;
 import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
@@ -54,31 +55,33 @@
     protected GetPortletsAction getPortletsAction = null;
     protected boolean allowDuplicatePortlets = true;
 
-    public AddPortletAction(String template, String errorTemplate, GetPortletsAction getPortletsAction)
+    public AddPortletAction( String template, String errorTemplate, PortletRegistry registry, GetPortletsAction getPortletsAction )
         throws AJAXException
     {
-        this(template, errorTemplate, null, null, getPortletsAction, true);
+        this( template, errorTemplate, registry, null, null, getPortletsAction, true );
     }
 
-    public AddPortletAction(String template, 
-                            String errorTemplate, 
-                            PageManager pageManager,
-                            PortletActionSecurityBehavior securityBehavior,
-                            GetPortletsAction getPortletsAction)
+    public AddPortletAction( String template, 
+                             String errorTemplate, 
+                             PortletRegistry registry,
+                             PageManager pageManager,
+                             PortletActionSecurityBehavior securityBehavior,
+                             GetPortletsAction getPortletsAction )
         throws AJAXException
     {
-        this(template, errorTemplate, pageManager, securityBehavior, getPortletsAction, true);
+        this( template, errorTemplate, registry, pageManager, securityBehavior, getPortletsAction, true );
     }
 
-    public AddPortletAction(String template, 
-                            String errorTemplate, 
-                            PageManager pageManager,
-                            PortletActionSecurityBehavior securityBehavior,
-                            GetPortletsAction getPortletsAction,
-                            boolean allowDuplicatePortlets)
+    public AddPortletAction( String template, 
+                             String errorTemplate,
+                             PortletRegistry registry,
+                             PageManager pageManager,
+                             PortletActionSecurityBehavior securityBehavior,
+                             GetPortletsAction getPortletsAction,
+                             boolean allowDuplicatePortlets )
         throws AJAXException
     {
-        super(template, errorTemplate, pageManager, securityBehavior); 
+        super( template, errorTemplate, registry, pageManager, securityBehavior );
         this.getPortletsAction = getPortletsAction;
         this.allowDuplicatePortlets = allowDuplicatePortlets;
     }
@@ -89,42 +92,88 @@
         String status = "success";
         try
         {
-            resultMap.put(ACTION, "add");
+            resultMap.put( ACTION, "add" );
             // Get the necessary parameters off of the request
-            String portletId = getActionParameter(requestContext, PORTLETID);
+            String portletId = getActionParameter( requestContext, PORTLETID );
             if (portletId == null) 
             { 
-                throw new RuntimeException("portlet id not provided"); 
+                throw new RuntimeException( "portlet id not provided" ); 
             }
-            resultMap.put(PORTLETID, portletId);
+            resultMap.put( PORTLETID, portletId );
             
             // Verify that the specified portlet id is valid and accessible
             // If the portletid is not valid an exception will be thrown
-            verifyPortletId(requestContext, portletId);
+            verifyPortletId( requestContext, portletId );
             
-            if(allowDuplicatePortlets == false) {
+            if( allowDuplicatePortlets == false )
+            {
             	// Check to see if this portlet has already been added to the page
-            	checkForDuplicatePortlet(requestContext, resultMap, portletId);
+            	checkForDuplicatePortlet( requestContext, resultMap, portletId );
             }
             
-            if (false == checkAccess(requestContext, JetspeedActions.EDIT))
+            String layoutId = getActionParameter( requestContext, LAYOUTID );
+            
+            if ( false == checkAccess( requestContext, JetspeedActions.EDIT ) )
             {
-                if (!createNewPageOnEdit(requestContext))
+            	NestedFragmentContext addToFragmentContext = null;
+            	if ( layoutId != null && layoutId.length() > 0 )
+            	{
+            		Page page = requestContext.getPage();
+            		Fragment fragment = page.getFragmentById( layoutId );
+            		if ( fragment == null )
+            		{
+            			success = false;
+            			resultMap.put( REASON, "Specified layout fragment not found: " + layoutId );
+            			return success;
+            		}
+            	
+            		try
+            		{
+            			addToFragmentContext = new NestedFragmentContext( fragment, page, getPortletRegistry() );
+            		}
+            		catch ( Exception ex )
+            		{
+            			log.error( "Failure to construct nested context for fragment " + layoutId, ex );
+            			success = false;
+            			resultMap.put( REASON, "Cannot construct nested context for specified layout fragment" );
+            			return success;
+            		}
+            	}
+            	
+                if ( ! createNewPageOnEdit( requestContext ) )
                 {
                     success = false;
-                    resultMap.put(REASON, "Insufficient access to edit page");                
+                    resultMap.put( REASON, "Insufficient access to edit page" );
                     return success;
                 }
                 status = "refresh";
-            }           
+
+                if ( addToFragmentContext != null )
+                {
+                	Page newPage = requestContext.getPage();
+
+                	// using NestedFragmentContext, find portlet id for copy of target portlet in the new page 
+                	Fragment newFragment = null;
+                	try
+                	{
+                		newFragment = addToFragmentContext.getFragmentOnNewPage( newPage, getPortletRegistry() );
+                	}
+                	catch ( Exception ex )
+                	{
+                		log.error( "Failure to locate copy of fragment " + layoutId, ex );
+                		success = false;
+                		resultMap.put( REASON, "Failed to find new fragment for specified layout id: " + layoutId );
+                		return success;
+                	}
+                	layoutId = newFragment.getId();
+                }
+            }
             
             Page page = requestContext.getPage();
-            String layoutId = getActionParameter(requestContext, LAYOUTID);
+            
             Fragment fragment = pageManager.newFragment();
-            fragment.setType(Fragment.PORTLET);
-            fragment.setName(portletId);
-            //fragment.setLayoutColumn(iCol);
-            //fragment.setLayoutRow(iRow);
+            fragment.setType( Fragment.PORTLET );
+            fragment.setName( portletId );
             
             Fragment placeInLayoutFragment = null;
             if ( layoutId != null && layoutId.length() > 0 )

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BasePortletAction.java Thu Nov 15 12:21:24 2007
@@ -118,7 +118,19 @@
         }
         return access;
     }
-
+    
+    public boolean isCreateNewPageOnEditEnabled()
+    {
+    	if (securityBehavior == null)
+            return false;
+    	return securityBehavior.isCreateNewPageOnEditEnabled();
+    }
+    public boolean isPageQualifiedForCreateNewPageOnEdit(RequestContext context)
+    {
+    	if (securityBehavior == null)
+            return false;
+    	return securityBehavior.isPageQualifiedForCreateNewPageOnEdit(context);
+    }
     public boolean createNewPageOnEdit(RequestContext context)
     {
         if (securityBehavior == null)
@@ -126,17 +138,18 @@
         
         return securityBehavior.createNewPageOnEdit(context);        
     }
-        
-    // TODO: support nested fragments
-    public Fragment getFragmentIdFromLocation(int row, int column, Page page)
+    
+    public Fragment getFragmentIdFromLocation( int row, int column, Page page )
+    {
+    	return getFragmentIdFromLocation( row, column, page.getRootFragment() );
+    }
+    public Fragment getFragmentIdFromLocation( int row, int column, Fragment parentFragment )
     {
-        Fragment root = page.getRootFragment();
-        Iterator fragments = root.getFragments().iterator();
-        while (fragments.hasNext())
+        Iterator fragments = parentFragment.getFragments().iterator();
+        while ( fragments.hasNext() )
         {
             Fragment fragment = (Fragment)fragments.next();
-            if (fragment.getLayoutColumn() == column &&
-                fragment.getLayoutRow() == row)
+            if ( fragment.getLayoutColumn() == column && fragment.getLayoutRow() == row )
             {
                 return fragment;
             }
@@ -174,43 +187,6 @@
     
     public Fragment getParentFragmentById(String id, Fragment root)
     {
-        if ( id == null )
-        {
-            return null;
-        }
-        return searchForParentFragmentById( id, root );
-    }
-    
-    protected Fragment searchForParentFragmentById( String id, Fragment parent )
-    {   
-        // find fragment by id, tracking fragment parent
-        Fragment matchedParent = null;
-        if( parent != null ) 
-        {
-            // process the children
-            List children = parent.getFragments();
-            for( int i = 0, cSize = children.size() ; i < cSize ; i++) 
-            {
-                Fragment childFrag = (Fragment)children.get( i );
-                if ( childFrag != null ) 
-                {
-                    if ( id.equals( childFrag.getId() ) )
-                    {
-                        matchedParent = parent;
-                        break;
-                    }
-                    else
-                    {
-                        matchedParent = searchForParentFragmentById( id, childFrag );
-                        if ( matchedParent != null )
-                        {
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        return matchedParent;
-    }
-    
+    	return NestedFragmentContext.getParentFragmentById( id, root );
+    }    
 }

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseUserAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseUserAction.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseUserAction.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/BaseUserAction.java Thu Nov 15 12:21:24 2007
@@ -123,6 +123,9 @@
 
     public boolean createNewPageOnEdit(RequestContext context)
     {
+    	if (securityBehavior == null)
+            return false;
+    	
         return securityBehavior.createNewPageOnEdit(context);        
     }
         

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/ChangePortletAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/ChangePortletAction.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/ChangePortletAction.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/ChangePortletAction.java Thu Nov 15 12:21:24 2007
@@ -26,11 +26,13 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.ajax.AJAXException;
 import org.apache.jetspeed.ajax.AjaxAction;
 import org.apache.jetspeed.ajax.AjaxBuilder;
 import org.apache.jetspeed.container.state.MutableNavigationalState;
 import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.decoration.PageActionAccess;
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.ContentPage;
@@ -127,86 +129,153 @@
         {
             resultMap.put(ACTION, action);
             // Get the necessary parameters off of the request
-            String portletId = getActionParameter(requestContext, PORTLETID);
-            if (portletId == null) 
+            String fragmentId = getActionParameter(requestContext, FRAGMENTID);
+            if (fragmentId == null) 
             { 
-                throw new Exception("portlet id not provided"); 
-            }            
-            resultMap.put(PORTLETID, portletId);
-            
-            String windowState = getActionParameter(requestContext, WINDOW_STATE);
-            String portletMode = getActionParameter(requestContext, PORTLET_MODE);
-            if (windowState == null && portletMode == null) 
-            { 
-                throw new Exception("portlet window state or mode not provided"); 
-            }           
-            if (windowState != null && !isValidWindowState(windowState))
-            {
-                throw new Exception("portlet window state " + windowState + " is not supported");
-            }
-            if (portletMode != null && !isValidPortletMode(portletMode))
-            {
-                throw new Exception("portlet mode " + portletMode + " is not supported");
+                throw new Exception("fragment id not provided"); 
             }
-
-            ContentPage page = requestContext.getPage();            
-            ContentFragment fragment = page.getContentFragmentById(portletId);
-            
-            String oldState = fragment.getState();
-            String oldMode = fragment.getMode();
+            resultMap.put(FRAGMENTID, fragmentId);
             
-            // Now Change the transient navigational state
-            MutableNavigationalState navState = (MutableNavigationalState)requestContext.getPortalURL().getNavigationalState();
-            PortletWindow portletWindow = windowAccessor.getPortletWindow(fragment);
-            if (portletWindow != null)
-            {
-                oldState = navState.getState(portletWindow).toString();
-                oldMode =  navState.getMode(portletWindow).toString();
-                if (windowState != null)
-                {
-                    navState.setState(portletWindow, new WindowState(windowState));
-                }
-                if (portletMode != null)
-                {
-                    navState.setMode(portletWindow, new PortletMode(portletMode));
-                }
-                navState.sync(requestContext);                                
-            }
-            
-
-            if (checkAccess(requestContext, JetspeedActions.EDIT))
-            {
-                if (windowState != null)
-                    fragment.setState(windowState);
-                if (portletMode != null)
-                    fragment.setMode(portletMode);
-                
-                if (pageManager != null && !batch)
-                {
-                    pageManager.updatePage(page);
-                }
-            }
-            
-            //requestContext.getPortalURL().getNavigationalState().
-            resultMap.put(STATUS, status);
+            ContentPage page = requestContext.getPage();            
+            ContentFragment fragment = page.getContentFragmentById(fragmentId);
             
-            if (windowState != null)
+            if ( fragment == null )
             {
-                resultMap.put(OLD_WINDOW_STATE, oldState);
-                resultMap.put(WINDOW_STATE, windowState);
+            	throw new Exception( "fragment specified by id cannot be found" );
             }
-
-            if (portletMode != null)
-            {
-                resultMap.put(OLD_PORTLET_MODE, oldMode);
-                resultMap.put(PORTLET_MODE, portletMode);
+            String requestedState = getActionParameter(requestContext, WINDOW_STATE);
+            String requestedMode = getActionParameter(requestContext, PORTLET_MODE);    
+            if ( "layout".equals( fragment.getType() ) )
+            {
+            	if ( ! fragment.getId().equals( page.getRootFragment().getId() ) )
+            	{
+            		throw new Exception( "for layout fragments, change action applies to only to the root layout fragment (i.e. it does not apply to nested layout fragments)" );
+            	}
+            	PageActionAccess pageActionAccess = (PageActionAccess)requestContext.getAttribute( PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE );
+            	if ( pageActionAccess == null )
+            	{
+            		throw new Exception( "cannot change action for root layout fragment due to null PageActionAccess object" );
+            	}
+            	//pageActionAccess.
+            	PortletWindow window = windowAccessor.getPortletWindow(fragment);
+            	PortletMode currentMode = requestContext.getPortalURL().getNavigationalState().getMode( window );
+            	WindowState currentState = requestContext.getPortalURL().getNavigationalState().getState( window );
+            	
+            	boolean requestedModeAlreadySet = false;
+            	if ( requestedMode == null )
+            		requestedModeAlreadySet = true;
+            	else
+            	{
+            		if ( requestedMode.equals( PortletMode.EDIT.toString() ) )
+            		{
+            			if( pageActionAccess.isEditing() )
+            				requestedModeAlreadySet = true;
+            			else
+            			{
+            				if ( pageActionAccess.isEditAllowed())
+            				{
+            					pageActionAccess.setEditing( true );
+            					resultMap.put(STATUS, status);
+            					resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
+            					resultMap.put(PORTLET_MODE, requestedMode);
+            				}
+            				else
+            				{
+            					throw new Exception( "permissions do no allow page edit" );
+            				}
+            			}
+            		}
+            		else if ( requestedMode.equals( PortletMode.VIEW.toString() ) )
+            		{
+            			pageActionAccess.setEditing( false );
+            			//if ( currentMode.equals( PortletMode.HELP ) )
+            			resultMap.put(STATUS, status);
+            			resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
+            			resultMap.put(PORTLET_MODE, requestedMode);
+            		}
+            		else
+            		{
+            			requestedModeAlreadySet = true;
+            		}
+            	}
+            	if ( requestedModeAlreadySet )
+            	{
+           			resultMap.put(STATUS, status);
+           			resultMap.put(OLD_PORTLET_MODE, currentMode.toString());
+           			resultMap.put(PORTLET_MODE, currentMode.toString());
+           		}
+            }
+            else
+            {
+	            if (requestedState == null && requestedMode == null) 
+	            { 
+	                throw new Exception("portlet window state or mode not provided"); 
+	            }           
+	            if (requestedState != null && !isValidWindowState(requestedState))
+	            {
+	                throw new Exception("portlet window state " + requestedState + " is not supported");
+	            }
+	            if (requestedMode != null && !isValidPortletMode(requestedMode))
+	            {
+	                throw new Exception("portlet mode " + requestedMode + " is not supported");
+	            }
+	
+	            
+	            String oldState = fragment.getState();
+	            String oldMode = fragment.getMode();
+	            
+	            // Now Change the transient navigational state
+	            MutableNavigationalState navState = (MutableNavigationalState)requestContext.getPortalURL().getNavigationalState();
+	            PortletWindow portletWindow = windowAccessor.getPortletWindow(fragment);
+	            if (portletWindow != null)
+	            {
+	                oldState = navState.getState(portletWindow).toString();
+	                oldMode =  navState.getMode(portletWindow).toString();
+	                if (requestedState != null)
+	                {
+	                    navState.setState(portletWindow, new WindowState(requestedState));
+	                }
+	                if (requestedMode != null)
+	                {
+	                    navState.setMode(portletWindow, new PortletMode(requestedMode));
+	                }
+	                navState.sync(requestContext);                                
+	            }
+	            
+	
+	            if (checkAccess(requestContext, JetspeedActions.EDIT))
+	            {
+	                if (requestedState != null)
+	                    fragment.setState(requestedState);
+	                if (requestedMode != null)
+	                    fragment.setMode(requestedMode);
+	                
+	                if (pageManager != null && !batch)
+	                {
+	                    pageManager.updatePage(page);
+	                }
+	            }
+	            
+	            //requestContext.getPortalURL().getNavigationalState().
+	            resultMap.put(STATUS, status);
+	            
+	            if (requestedState != null)
+	            {
+	                resultMap.put(OLD_WINDOW_STATE, oldState);
+	                resultMap.put(WINDOW_STATE, requestedState);
+	            }
+	
+	            if (requestedMode != null)
+	            {
+	                resultMap.put(OLD_PORTLET_MODE, oldMode);
+	                resultMap.put(PORTLET_MODE, requestedMode);
+	            }
             }
-            
         } 
         catch (Exception e)
         {
             // Log the exception
-            log.error("exception while moving a portlet", e);
+            log.error("exception while changing portlet/page action", e);
             resultMap.put(REASON, e.toString());
             // Return a failure indicator
             success = false;

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java Thu Nov 15 12:21:24 2007
@@ -61,6 +61,7 @@
     public static final String PAGES = "pages";
     public static final String PAGE = "page";
     public static final String PROFILED_PATH = "profiledPath";
+    public static final String PAGE_QUALIFIED_CREATE_ON_EDIT = "pageQualifiedForCreateNewPageOnEdit";
     public static final String FOLDER = "folder";
     public static final String FOLDERS = "folders";
     public static final String SIZES = "sizes";
@@ -69,6 +70,8 @@
     public static final String GUESTUSERS = "guestusers";
     public static final String USERNAME = "username";
     public static final String USERINFO = "userinfo";
+    public static final String USER_IS_ANONYMOUS = "userIsAnonymous";
+    public static final String ROLES = "roles";
     public static final String SESSIONS = "sessions";
     public static final String IPADDRESS = "ipaddress";
     

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java Thu Nov 15 12:21:24 2007
@@ -21,6 +21,10 @@
 import java.util.List;
 import java.util.Map;
 
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.JetspeedActions;
@@ -29,6 +33,7 @@
 import org.apache.jetspeed.ajax.AjaxBuilder;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.decoration.DecorationValve;
+import org.apache.jetspeed.decoration.PageActionAccess;
 import org.apache.jetspeed.decoration.Theme;
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 import org.apache.jetspeed.om.page.Fragment;
@@ -54,17 +59,17 @@
     extends BaseGetResourceAction 
     implements AjaxAction, AjaxBuilder, Constants
 {
-    protected Log log = LogFactory.getLog(GetPageAction.class);
+    protected Log log = LogFactory.getLog( GetPageAction.class );
     
     private PortletRegistry registry;
     private DecorationValve decorationValve;
     
-    public GetPageAction(String template, 
-            String errorTemplate, 
-            PageManager pageManager,
-            PortletActionSecurityBehavior securityBehavior,
-            PortletRegistry registry,
-            DecorationValve decorationValve)
+    public GetPageAction( String template, 
+                          String errorTemplate, 
+                          PageManager pageManager,
+                          PortletActionSecurityBehavior securityBehavior,
+                          PortletRegistry registry,
+                          DecorationValve decorationValve )
     {
         super(template, errorTemplate, pageManager, securityBehavior);
         this.registry = registry;
@@ -77,28 +82,27 @@
         String status = "success";
         try
         {
-            resultMap.put(ACTION, "getpage");
-            if (false == checkAccess(requestContext, JetspeedActions.VIEW))
+            resultMap.put( ACTION, "getpage" );
+            if ( false == checkAccess( requestContext, JetspeedActions.VIEW ) )
             {
-                resultMap.put(REASON, "Insufficient access to view page");
+                resultMap.put( REASON, "Insufficient access to view page" );
                 success = false;
                 return success;
             }            
             
             // Run the Decoration valve to get actions
-            decorationValve.invoke(requestContext, null);
+            decorationValve.invoke( requestContext, null );
             
-            //String filter = getActionParameter(requestContext, FILTER);            
             Page page = requestContext.getPage();
-            String pageName = getActionParameter(requestContext, PAGE);
-            if (pageName != null)
+            String pageName = getActionParameter( requestContext, PAGE );
+            if ( pageName != null )
             {
-                page = retrievePage(requestContext, pageName);
+                page = retrievePage( requestContext, pageName );
             }
-            resultMap.put(STATUS, status);
-            resultMap.put(PAGE, page);
+            resultMap.put( STATUS, status );
+            resultMap.put( PAGE, page );
             
-            Theme theme = (Theme)requestContext.getAttribute(PortalReservedParameters.PAGE_THEME_ATTRIBUTE);
+            Theme theme = (Theme)requestContext.getAttribute( PortalReservedParameters.PAGE_THEME_ATTRIBUTE );
             String pageDecoratorName = null;
             if ( theme != null )
             {
@@ -111,30 +115,43 @@
             if ( pageDecoratorName != null )
                 resultMap.put( DEFAULT_LAYOUT, pageDecoratorName );
                     
-            PortalSiteRequestContext siteRequestContext = (PortalSiteRequestContext)requestContext.getAttribute(ProfilerValveImpl.PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);
-            if (siteRequestContext == null)
+            PortalSiteRequestContext siteRequestContext = (PortalSiteRequestContext)requestContext.getAttribute( ProfilerValveImpl.PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY );
+            if ( siteRequestContext == null )
             {
                 success = false;
-                resultMap.put(REASON, "Missing portal site request context from ProfilerValve");
+                resultMap.put( REASON, "Missing portal site request context from ProfilerValve" );
                 return success;
             }
             
-            resultMap.put(PROFILED_PATH, siteRequestContext.getPage().getPath() );  // requestContext.getPath());
-            putSecurityInformation(resultMap, page);                        
-            String fragments = getActionParameter(requestContext, FRAGMENTS);
-            if (fragments == null)
+            String profiledPath = siteRequestContext.getPage().getPath();
+            resultMap.put( PROFILED_PATH, profiledPath );
+            putSecurityInformation( resultMap, page );
+     
+            PageActionAccess pageActionAccess = (PageActionAccess)requestContext.getAttribute( PortalReservedParameters.PAGE_EDIT_ACCESS_ATTRIBUTE );
+            Boolean userIsAnonymous = Boolean.TRUE;
+            if ( pageActionAccess != null )
+            	userIsAnonymous = new Boolean( pageActionAccess.isAnonymous() );
+            resultMap.put( USER_IS_ANONYMOUS, userIsAnonymous.toString() );
+     
+            Boolean isPageQualifiedForCreateNewPageOnEdit = Boolean.FALSE;
+            if ( ! userIsAnonymous.booleanValue() )
+            	isPageQualifiedForCreateNewPageOnEdit = new Boolean( isPageQualifiedForCreateNewPageOnEdit( requestContext ) );
+            resultMap.put( PAGE_QUALIFIED_CREATE_ON_EDIT, isPageQualifiedForCreateNewPageOnEdit.toString() );
+            
+            String fragments = getActionParameter( requestContext, FRAGMENTS );
+            if ( fragments == null )
             {
-                resultMap.put(FRAGMENTS, "true");
+                resultMap.put( FRAGMENTS, "true" );
             }
             else
             {
-                if (fragments.equalsIgnoreCase("true"))
+                if ( fragments.equalsIgnoreCase( "true" ) )
                 {
-                    resultMap.put(FRAGMENTS, "true");
+                    resultMap.put( FRAGMENTS, "true" );
                 }
                 else
                 {
-                    resultMap.put(FRAGMENTS, "false");
+                    resultMap.put( FRAGMENTS, "false" );
                     return success;
                 }
             }
@@ -142,17 +159,17 @@
             Map fragSizes = new HashMap();
             Map portletIcons = new HashMap();
             
-            String singleLayoutId = getActionParameter(requestContext, LAYOUTID);
+            String singleLayoutId = getActionParameter( requestContext, LAYOUTID );
             if ( singleLayoutId != null )
             {   // build page representation with single layout
                 Fragment currentLayoutFragment = page.getFragmentById( singleLayoutId );
                 if ( currentLayoutFragment == null )
                 {
-                    throw new Exception("layout id not found: " + singleLayoutId );
+                    throw new Exception( "layout id not found: " + singleLayoutId );
                 }
                 Fragment currentPortletFragment = null;
                 
-                String singlePortletId = getActionParameter(requestContext, PORTLETENTITY);
+                String singlePortletId = getActionParameter( requestContext, PORTLETENTITY );
                 if ( singlePortletId != null )
                 {
                     Iterator layoutChildIter = currentLayoutFragment.getFragments().iterator();
@@ -170,7 +187,7 @@
                     }
                     if ( currentPortletFragment == null )
                     {
-                        throw new Exception("portlet id " + singlePortletId + " not found in layout " + singleLayoutId );
+                        throw new Exception( "portlet id " + singlePortletId + " not found in layout " + singleLayoutId );
                     }
                     resultMap.put( "portletsingleId", currentPortletFragment.getId() );
                 }
@@ -185,10 +202,10 @@
             resultMap.put( SIZES, fragSizes );
             resultMap.put( "portletIcons", portletIcons );
         }
-        catch (Exception e)
+        catch ( Exception e )
         {
             // Log the exception
-            log.error("exception while getting page", e);
+            log.error( "exception while getting page", e );
 
             // Return a failure indicator
             success = false;
@@ -197,14 +214,14 @@
         return success;
 	}
     
-    protected Page retrievePage(RequestContext requestContext, String pageName)
-    throws Exception
+    protected Page retrievePage( RequestContext requestContext, String pageName )
+        throws Exception
     {        
-        if (pageName == null)
+        if ( pageName == null )
         {
             pageName = "/";
         }
-        Page page = pageManager.getPage(pageName);
+        Page page = pageManager.getPage( pageName );
         return page;
     }        
     
@@ -215,56 +232,12 @@
         {
             return;
         }
-    	if ( fragSizes != null && "layout".equals( frag.getType() ) )
+        
+    	if ( "layout".equals( frag.getType() ) )
     	{   // get layout fragment sizes
-    		String sizesVal = frag.getProperty( "sizes" );
-    		if ( sizesVal == null || sizesVal.length() == 0 )
-    		{
-    			String layoutName = frag.getName();
-    			if ( layoutName != null && layoutName.length() > 0 )
-    			{
-    				// logic below is copied from org.apache.jetspeed.portlets.MultiColumnPortlet
-    				PortletDefinition portletDef = registry.getPortletDefinitionByUniqueName( layoutName );
-                    
-    				ParameterSet paramSet = portletDef.getInitParameterSet();
-    				Parameter sizesParam = paramSet.get( "sizes" );
-    				String sizesParamVal = ( sizesParam == null ) ? null : sizesParam.getValue();
-    				if ( sizesParamVal != null && sizesParamVal.length() > 0 )
-    				{
-    					fragSizes.put( frag.getId(), sizesParamVal );
-    					//log.info( "GetPageAction settings sizes for " + frag.getId() + " to " + sizesParamVal);
-    				}
-    				else
-    				{
-    					Parameter colsParam = paramSet.get( "columns" );
-    					String colsParamVal = ( colsParam == null ) ? null : colsParam.getValue();
-    					if ( colsParamVal != null && colsParamVal.length() > 0 )
-    					{
-    						int cols = 0;
-    						try
-    						{
-    							cols = Integer.parseInt( colsParamVal );
-    						}
-    						catch ( NumberFormatException ex )
-    						{
-    						}
-    						if ( cols < 1 )
-    						{
-    							cols = 2;
-    						}
-    						switch (cols)
-    			            {
-    			            	case 1: sizesParamVal = "100%"; break;
-    			            	case 2: sizesParamVal = "50%,50%"; break;
-    			            	case 3: sizesParamVal = "34%,33%,33%"; break;
-    			            	default: sizesParamVal = "50%,50%"; break;
-    			            }
-    						fragSizes.put( frag.getId(), sizesParamVal );
-    						//log.info( "GetPageAction defaulting sizes for " + frag.getId() + " to " + sizesParamVal);
-    					}
-    				}
-    			}
-    		}
+    		if ( fragSizes != null )
+    			PortletPlacementContextImpl.getColumnCountAndSizes( frag, registry, fragSizes );
+    		
     		List childFragments = frag.getFragments();
     		if ( childFragments != null )
     		{
@@ -300,5 +273,4 @@
             }
         }
     }
-    
 }

Modified: portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java?rev=595431&r1=595430&r2=595431&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java (original)
+++ portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/layout/impl/GetUserInformationAction.java Thu Nov 15 12:21:24 2007
@@ -18,17 +18,27 @@
 
 import java.security.Principal;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
 import java.util.prefs.Preferences;
 
+import javax.security.auth.Subject;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.administration.PortalConfiguration;
 import org.apache.jetspeed.ajax.AJAXException;
 import org.apache.jetspeed.ajax.AjaxAction;
 import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
 import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.RolePrincipal;
 import org.apache.jetspeed.security.User;
 import org.apache.jetspeed.security.UserManager;
+import org.apache.jetspeed.security.impl.RolePrincipalImpl;
 
 /**
  * Retrieve user information of the current user
@@ -51,9 +61,9 @@
     public GetUserInformationAction(String template, 
                             String errorTemplate, 
                             UserManager um,
-                            RolesSecurityBehavior securityBehavior)                            
+                            RolesSecurityBehavior rolesSecurityBehavior)                            
     {
-        super(template, errorTemplate, um, securityBehavior); 
+        super(template, errorTemplate, um, rolesSecurityBehavior);
     }
     
     public boolean run(RequestContext requestContext, Map resultMap)
@@ -84,8 +94,19 @@
                 	}
                 	resultMap.put(USERINFO, prefsSet);
 
+                	List roles = new ArrayList();
+                	Subject userSubject = user.getSubject();
+                	if ( userSubject != null )
+                	{
+                		Iterator rolesIter = userSubject.getPrincipals( RolePrincipalImpl.class ).iterator();
+                		while ( rolesIter.hasNext() )
+                        {
+                			RolePrincipal role = (RolePrincipal)rolesIter.next();
+                            roles.add( role.getName() );
+                        }
+                	}
+                	resultMap.put( ROLES, roles);
                 }
-                	
         	}
         	else
         	{



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message