Coverage report

  %line %branch
org.apache.jetspeed.desktop.impl.JetspeedDesktopImpl
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.desktop.impl;
 18  
 
 19  
 import java.io.IOException;
 20  
 import java.util.Iterator;
 21  
 import java.util.ResourceBundle;
 22  
 import java.util.Set;
 23  
 import java.util.Random;
 24  
 
 25  
 import javax.servlet.RequestDispatcher;
 26  
 import javax.servlet.ServletContext;
 27  
 
 28  
 import org.apache.commons.logging.Log;
 29  
 import org.apache.commons.logging.LogFactory;
 30  
 import org.apache.jetspeed.Jetspeed;
 31  
 import org.apache.jetspeed.cache.CacheElement;
 32  
 import org.apache.jetspeed.cache.JetspeedCache;
 33  
 import org.apache.jetspeed.container.url.BasePortalURL;
 34  
 import org.apache.jetspeed.decoration.DecorationFactory;
 35  
 import org.apache.jetspeed.decoration.LayoutDecoration;
 36  
 import org.apache.jetspeed.decoration.PortletDecoration;
 37  
 import org.apache.jetspeed.decoration.Theme;
 38  
 import org.apache.jetspeed.desktop.JetspeedDesktop;
 39  
 import org.apache.jetspeed.desktop.JetspeedDesktopContext;
 40  
 import org.apache.jetspeed.headerresource.HeaderResource;
 41  
 import org.apache.jetspeed.headerresource.HeaderResourceFactory;
 42  
 import org.apache.jetspeed.headerresource.HeaderResourceLib;
 43  
 import org.apache.jetspeed.om.page.Page;
 44  
 import org.apache.jetspeed.request.RequestContext;
 45  
 import org.springframework.web.context.ServletContextAware;
 46  
 
 47  
 /**
 48  
  * Desktop Valve
 49  
  *
 50  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 51  
  * @author <a href="mailto:smilek@apache.org">Steve Milek</a>
 52  
  * @version $Id: JetspeedDesktopImpl.java $
 53  
  */
 54  
 public class JetspeedDesktopImpl implements JetspeedDesktop, ServletContextAware
 55  
 {
 56  0
 	private static final Log log = LogFactory.getLog( JetspeedDesktopImpl.class );
 57  
 	
 58  
     private final static String EOL = "\r\n";   // html eol
 59  
     private final static String DOJO_CONFIG_LAYOUT_DECORATION_PATH_VAR_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".layoutDecorationPath";
 60  
     private final static String DOJO_CONFIG_LAYOUT_VAR_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".layoutName";
 61  
     private final static String DOJO_CONFIG_PORTLET_DECORATIONS_PATH_VAR_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".portletDecorationsPath";
 62  
     private final static String DOJO_CONFIG_PORTLET_DECORATIONS_ALLOWED_VAR_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".portletDecorationsAllowed";
 63  
     private final static String DOJO_CONFIG_PORTLET_DECORATIONS_CONFIG_VAR_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".portletDecorationsProperties";    
 64  
     private final static String DOJO_CONFIG_ACTION_LABELS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".desktopActionLabels";
 65  
     private final static String DOJO_CONFIG_LOADING_IMGPROPS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".loadingImgProps";
 66  
     private final static String DOJO_CONFIG_PAGEEDITOR_LABELS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".pageEditorLabels";
 67  
     private final static String DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".pageEditorDialogLabels";
 68  
     private final static String DOJO_CONFIG_PAGEEDITOR_SETTINGS_NAME = HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + ".pec";
 69  
     
 70  0
     private final static String[] DESKTOP_LOADING_PROPERTY_NAMES = new String[] 
 71  
                                                                  { "dir", "animated", "stepprefix", "stepextension", "steps"
 72  
                                                                  };
 73  0
     private final static String[] DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES = new String[] 
 74  
                                                                  { "imgdir", "imganimated", "imgstepprefix", "imgstepextension", "imgsteps"
 75  
                                                                  };
 76  0
     private final static String[] DESKTOP_ACTION_RESOURCE_NAMES = new String[] 
 77  
                                                                  { "menu", "tile", "untile", "heightexpand", "heightnormal",
 78  
     															   "restore", "removeportlet", "minimized", "maximized", "normal",
 79  
     															   "help", "edit", "view", "print", "config", "edit_defaults", "about",
 80  
     															   "addportlet", "editpage", 
 81  
     															   "movetiled", "moveuntiled", "loadpage", "loadpageeditor",
 82  
     															   "loadportletrender", "loadportletaction", "loadportletupdate"
 83  
     															 };
 84  0
     private final static String[] DESKTOP_PAGEEDITOR_RESOURCE_NAMES = new String[]
 85  
                                                                  { "title", "changelayout", "changepagelayouttheme", "changepageportlettheme",
 86  
     	                                                           "newpage", "deletepage", "addlayout", "addportlet", "columnsizes",
 87  
     	                                                           "deletelayout", "movemode", "movemode_exit", "changeportlettheme"
 88  
     	                                                         };
 89  0
     private final static String[] DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAMES = new String[]
 90  
                                                                  { "columnsizes", "columnsizes_column1", "columnsizes_column2", "columnsizes_column3",
 91  
     	                                                           "columnsizes_column4", "columnsizes_column5", "newpage", "newpage_name",
 92  
     	                                                           "newpage_title", "newpage_titleshort", "deletepage", "deletelayout",
 93  
     	                                                           "removeportlet", "ok", "cancel", "yes", "no"
 94  
                                                                  };
 95  
     
 96  
     private final static String DESKTOP_LOADING_NAME_PREFIX = "desktop.loading.";
 97  
     private final static String DESKTOP_ACTION_NAME_PREFIX = "desktop.action.";
 98  
     private final static String DESKTOP_PAGEEDITOR_NAME_PREFIX = "desktop.pageeditor.";
 99  
     
 100  
     private final static String DESKTOP_LOADING_IMG_NAME_PREFIX = DESKTOP_LOADING_NAME_PREFIX + "img.";
 101  
     private final static String DESKTOP_ACTION_RESOURCE_NAME_PREFIX = DESKTOP_ACTION_NAME_PREFIX + "labels.";
 102  
     private final static String DESKTOP_PAGEEDITOR_RESOURCE_NAME_PREFIX = DESKTOP_PAGEEDITOR_NAME_PREFIX + "labels.";
 103  
     private final static String DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAME_PREFIX = DESKTOP_PAGEEDITOR_NAME_PREFIX + "dialog.labels.";
 104  
     
 105  
     private final static String DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.layout.decorator.editable";
 106  
     private final static String DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_DEFAULT = "true";
 107  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.name.editable";
 108  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_DEFAULT = "true";
 109  
     
 110  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.columnsize.editable";
 111  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_DEFAULT = "true";
 112  
     
 113  
     private final static String DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.add.enabled";
 114  
     private final static String DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_DEFAULT = "true";
 115  
     private final static String DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED = DESKTOP_PAGEEDITOR_NAME_PREFIX + "portlet.add.enabled";
 116  
     private final static String DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_DEFAULT = "true";
 117  
     private final static String DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.portlet.decorator.editable";
 118  
     private final static String DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_DEFAULT = "true";
 119  
     private final static String DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "portlet.decorator.editable";
 120  
     private final static String DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_DEFAULT = "true";
 121  
     
 122  
     private final static String DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT = DESKTOP_PAGEEDITOR_NAME_PREFIX + "movemode.isdefault";
 123  
     private final static String DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_DEFAULT = "true";
 124  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.editable";
 125  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_DEFAULT = "false";
 126  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.toplevel.moveable";
 127  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_DEFAULT = "false";
 128  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.columnsize.editable";
 129  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_DEFAULT = "false";
 130  
     
 131  
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE = DESKTOP_PAGEEDITOR_NAME_PREFIX + "layout.noactions.editor.role";
 132  0
     private final static String DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE_DEFAULT = null;
 133  
     
 134  
     private final static String DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX = DESKTOP_PAGEEDITOR_NAME_PREFIX + "page.layout.depth.max";
 135  
     private final static int DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_DEFAULT = 2;                     // allowed range is 0-15
 136  
 
 137  
     private final static int DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_RESERVED =              0x000F;  // max layout depth (0-15) is first 4 bits
 138  
     private final static int DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_TRUE =         0x0010;
 139  
     private final static int DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_TRUE =                   0x0020;
 140  
     private final static int DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_TRUE =             0x0040;
 141  
     private final static int DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_TRUE =                       0x0080;
 142  
     private final static int DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_TRUE =                    0x0100;
 143  
     private final static int DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_TRUE =        0x0200;
 144  
     private final static int DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_TRUE =             0x0400;
 145  
     private final static int DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_TRUE =                     0x0800;
 146  
     private final static int DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_TRUE =              0x1000;
 147  
     private final static int DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_TRUE =     0x2000;
 148  
     private final static int DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_TRUE =   0x4000;
 149  
     // algorithm used below and on client-size doesn't allow for further expansion (i.e. allows for expansion up to 0x4000)
 150  
     //   (i.e. use of 0x8000 would break algorithm - because it would introduce the possibility of values close to 0xFFFF)
 151  
     //   - if needed, add another variable for a fresh set of flags (and adjust the dependencies)
 152  
             
 153  
     private DecorationFactory decorationFactory;
 154  
         
 155  
     /** desktop pipeline servlet path */
 156  
     private String desktopServletPath;
 157  
     
 158  
     /** default extension for layout templates */
 159  
     private String defaultLayoutTemplateExtension;
 160  
     
 161  
     /** spring-fed servlet context property */
 162  
     private ServletContext servletContext;
 163  
     
 164  
     /** tool for directing output to html &lt;head&gt; */
 165  
     private HeaderResourceFactory headerResourceFactory;
 166  
     
 167  
     /** cache to minimize production of generated desktop configuration content **/
 168  
     private JetspeedCache desktopContentCache;
 169  
         
 170  
     /** base portal URL to override default URL server info from servlet */
 171  0
     private BasePortalURL baseUrlAccess = null;
 172  
     
 173  
     public JetspeedDesktopImpl( DecorationFactory decorationFactory,
 174  
     						    HeaderResourceFactory headerResourceFactory,
 175  
     						    JetspeedCache desktopContentCache,
 176  
     						    String desktopServletPath,
 177  
     						    String defaultLayoutTemplateExtension )
 178  
     {
 179  0
         this( decorationFactory, headerResourceFactory, desktopContentCache, desktopServletPath, defaultLayoutTemplateExtension, null, class="keyword">null, class="keyword">null );
 180  0
     }
 181  
     public JetspeedDesktopImpl( DecorationFactory decorationFactory,
 182  
                                 HeaderResourceFactory headerResourceFactory,
 183  
                                 JetspeedCache desktopContentCache,
 184  
                                 String desktopServletPath,
 185  
                                 String defaultLayoutTemplateExtension,
 186  
                                 String defaultDesktopLayoutDecoration,
 187  
                                 String defaultDesktopPortletDecoration )
 188  
     {
 189  0
     	this( decorationFactory, headerResourceFactory, desktopContentCache, desktopServletPath, defaultLayoutTemplateExtension, defaultDesktopLayoutDecoration, defaultDesktopPortletDecoration, null );
 190  0
     }
 191  
     public JetspeedDesktopImpl( DecorationFactory decorationFactory,
 192  
     		                    HeaderResourceFactory headerResourceFactory,
 193  
     		                    JetspeedCache desktopContentCache,
 194  
     		                    String desktopServletPath,
 195  
     		                    String defaultLayoutTemplateExtension,
 196  
     		                    String defaultDesktopLayoutDecoration,
 197  
     		                    String defaultDesktopPortletDecoration,
 198  
     		                    BasePortalURL baseUrlAccess )
 199  0
     {
 200  0
         this.decorationFactory = decorationFactory;
 201  0
         this.headerResourceFactory = headerResourceFactory;
 202  0
         this.desktopContentCache = desktopContentCache;
 203  
         
 204  0
         if ( desktopServletPath != null && desktopServletPath.length() > 0 )
 205  
         {
 206  0
             if ( desktopServletPath.charAt( 0 ) != '/' )
 207  0
                 desktopServletPath = "/" + desktopServletPath;
 208  
         }
 209  0
         this.desktopServletPath = desktopServletPath;
 210  0
         if ( this.desktopServletPath == null || class="keyword">this.desktopServletPath.length() == 0 )
 211  
         {
 212  0
             log.warn( "JetspeedDesktopImpl initialization is incomplete due to undefined desktop servlet path." );
 213  0
             this.desktopServletPath = null;
 214  
         }
 215  
         
 216  0
         this.defaultLayoutTemplateExtension = defaultLayoutTemplateExtension;
 217  
         
 218  
         // set default layout and portlet decorations only if they are not currently undefined
 219  0
         if ( defaultDesktopLayoutDecoration != null && defaultDesktopLayoutDecoration.length() > 0 )
 220  
         {
 221  0
             String existingDefaultDesktopLayoutDecoration = decorationFactory.getDefaultDesktopLayoutDecoration();
 222  0
             if ( existingDefaultDesktopLayoutDecoration == null || existingDefaultDesktopLayoutDecoration.length() == 0 )
 223  
             {
 224  0
                 decorationFactory.setDefaultDesktopLayoutDecoration( defaultDesktopLayoutDecoration );
 225  
             }
 226  
         }
 227  0
         if ( defaultDesktopPortletDecoration != null && defaultDesktopPortletDecoration.length() > 0 )
 228  
         {
 229  0
             String existingDefaultDesktopPortletDecoration = decorationFactory.getDefaultDesktopPortletDecoration();
 230  0
             if ( existingDefaultDesktopPortletDecoration == null || existingDefaultDesktopPortletDecoration.length() == 0 )
 231  
             {
 232  0
                 decorationFactory.setDefaultDesktopPortletDecoration( defaultDesktopPortletDecoration );
 233  
             }
 234  
         }
 235  
                 
 236  0
         this.baseUrlAccess = baseUrlAccess;
 237  0
     }
 238  
 
 239  
     public void render( RequestContext request )    
 240  
     {
 241  0
         String layoutDecorationTemplatePath = null;
 242  0
         boolean layoutDecorationTemplatePathWasAssigned = false;
 243  
         try
 244  
         {
 245  0
             Page page = request.getPage();
 246  
             
 247  
             // enable desktop
 248  0
             request.setAttribute( JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE, Boolean.TRUE );
 249  
             
 250  
             // get decorations
 251  0
             Theme theme = decorationFactory.getTheme( page, request );
 252  
             
 253  0
             HeaderResource hr = getHeaderResourceFactory().getHeaderResouce( request );
 254  0
             JetspeedDesktopContext desktopContext = new JetspeedDesktopContextImpl( request, this.baseUrlAccess, theme, hr, defaultLayoutTemplateExtension );
 255  
             
 256  0
             String layoutTemplateIdPropertyName = null;
 257  0
             if ( "true".equals( request.getRequest().getParameter( "jsprintmode" ) ) )
 258  0
                 layoutTemplateIdPropertyName = JetspeedDesktopContext.LAYOUT_PRINT_TEMPLATE_ID_PROP;
 259  
             
 260  0
             layoutDecorationTemplatePath = desktopContext.getLayoutTemplatePath( layoutTemplateIdPropertyName );
 261  0
             layoutDecorationTemplatePathWasAssigned = true;
 262  
             
 263  0
             RequestDispatcher dispatcher = request.getRequest().getRequestDispatcher( layoutDecorationTemplatePath );
 264  
             
 265  0
             hr.dojoEnable();
 266  
             
 267  0
             request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_CONTEXT_ATTRIBUTE, desktopContext );
 268  0
             request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_REQUEST_CONTEXT_ATTRIBUTE, request );
 269  0
             request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_COMPONENT_MANAGER_ATTRIBUTE, Jetspeed.getComponentManager() );
 270  
             
 271  0
             String layoutDecorationName = desktopContext.getLayoutDecorationName();
 272  0
             boolean inclStyleLayout = hr.isHeaderSectionIncluded( HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT );
 273  0
             String dojoConfigContentCacheKey = DOJO_CONFIG_LAYOUT_VAR_NAME + "." + layoutDecorationName;
 274  0
             String dojoConfigContent = getCachedContent( dojoConfigContentCacheKey );
 275  
             
 276  0
             if ( dojoConfigContent == null )
 277  
             {
 278  0
 	            String portletDecorationsBasePath = decorationFactory.getPortletDecorationsBasePath();
 279  0
 	            StringBuffer dojoConfigAddOn = new StringBuffer();
 280  0
 	            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_LAYOUT_DECORATION_PATH_VAR_NAME ).append( " = \"" ).append( desktopContext.getLayoutBasePath() ).append( "\"" ).append( EOL );
 281  0
 	            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_LAYOUT_VAR_NAME ).append( " = \"" ).append( layoutDecorationName ).append( "\"" ).append( EOL );
 282  0
 	            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PORTLET_DECORATIONS_PATH_VAR_NAME ).append( " = \"" ).append( portletDecorationsBasePath ).append( "\"" ).append( EOL );
 283  
 
 284  0
 	            LayoutDecoration desktopLayoutDecoration = decorationFactory.getLayoutDecoration( layoutDecorationName, request );
 285  0
 	            if ( desktopLayoutDecoration != null )
 286  
 	            {
 287  0
 	            	boolean atLeastOneFound = false;
 288  0
 	            	StringBuffer loadingPropsBuffer = new StringBuffer();
 289  0
 	                loadingPropsBuffer.append( "    " ).append( DOJO_CONFIG_LOADING_IMGPROPS_NAME ).append( " = { " );
 290  0
 	                for ( int i = 0 ; i < DESKTOP_LOADING_PROPERTY_NAMES.length ; i++ )
 291  
 	                {
 292  0
 	                    String propValue = desktopLayoutDecoration.getProperty( DESKTOP_LOADING_IMG_NAME_PREFIX + DESKTOP_LOADING_PROPERTY_NAMES[ i ] );
 293  0
 	                    if ( propValue != null )
 294  
 	                    {
 295  0
 	                        if ( atLeastOneFound )
 296  
 	                        {
 297  0
 	                            loadingPropsBuffer.append( ", " );
 298  
 	                        }
 299  
 	                        else
 300  
 	                        {
 301  0
 	                        	atLeastOneFound = true;
 302  
 	                        }
 303  0
 	                        String usePropertyName = DESKTOP_LOADING_PROPERTY_NAMES[ i ];
 304  0
 	                        if ( DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES != null && DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES.length > i && DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES[i] != class="keyword">null )
 305  0
 	                        	usePropertyName = DESKTOP_LOADING_OUTPUT_PROPERTY_NAMES[i];
 306  
 	                        	
 307  0
 	                        loadingPropsBuffer.append( usePropertyName ).append( ": " ).append( propValue );
 308  
 	                    }
 309  
 	                }
 310  0
 	                loadingPropsBuffer.append( " };" );
 311  0
 	                if ( atLeastOneFound )
 312  0
 	                	dojoConfigAddOn.append( loadingPropsBuffer.toString() ).append( EOL );
 313  
 	                
 314  0
 	                addPageEditorSettings( dojoConfigAddOn, desktopLayoutDecoration );
 315  0
 	            }
 316  
 	            else
 317  
 	            {
 318  0
 	            	log.error( "Failed to find desktop layout decoration " + layoutDecorationName + " - layout decoration properties cannot be added to content." );
 319  
 	            }
 320  
 	            
 321  0
 	            Set desktopPortletDecorationsNames = decorationFactory.getDesktopPortletDecorations( request );
 322  0
 	            String portletDecorationNamesContent = HeaderResourceLib.makeJSONStringArray( desktopPortletDecorationsNames );
 323  0
 	            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PORTLET_DECORATIONS_ALLOWED_VAR_NAME ).append( " = " ).append( portletDecorationNamesContent ).append( ";" );
 324  
 
 325  0
 	            StringBuffer pDecsOut = new StringBuffer();
 326  0
 	            Iterator desktopPortletDecorationsNamesIter = desktopPortletDecorationsNames.iterator();
 327  0
 	            while ( desktopPortletDecorationsNamesIter.hasNext() )
 328  
 	            {
 329  0
 	                String desktopPortletDecorationName = (String)desktopPortletDecorationsNamesIter.next();
 330  
 	            
 331  0
 	                PortletDecoration desktopPortletDecoration = decorationFactory.getPortletDecoration( desktopPortletDecorationName, request );
 332  
 	                
 333  0
 	                StringBuffer pOut = new StringBuffer();
 334  
 	                
 335  0
 	                String actionButtonOrderContent = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_ORDER );
 336  0
 	                if ( actionButtonOrderContent != null && actionButtonOrderContent.length() > 0 )
 337  
 	                {
 338  0
 	                    pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_ORDER ).append( ": " ).append( actionButtonOrderContent );
 339  
 	                }
 340  
 	                
 341  0
 	                String actionNoImageContent = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_NOIMAGE );
 342  0
 	                if ( actionNoImageContent != null && actionNoImageContent.length() > 0 )
 343  
 	                {
 344  0
 	                	pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_NOIMAGE ).append( ": " ).append( actionNoImageContent );
 345  
 	                }
 346  
 	                
 347  0
 	                String actionMenuOrderContent = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_MENU_ORDER );
 348  0
 	                if ( actionMenuOrderContent != null && actionMenuOrderContent.length() > 0 )
 349  
 	                {
 350  0
 	                	pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_MENU_ORDER ).append( ": " ).append( actionMenuOrderContent );
 351  
 	                }
 352  
 	                
 353  0
 	                String windowActionButtonTooltip = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_TOOLTIP );
 354  0
 	                if ( windowActionButtonTooltip != null && windowActionButtonTooltip.length() > 0 )
 355  
 	                {
 356  0
 	                    pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_TOOLTIP ).append( ": " ).append( windowActionButtonTooltip );
 357  
 	                }
 358  
 
 359  0
 	                String windowActionButtonMax = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_MAX );
 360  0
 	                if ( windowActionButtonMax != null && windowActionButtonMax.length() > 0 )
 361  
 	                {
 362  0
 	                    pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_MAX ).append( ": " ).append( windowActionButtonMax );
 363  
 	                }
 364  
 	                
 365  0
 	                String iconEnabledContent = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ICON_ENABLED );
 366  0
 	                if ( iconEnabledContent != null && iconEnabledContent.length() > 0 )
 367  
 	                {
 368  0
 	                	pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ICON_ENABLED ).append( ": " ).append( iconEnabledContent );
 369  
 	                }
 370  
 	                
 371  0
 	                String iconPathContent = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ICON_PATH );
 372  0
 	                if ( iconPathContent != null && iconPathContent.length() > 0 )
 373  
 	                {
 374  0
 	                	pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ICON_PATH ).append( ": " ).append( iconPathContent ).append( ";" ).append( EOL );
 375  
 	                }
 376  
 	                
 377  0
 	                String titlebarEnabledContent = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_TITLEBAR_ENABLED );
 378  0
 	                if ( titlebarEnabledContent != null && titlebarEnabledContent.length() > 0 )
 379  
 	                {
 380  0
 	                	pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_TITLEBAR_ENABLED ).append( ": " ).append( titlebarEnabledContent );
 381  
 	                }
 382  
 	                
 383  0
 	                String resizebarEnabledContent = desktopPortletDecoration.getProperty( HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_RESIZEBAR_ENABLED );
 384  0
 	                if ( resizebarEnabledContent != null && resizebarEnabledContent.length() > 0 )
 385  
 	                {
 386  0
 	                	pOut.append( ( pOut.length() > 0 ) ? ", " : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_RESIZEBAR_ENABLED ).append( ": " ).append( resizebarEnabledContent );
 387  
 	                }
 388  
 	                
 389  0
 	                if ( pOut.length() > 0 )
 390  
 	                {
 391  0
 	                	if ( pDecsOut.length() == 0 )
 392  
 	                	{
 393  0
 	                		pDecsOut.append( DOJO_CONFIG_PORTLET_DECORATIONS_CONFIG_VAR_NAME ).append( " = { " );
 394  
 	                	}
 395  
 	                	else
 396  
 	                	{
 397  0
 	                		pDecsOut.append( ", " );
 398  
 	                	}
 399  0
 	                	pDecsOut.append( "\"" ).append( desktopPortletDecorationName ).append( "\": { " ).append( pOut.toString() ).append( " }" ).append( EOL );
 400  
 	                }
 401  0
 	            }   // while ( desktopPortletDecorationsNamesIter.hasNext() )
 402  0
 	            if ( pDecsOut.length() > 0 )
 403  
 	            {
 404  0
 	            	pDecsOut.append( " }" );
 405  0
 		            dojoConfigAddOn.append( EOL ).append( "    " ).append( pDecsOut.toString() ).append( ";" );
 406  
 	            }
 407  
 	            
 408  0
 	            dojoConfigContent = dojoConfigAddOn.toString();
 409  0
 	            setCachedContent( dojoConfigContentCacheKey, dojoConfigContent );		            
 410  
             }            
 411  
             
 412  0
             if ( dojoConfigContent != null )
 413  
             {
 414  0
             	hr.addHeaderSectionFragment( DOJO_CONFIG_LAYOUT_VAR_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, dojoConfigContent );
 415  
             }
 416  
             
 417  0
             if ( inclStyleLayout )
 418  
             {
 419  0
             	String contextPath = request.getRequest().getContextPath();
 420  0
             	String styleLayoutContentCacheKey = (HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT + "." + layoutDecorationName + "." + contextPath);
 421  0
             	String styleLayoutContent = getCachedContent( styleLayoutContentCacheKey );
 422  0
             	if ( styleLayoutContent == null )
 423  
                 {
 424  0
             		String portletDecorationsBasePath = decorationFactory.getPortletDecorationsBasePath();
 425  0
     	            String portletDecorationsBaseRelative = portletDecorationsBasePath;
 426  0
     	            if ( portletDecorationsBaseRelative != null && portletDecorationsBaseRelative.length() > 1 && portletDecorationsBaseRelative.indexOf( '/' ) == 0 )
 427  
     	            {
 428  0
     	                portletDecorationsBaseRelative = portletDecorationsBaseRelative.substring( 1 );
 429  
     	            }
 430  0
 	                StringBuffer desktopThemeStyleLink = new StringBuffer();
 431  
 	                
 432  0
 	                int stylesheetCount = 0;
 433  0
 	                Iterator stylesheetIter = theme.getStyleSheets().iterator();
 434  0
 	                while ( stylesheetIter.hasNext() )
 435  
 	                {
 436  0
 	                    String stylesheetHref = (String)stylesheetIter.next();
 437  0
 	                    if ( stylesheetHref != null && stylesheetHref.length() > 0 )
 438  
 	                    {
 439  0
 	                        if ( ! stylesheetHref.startsWith( portletDecorationsBaseRelative ) )
 440  
 	                        {   // exclude portlet decorations - in desktop these are loaded via javascript
 441  0
 	                            if ( stylesheetCount > 0 )
 442  
 	                            {
 443  0
 	                                desktopThemeStyleLink.append( EOL );
 444  
 	                            }
 445  
 	                            
 446  0
 	                            desktopThemeStyleLink.append( "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" href=\"" );
 447  
 	                            //desktopThemeStyleLink.append( desktopContext.getPortalResourceUrl( stylesheetHref ) ).append( "\"/>" );
 448  0
 	                            desktopThemeStyleLink.append( contextPath + "/" + stylesheetHref ).append( "\"/>" );
 449  
 	                            
 450  0
 	                            stylesheetCount++;
 451  
 	                        }
 452  
 	                    }
 453  0
 	                }
 454  0
 	                styleLayoutContent = desktopThemeStyleLink.toString();
 455  0
 		            setCachedContent( styleLayoutContentCacheKey, styleLayoutContent );
 456  
                 }
 457  0
                 if ( styleLayoutContent != null && styleLayoutContent.length() > 0 )
 458  
                 {
 459  0
                 	hr.setHeaderSectionType( HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, HeaderResource.HEADER_TYPE_LINK_TAG );
 460  0
                 	hr.addHeaderSectionFragment( "desktop.style.layout", HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, styleLayoutContent );            	
 461  
                 }
 462  
             }
 463  
             
 464  0
             String layoutDecorationLocaleSuffix = "." + layoutDecorationName + "." + request.getLocale().toString();
 465  0
             String desktopActionLabelsCacheKey = DOJO_CONFIG_ACTION_LABELS_NAME + layoutDecorationLocaleSuffix;
 466  0
             String pageEditorLabelsCacheKey = DOJO_CONFIG_PAGEEDITOR_LABELS_NAME + layoutDecorationLocaleSuffix;
 467  0
             String pageEditorDialogLabelsCacheKey = DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME + layoutDecorationLocaleSuffix;
 468  
             
 469  0
             String desktopActionLabelsContent = getCachedContent( desktopActionLabelsCacheKey );
 470  0
             String pageEditorLabelsContent = getCachedContent( pageEditorLabelsCacheKey );
 471  0
             String pageEditorDialogLabelsContent = getCachedContent( pageEditorDialogLabelsCacheKey );
 472  0
             if ( desktopActionLabelsContent == null || pageEditorLabelsContent == class="keyword">null || pageEditorDialogLabelsContent == class="keyword">null )
 473  
             {
 474  0
             	ResourceBundle messages = desktopContext.getLayoutResourceBundle( request.getLocale() );            	
 475  0
             	if ( desktopActionLabelsContent == null )
 476  
             	{
 477  0
             		desktopActionLabelsContent = getResourcesAsJavascriptObject( DESKTOP_ACTION_RESOURCE_NAME_PREFIX, DESKTOP_ACTION_RESOURCE_NAMES, messages, DOJO_CONFIG_ACTION_LABELS_NAME, "    ", true );
 478  0
             		setCachedContent( desktopActionLabelsCacheKey, desktopActionLabelsContent );
 479  
             	}
 480  0
             	if ( pageEditorLabelsContent == null )
 481  
             	{
 482  0
             		pageEditorLabelsContent = getResourcesAsJavascriptObject( DESKTOP_PAGEEDITOR_RESOURCE_NAME_PREFIX, DESKTOP_PAGEEDITOR_RESOURCE_NAMES, messages, DOJO_CONFIG_PAGEEDITOR_LABELS_NAME, "    ", true );
 483  0
             		setCachedContent( pageEditorLabelsCacheKey, pageEditorLabelsContent );
 484  
             	}
 485  0
             	if ( pageEditorDialogLabelsContent == null )
 486  
             	{
 487  0
             		pageEditorDialogLabelsContent = getResourcesAsJavascriptObject( DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAME_PREFIX, DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAMES, messages, DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME, "    ", true );
 488  0
             		setCachedContent( pageEditorDialogLabelsCacheKey, pageEditorDialogLabelsContent );
 489  
             	}
 490  
             }
 491  0
             if ( desktopActionLabelsContent != null && desktopActionLabelsContent.length() > 0 )
 492  
             {
 493  0
                 hr.addHeaderSectionFragment( DOJO_CONFIG_ACTION_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, desktopActionLabelsContent );
 494  
             }
 495  0
             if ( pageEditorLabelsContent != null && pageEditorLabelsContent.length() > 0 )
 496  
             {
 497  0
                 hr.addHeaderSectionFragment( DOJO_CONFIG_PAGEEDITOR_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, pageEditorLabelsContent );
 498  
             }
 499  0
             if ( pageEditorDialogLabelsContent != null && pageEditorDialogLabelsContent.length() > 0 )
 500  
             {
 501  0
                 hr.addHeaderSectionFragment( DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, pageEditorDialogLabelsContent );
 502  
             }
 503  
             
 504  0
             dispatcher.include( request.getRequest(), request.getResponse() );
 505  
         }
 506  0
         catch ( Exception e )
 507  
         {
 508  
             try
 509  
             {
 510  0
                 if ( layoutDecorationTemplatePathWasAssigned )
 511  
                 {
 512  0
                     layoutDecorationTemplatePath = ( layoutDecorationTemplatePath == null || layoutDecorationTemplatePath.length() == 0 ? "null" : layoutDecorationTemplatePath );
 513  0
                     log.error( "Failed to include desktop layout decoration at path " + layoutDecorationTemplatePath, e );
 514  0
                     request.getResponse().getWriter().println( "Desktop layout decoration " + layoutDecorationTemplatePath + " is not available" );
 515  
                 }
 516  
                 else
 517  
                 {
 518  0
                     log.error( "Failed to initialize for inclusion of desktop layout decoration", e );
 519  0
                     request.getResponse().getWriter().println( "Failed to initialize for inclusion of desktop layout decoration" );
 520  
                 }
 521  
             }
 522  0
             catch ( IOException ioe )
 523  
             {
 524  0
                 log.error( "Failed to write desktop layout decoration exception information to servlet output writer", ioe );
 525  0
             }
 526  0
         }
 527  0
     }
 528  
     
 529  
     private void addPageEditorSettings( StringBuffer dojoConfigAddOn, LayoutDecoration desktopLayoutDecoration )
 530  
     {
 531  0
     	int[] pageEditorConfigFlags = new class="keyword">int[] { 0 };
 532  
     	String propValue;
 533  
 
 534  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE );
 535  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DECORATOR_EDITABLE_TRUE );
 536  
     	
 537  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE );
 538  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NAME_EDITABLE_TRUE );
 539  
     	
 540  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE );
 541  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_COLUMNSIZE_EDITABLE_TRUE );
 542  
     	
 543  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED );
 544  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_DEFAULT, DESKTOP_PAGEEDITOR_PAGE_ADD_ENABLED_TRUE );
 545  
     	
 546  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED );
 547  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_DEFAULT, DESKTOP_PAGEEDITOR_PORTLET_ADD_ENABLED_TRUE );
 548  
     	
 549  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE );
 550  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_PAGE_PORTLET_DECORATOR_EDITABLE_TRUE );
 551  
 
 552  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE );
 553  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_PORTLET_DECORATOR_EDITABLE_TRUE );
 554  
 
 555  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE );
 556  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITABLE_TRUE );
 557  
     	
 558  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE );
 559  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_TOPLEVEL_MOVEABLE_TRUE );
 560  
     	
 561  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE );
 562  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_DEFAULT, DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_COLUMNSIZE_EDITABLE_TRUE );
 563  
 
 564  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT );
 565  0
     	processBooleanFlagProperty( pageEditorConfigFlags, propValue, DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_DEFAULT, DESKTOP_PAGEEDITOR_MOVEMODE_ISDEFAULT_TRUE );
 566  
     	
 567  0
     	propValue = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX );
 568  0
     	Integer maxLayoutNestingObj = null;
 569  
     	try
 570  
     	{
 571  0
     		maxLayoutNestingObj = new Integer( propValue );
 572  
     	}
 573  0
     	catch ( NumberFormatException ex )
 574  
     	{
 575  0
     		maxLayoutNestingObj = new Integer( DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_DEFAULT );
 576  0
     	}
 577  0
     	int maxLayoutNesting = maxLayoutNestingObj.class="keyword">intValue();
 578  0
     	if ( maxLayoutNesting < 0 )
 579  0
     		maxLayoutNesting = 0;
 580  0
     	if ( maxLayoutNesting > DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_RESERVED )
 581  0
     		maxLayoutNesting = DESKTOP_PAGEEDITOR_PAGE_LAYOUT_DEPTH_MAX_RESERVED;
 582  0
     	pageEditorConfigFlags[0] += maxLayoutNesting;
 583  
     	    	
 584  0
     	String allowEditNoactionsRole = desktopLayoutDecoration.getProperty( DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE );
 585  0
     	if ( allowEditNoactionsRole == null )
 586  0
     		allowEditNoactionsRole = DESKTOP_PAGEEDITOR_LAYOUT_NOACTIONS_EDITOR_ROLE_DEFAULT;
 587  0
     	if ( allowEditNoactionsRole == null )
 588  0
     		allowEditNoactionsRole = "";
 589  0
     	char[] allowEditNoactionsRoleChars = allowEditNoactionsRole.toCharArray();
 590  0
     	int allowEditNoactionsRoleCharsLen = ( ( allowEditNoactionsRoleChars == null ) ? 0 : allowEditNoactionsRoleChars.length );
 591  0
     	Random rnd = new Random();
 592  0
     	int extrasCount = ( allowEditNoactionsRoleCharsLen > 0 ? getRandom( rnd, 2, 5 ) : getRandom( rnd, 5, 8 ) );
 593  0
     	int hexLen = 1 + extrasCount + allowEditNoactionsRoleCharsLen;
 594  0
     	int addedExtras = 0;
 595  0
     	int nextRoleChar = 0;
 596  0
     	StringBuffer pageEditorSettings = new StringBuffer();
 597  0
     	for ( int i = 0 ; i < hexLen ; i++ )
 598  
     	{   // here we "mix-up" (obfuscate) the way this information is provided to the client-side
 599  
     		//    this is done to avoid obvious display of certain strings in content, like "manager" or "admin"
 600  0
     		int rndVal = getRandom( rnd, 0x1000, 0xFFFD );
 601  0
     		boolean isRndValEven = ( (rndVal % 2) == 0 );
 602  0
     		int rndValTens = (class="keyword">int)Math.floor( rndVal / 10 );
 603  0
     		int rndValTensEven = ( ( ( rndValTens % 2 ) == 1 ) ? Math.max( rndValTens - 1, 2 ) : rndValTens );
 604  
     		int valToHex;
 605  0
     		if ( i == 0 )
 606  
     		{
 607  0
     			valToHex = pageEditorConfigFlags[0];
 608  
     		}
 609  0
     		else if ( addedExtras < extrasCount && ( ( ( i % 2 ) == 1 ) || nextRoleChar >= allowEditNoactionsRoleCharsLen ) )
 610  
     		{
 611  0
     			if ( ! isRndValEven )
 612  0
     				rndVal++;
 613  0
     			valToHex = getRandom( rnd, 0x0A00, 0xDFFF );
 614  0
     			if ( (valToHex % 2) == 1 )
 615  0
     				valToHex = valToHex + 1;
 616  0
     			pageEditorSettings.append( ", " );
 617  0
     			addedExtras++;
 618  
     		}
 619  
     		else
 620  
     		{
 621  
     			//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 ) );
 622  0
     			valToHex = ( ((int)allowEditNoactionsRoleChars[nextRoleChar] << 4 ) | 0x0001 );
 623  0
     			pageEditorSettings.append( ", " );
 624  0
     			nextRoleChar++;
 625  
     		}
 626  0
     		String rndValHex = Integer.toHexString( 0x10000 | rndVal ).substring( 1 );
 627  
     		
 628  0
     		String realValHex = Integer.toHexString( 0x10000 | ( valToHex + rndValTensEven ) ).substring( 1 );
 629  0
     		if ( isRndValEven && i > 0 )
 630  0
     			pageEditorSettings.append( "0x" ).append( realValHex ).append( rndValHex );
 631  
     		else
 632  0
     			pageEditorSettings.append( "0x" ).append( rndValHex ).append( realValHex );
 633  
     	}
 634  0
     	dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PAGEEDITOR_SETTINGS_NAME ).append( " = [ " ).append( pageEditorSettings.toString() ).append( " ];" ).append( EOL );
 635  0
     }
 636  
     private int getRandom( Random rnd, class="keyword">int minValueInclusive, class="keyword">int maxValueExclusive )
 637  
     {
 638  0
     	if ( minValueInclusive > maxValueExclusive )
 639  0
     		throw new IllegalArgumentException( "minValueInclusive (" + minValueInclusive + ") cannot be greater than maxValueExclusive (" + maxValueExclusive + ")" );
 640  
 
 641  0
     	int diff = (class="keyword">int)( maxValueExclusive - minValueInclusive );
 642  0
     	if ( dclass="keyword">iff == 0 )
 643  0
     		return minValueInclusive;
 644  
 
 645  0
     	double sample = rnd.nextDouble();
 646  0
     	int result = (class="keyword">int)( sample * diff + minValueInclusive );
 647  0
     	result = ( ( result != maxValueExclusive ) ? result : ( result - 1 ) );
 648  0
     	return result;
 649  
     }
 650  
     
 651  
     private void processBooleanFlagProperty( int[] flags, Object propVal, Object propValDefault, class="keyword">int propIsTrueBit )
 652  
     {
 653  0
         String boolStr = ( ( propVal == null ) ? ( ( propValDefault == class="keyword">null ) ? (String)class="keyword">null : propValDefault.toString() ) : propVal.toString() );
 654  0
         if ( boolStr != null && boolStr.toLowerCase().equals( "true" ) )
 655  0
         	flags[0] |= propIsTrueBit;
 656  0
     }
 657  
 
 658  
     private String getCachedContent( String cacheKey )
 659  
     {
 660  0
     	CacheElement cachedElement = desktopContentCache.get(cacheKey);
 661  0
         if (cachedElement != null)
 662  0
          return (String)cachedElement.getContent();  
 663  0
         return null;
 664  
     }
 665  
     private void setCachedContent( String cacheKey, String content )
 666  
     {
 667  0
     	CacheElement cachedElement = desktopContentCache.createElement( cacheKey, content );
 668  0
     	cachedElement.setTimeToIdleSeconds(desktopContentCache.getTimeToIdleSeconds());
 669  0
     	cachedElement.setTimeToLiveSeconds(desktopContentCache.getTimeToLiveSeconds());
 670  0
     	desktopContentCache.put( cachedElement );
 671  0
     }
 672  
 
 673  
     private String getResourcesAsJavascriptObject( String resourceNamePrefix, String[] resourceNames, ResourceBundle messages, String varName, String indent, boolean ifEmptyReturnEmptyString )
 674  
     {
 675  0
     	StringBuffer jsObjBuffer = new StringBuffer();
 676  0
         boolean atLeastOneFound = false;
 677  0
         if ( indent != null )
 678  0
         	jsObjBuffer.append( indent );
 679  0
         if ( varName != null )
 680  0
         	jsObjBuffer.append( varName ).append( " = " );
 681  0
         jsObjBuffer.append( "{ " );
 682  0
         for ( int i = 0 ; i < resourceNames.length ; i++ )
 683  
         {
 684  0
             String resourceValue = null;
 685  
         	try
 686  
         	{
 687  0
         		resourceValue = messages.getString( resourceNamePrefix + resourceNames[ i ] );
 688  
         	}
 689  0
         	catch ( java.util.MissingResourceException ex ) { }
 690  0
             if ( resourceValue != null )
 691  
             {
 692  0
                 if ( atLeastOneFound )
 693  
                 {
 694  0
                     jsObjBuffer.append( ", " );
 695  
                 }
 696  
                 else
 697  
                 {
 698  0
                 	atLeastOneFound = true;
 699  
                 }
 700  0
                 jsObjBuffer.append( resourceNames[ i ] ).append( ": \"" ).append( resourceValue ).append( "\"" );
 701  
             }
 702  
         }
 703  0
         jsObjBuffer.append( " };" );
 704  0
         if ( ! atLeastOneFound && class="keyword">ifEmptyReturnEmptyString )
 705  0
         	return "";
 706  0
         return jsObjBuffer.toString();
 707  
     }
 708  
     
 709  
     public boolean isDesktopEnabled( RequestContext requestContext )
 710  
     {
 711  0
         return this.decorationFactory.isDesktopEnabled( requestContext );
 712  
     }
 713  
     
 714  
     public ServletContext getServletContext()
 715  
     {
 716  0
         return servletContext;
 717  
     }
 718  
 
 719  
     public void setServletContext(ServletContext servletContext)
 720  
     {
 721  0
         this.servletContext = servletContext;
 722  0
     }
 723  
     
 724  
     public HeaderResourceFactory getHeaderResourceFactory()
 725  
     {
 726  0
         return this.headerResourceFactory;
 727  
     }
 728  
     
 729  
     // get portal urls - each of these methods is copied from HeaderResourceImpl.java
 730  
  
 731  
     /**
 732  
      * Desktop servlet path ( e.g. /desktop )
 733  
      * 
 734  
      * @return portal base url
 735  
      */
 736  
     public String getDesktopServletPath()
 737  
     {
 738  0
         return this.desktopServletPath;
 739  
     }
 740  
     
 741  
     /**
 742  
      * Portal base url ( e.g. http://localhost:8080/jetspeed )
 743  
      * 
 744  
      * @return portal base url
 745  
      */
 746  
     public String getPortalBaseUrl( RequestContext context )
 747  
     {
 748  0
         return HeaderResourceLib.getPortalBaseUrl( context, this.baseUrlAccess );
 749  
     }
 750  
     
 751  
     /**
 752  
      * Portal base url ( e.g. http://localhost:8080/jetspeed )
 753  
      * 
 754  
      * @return portal base url
 755  
      */
 756  
     public String getPortalBaseUrl( RequestContext context, boolean encode )
 757  
     {
 758  0
         String baseurl = getPortalBaseUrl( context );
 759  0
         if ( ! encode )
 760  
         {
 761  0
             return baseurl;
 762  
         }
 763  
         else
 764  
         {
 765  0
             return context.getResponse().encodeURL( baseurl );
 766  
         }
 767  
     }
 768  
     
 769  
     /**
 770  
      * Portal base url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/javascript/dojo/ )
 771  
      * 
 772  
      * @return portal base url with relativePath argument appended
 773  
      */
 774  
     public String getPortalResourceUrl( RequestContext context, String relativePath )
 775  
     {
 776  0
         return getPortalResourceUrl( context, relativePath, false );
 777  
     }
 778  
     
 779  
     /**
 780  
      * Portal base url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/javascript/dojo/ )
 781  
      * 
 782  
      * @return portal base url with relativePath argument appended
 783  
      */
 784  
     public String getPortalResourceUrl( RequestContext context, String relativePath, boolean encode )
 785  
     {
 786  0
         return HeaderResourceLib.getPortalResourceUrl( relativePath, getPortalBaseUrl( context ), encode, context );
 787  
     }
 788  
     
 789  
     /**
 790  
      * Portal base servlet url ( e.g. http://localhost:8080/jetspeed/desktop/ )
 791  
      * 
 792  
      * @return portal base servlet url
 793  
      */
 794  
     public String getPortalUrl( RequestContext context )
 795  
     {
 796  0
         return HeaderResourceLib.getPortalUrl( getPortalBaseUrl( context ), context, getDesktopServletPath() );
 797  
     }
 798  
     
 799  
     /**
 800  
      * Portal base servlet url ( e.g. http://localhost:8080/jetspeed/desktop/ )
 801  
      * 
 802  
      * @return portal base servlet url
 803  
      */
 804  
     public String getPortalUrl( RequestContext context, boolean encode )
 805  
     {
 806  0
         return getPortalUrl( context, null, encode );
 807  
     }
 808  
     
 809  
     /**
 810  
      * Portal base servlet url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/desktop/default-page.psml )
 811  
      * 
 812  
      * @return portal base servlet url with relativePath argument appended
 813  
      */
 814  
     public String getPortalUrl( RequestContext context, String relativePath )
 815  
     {
 816  0
         return getPortalUrl( context, relativePath, false );
 817  
     }
 818  
     
 819  
     /**
 820  
      * Portal base servlet url with relativePath argument appended ( e.g. http://localhost:8080/jetspeed/desktop/default-page.psml )
 821  
      * 
 822  
      * @return portal base servlet url with relativePath argument appended
 823  
      */
 824  
     public String getPortalUrl( RequestContext context, String relativePath, boolean encode )
 825  
     {
 826  0
         return HeaderResourceLib.getPortalResourceUrl( relativePath, getPortalUrl( context ), encode, context );
 827  
     }
 828  
 }
 829  
     

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.