Author: smilek
Date: Thu Oct 25 17:17:28 2007
New Revision: 588437

URL: http://svn.apache.org/viewvc?rev=588437&view=rev
Log:
added loading property content; changed <link> tag insertion to prevent adding 
portlet decorator stylesheets

Modified:
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java

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=588437&r1=588436&r2=588437&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 Oct 25 17:17:28 2007
@@ -31,6 +31,7 @@
 import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.container.url.BasePortalURL;
 import org.apache.jetspeed.decoration.DecorationFactory;
+import org.apache.jetspeed.decoration.LayoutDecoration;
 import org.apache.jetspeed.decoration.PortletDecoration;
 import org.apache.jetspeed.decoration.Theme;
 import org.apache.jetspeed.desktop.JetspeedDesktop;
@@ -58,9 +59,13 @@
     private final static String 
DOJO_CONFIG_PORTLET_DECORATIONS_ALLOWED_VAR_NAME = 
HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + 
".portletDecorationsAllowed";
     private final static String 
DOJO_CONFIG_PORTLET_DECORATIONS_CONFIG_VAR_NAME = 
HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + 
".portletDecorationsProperties";    
     private final static String DOJO_CONFIG_ACTION_LABELS_NAME = 
HeaderResource.HEADER_INTERNAL_DOJO_CONFIG_JETSPEED_VAR_NAME + 
".desktopActionLabels";
+    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[] DESKTOP_LOADING_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",
@@ -79,6 +84,7 @@
                                                                   
"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.";
@@ -152,12 +158,7 @@
         
         this.baseUrlAccess = baseUrlAccess;
     }
-    /*
-        CacheElement cachedElement = 
desktopContentCache.createElement(content.getCacheKey(), content);
-        
cachedElement.setTimeToIdleSeconds(desktopContentCache.getTimeToIdleSeconds());
-        
cachedElement.setTimeToLiveSeconds(desktopContentCache.getTimeToLiveSeconds());
-        desktopContentCache.put(cachedElement);
-     */
+
     public void render( RequestContext request )    
     {
         String layoutDecorationTemplatePath = null;
@@ -193,156 +194,188 @@
             String layoutDecorationName = 
desktopContext.getLayoutDecorationName();
             boolean inclStyleLayout = hr.isHeaderSectionIncluded( 
HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT );
             String dojoConfigContentCacheKey = DOJO_CONFIG_LAYOUT_VAR_NAME + 
"." + layoutDecorationName;
-            String styleLayoutContentCacheKey = ( inclStyleLayout ? 
(HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT + "." + 
layoutDecorationName) : (String)null );
             String dojoConfigContent = getCachedContent( 
dojoConfigContentCacheKey );
-            String styleLayoutContent = ( inclStyleLayout ? getCachedContent( 
styleLayoutContentCacheKey ) : (String)null );
-            
             
-            
-            
-            if ( dojoConfigContent == null || ( styleLayoutContent == null && 
inclStyleLayout ) )
+            if ( dojoConfigContent == null )
             {
                    String portletDecorationsBasePath = 
decorationFactory.getPortletDecorationsBasePath();
-                   String portletDecorationsBaseRelative = 
portletDecorationsBasePath;
-                   if ( portletDecorationsBaseRelative != null && 
portletDecorationsBaseRelative.length() > 1 && 
portletDecorationsBaseRelative.indexOf( '/' ) == 0 )
+                   StringBuffer dojoConfigAddOn = new StringBuffer();
+                   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 )
                    {
-                       portletDecorationsBaseRelative = 
portletDecorationsBaseRelative.substring( 1 );
+                       boolean atLeastOneFound = false;
+                       StringBuffer loadingPropsBuffer = new StringBuffer();
+                       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 ] );
+                           if ( propValue != null )
+                           {
+                               if ( atLeastOneFound )
+                               {
+                                   loadingPropsBuffer.append( ", " );
+                               }
+                               else
+                               {
+                                       atLeastOneFound = true;
+                               }
+                               loadingPropsBuffer.append( 
DESKTOP_LOADING_PROPERTY_NAMES[ i ] ).append( ": " ).append( propValue );
+                           }
+                       }
+                       loadingPropsBuffer.append( " };" );
+                       if ( atLeastOneFound )
+                               dojoConfigAddOn.append( 
loadingPropsBuffer.toString() ).append( EOL );
                    }
-                   
-                   if ( dojoConfigContent == null )
+                   else
                    {
-                           StringBuffer dojoConfigAddOn = new StringBuffer();
-                           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 );
-                           Set desktopPortletDecorationsNames = 
decorationFactory.getDesktopPortletDecorations( request );
-                           String portletDecorationNamesContent = 
HeaderResourceLib.makeJSONStringArray( desktopPortletDecorationsNames );
-                           dojoConfigAddOn.append( "    " ).append( 
DOJO_CONFIG_PORTLET_DECORATIONS_ALLOWED_VAR_NAME ).append( " = " ).append( 
portletDecorationNamesContent ).append( ";" );
-
-                           StringBuffer pDecsOut = new StringBuffer();
-                           Iterator desktopPortletDecorationsNamesIter = 
desktopPortletDecorationsNames.iterator();
-                           while ( 
desktopPortletDecorationsNamesIter.hasNext() )
-                           {
-                               String desktopPortletDecorationName = 
(String)desktopPortletDecorationsNamesIter.next();
-                           
-                               PortletDecoration desktopPortletDecoration = 
decorationFactory.getPortletDecoration( desktopPortletDecorationName, request );
-                               
-                               StringBuffer pOut = new StringBuffer();
-                               
-                               String actionButtonOrderContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_ORDER );
-                               if ( actionButtonOrderContent != null && 
actionButtonOrderContent.length() > 0 )
-                               {
-                                   pOut.append( ( pOut.length() > 0 ) ? ", " : 
"" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_ORDER ).append( 
": " ).append( actionButtonOrderContent );
-                               }
-                               
-                               String actionNoImageContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_NOIMAGE );
-                               if ( actionNoImageContent != null && 
actionNoImageContent.length() > 0 )
-                               {
-                                       pOut.append( ( pOut.length() > 0 ) ? ", 
" : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_NOIMAGE ).append( ": 
" ).append( actionNoImageContent );
-                               }
-                               
-                               String actionMenuOrderContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_MENU_ORDER );
-                               if ( actionMenuOrderContent != null && 
actionMenuOrderContent.length() > 0 )
-                               {
-                                       pOut.append( ( pOut.length() > 0 ) ? ", 
" : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_MENU_ORDER ).append( 
": " ).append( actionMenuOrderContent );
-                               }
-                               
-                               String windowActionButtonTooltip = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_TOOLTIP );
-                               if ( windowActionButtonTooltip != null && 
windowActionButtonTooltip.length() > 0 )
-                               {
-                                   pOut.append( ( pOut.length() > 0 ) ? ", " : 
"" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_TOOLTIP ).append( 
": " ).append( windowActionButtonTooltip );
-                               }
-
-                               String windowActionButtonMax = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_MAX );
-                               if ( windowActionButtonMax != null && 
windowActionButtonMax.length() > 0 )
-                               {
-                                   pOut.append( ( pOut.length() > 0 ) ? ", " : 
"" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_MAX ).append( ": 
" ).append( windowActionButtonMax );
-                               }
-                               
-                               String iconEnabledContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ICON_ENABLED );
-                               if ( iconEnabledContent != null && 
iconEnabledContent.length() > 0 )
-                               {
-                                       pOut.append( ( pOut.length() > 0 ) ? ", 
" : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ICON_ENABLED ).append( ": " 
).append( iconEnabledContent );
-                               }
-                               
-                               String iconPathContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ICON_PATH );
-                               if ( iconPathContent != null && 
iconPathContent.length() > 0 )
-                               {
-                                       pOut.append( ( pOut.length() > 0 ) ? ", 
" : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_ICON_PATH ).append( ": " 
).append( iconPathContent ).append( ";" ).append( EOL );
-                               }
-                               
-                               String titlebarEnabledContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_TITLEBAR_ENABLED );
-                               if ( titlebarEnabledContent != null && 
titlebarEnabledContent.length() > 0 )
-                               {
-                                       pOut.append( ( pOut.length() > 0 ) ? ", 
" : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_TITLEBAR_ENABLED ).append( 
": " ).append( titlebarEnabledContent );
-                               }
-                               
-                               String resizebarEnabledContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_RESIZEBAR_ENABLED );
-                               if ( resizebarEnabledContent != null && 
resizebarEnabledContent.length() > 0 )
-                               {
-                                       pOut.append( ( pOut.length() > 0 ) ? ", 
" : "" ).append( HeaderResource.DESKTOP_JSON_WINDOW_RESIZEBAR_ENABLED ).append( 
": " ).append( resizebarEnabledContent );
-                               }
-                               
-                               if ( pOut.length() > 0 )
-                               {
-                                       if ( pDecsOut.length() == 0 )
-                                       {
-                                               pDecsOut.append( 
DOJO_CONFIG_PORTLET_DECORATIONS_CONFIG_VAR_NAME ).append( " = { " );
-                                       }
-                                       else
-                                       {
-                                               pDecsOut.append( ", " );
-                                       }
-                                       pDecsOut.append( "\"" ).append( 
desktopPortletDecorationName ).append( "\": { " ).append( pOut.toString() 
).append( " }" ).append( EOL );
-                               }
-                           }   // while ( 
desktopPortletDecorationsNamesIter.hasNext() )
-                           if ( pDecsOut.length() > 0 )
-                           {
-                               pDecsOut.append( " }" );
-                                   dojoConfigAddOn.append( EOL ).append( "    
" ).append( pDecsOut.toString() ).append( ";" );
-                           }
-                           
-                           dojoConfigContent = dojoConfigAddOn.toString();
-                           setCachedContent( dojoConfigContentCacheKey, 
dojoConfigContent );                       
+                       log.error( "Failed to find desktop layout decoration " 
+ layoutDecorationName + " - layout decoration properties cannot be added to 
content." );
                    }
                    
-                   if ( inclStyleLayout )
+                   Set desktopPortletDecorationsNames = 
decorationFactory.getDesktopPortletDecorations( request );
+                   String portletDecorationNamesContent = 
HeaderResourceLib.makeJSONStringArray( desktopPortletDecorationsNames );
+                   dojoConfigAddOn.append( "    " ).append( 
DOJO_CONFIG_PORTLET_DECORATIONS_ALLOWED_VAR_NAME ).append( " = " ).append( 
portletDecorationNamesContent ).append( ";" );
+
+                   StringBuffer pDecsOut = new StringBuffer();
+                   Iterator desktopPortletDecorationsNamesIter = 
desktopPortletDecorationsNames.iterator();
+                   while ( desktopPortletDecorationsNamesIter.hasNext() )
                    {
-                       if ( styleLayoutContent == null )
+                       String desktopPortletDecorationName = 
(String)desktopPortletDecorationsNamesIter.next();
+                   
+                       PortletDecoration desktopPortletDecoration = 
decorationFactory.getPortletDecoration( desktopPortletDecorationName, request );
+                       
+                       StringBuffer pOut = new StringBuffer();
+                       
+                       String actionButtonOrderContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_ORDER );
+                       if ( actionButtonOrderContent != null && 
actionButtonOrderContent.length() > 0 )
+                       {
+                           pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_ORDER ).append( ": " 
).append( actionButtonOrderContent );
+                       }
+                       
+                       String actionNoImageContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_NOIMAGE );
+                       if ( actionNoImageContent != null && 
actionNoImageContent.length() > 0 )
+                       {
+                               pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_NOIMAGE ).append( ": " 
).append( actionNoImageContent );
+                       }
+                       
+                       String actionMenuOrderContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_MENU_ORDER );
+                       if ( actionMenuOrderContent != null && 
actionMenuOrderContent.length() > 0 )
+                       {
+                               pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_MENU_ORDER ).append( ": " 
).append( actionMenuOrderContent );
+                       }
+                       
+                       String windowActionButtonTooltip = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_TOOLTIP );
+                       if ( windowActionButtonTooltip != null && 
windowActionButtonTooltip.length() > 0 )
+                       {
+                           pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_TOOLTIP ).append( ": 
" ).append( windowActionButtonTooltip );
+                       }
+
+                       String windowActionButtonMax = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ACTION_BUTTON_MAX );
+                       if ( windowActionButtonMax != null && 
windowActionButtonMax.length() > 0 )
                        {
-                               StringBuffer desktopThemeStyleLink = new 
StringBuffer();
-                               int stylesheetCount = 0;
-                               Iterator stylesheetIter = 
theme.getStyleSheets().iterator();
-                               while ( stylesheetIter.hasNext() )
-                               {
-                                   String stylesheetHref = 
(String)stylesheetIter.next();
-                                   if ( stylesheetHref != null && 
stylesheetHref.length() > 0 )
-                                   {
-                                       if ( ! stylesheetHref.startsWith( 
portletDecorationsBaseRelative ) )
-                                       {   // exclude portlet decorations - in 
desktop these are loaded via javascript
-                                           if ( stylesheetCount > 0 )
-                                           {
-                                               desktopThemeStyleLink.append( 
EOL );
-                                           }
-                                           desktopThemeStyleLink.append( 
"<link rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" 
href=\"" );
-                                           desktopThemeStyleLink.append( 
desktopContext.getPortalResourceUrl( stylesheetHref ) ).append( "\"/>" );
-                                           stylesheetCount++;
-                                       }
-                                   }
-                               }
-                               styleLayoutContent = 
desktopThemeStyleLink.toString();
-                                   setCachedContent( 
styleLayoutContentCacheKey, styleLayoutContent );
+                           pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_ACTION_BUTTON_MAX ).append( ": " 
).append( windowActionButtonMax );
                        }
+                       
+                       String iconEnabledContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ICON_ENABLED );
+                       if ( iconEnabledContent != null && 
iconEnabledContent.length() > 0 )
+                       {
+                               pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_ICON_ENABLED ).append( ": " 
).append( iconEnabledContent );
+                       }
+                       
+                       String iconPathContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_ICON_PATH );
+                       if ( iconPathContent != null && 
iconPathContent.length() > 0 )
+                       {
+                               pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_ICON_PATH ).append( ": " ).append( 
iconPathContent ).append( ";" ).append( EOL );
+                       }
+                       
+                       String titlebarEnabledContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_TITLEBAR_ENABLED );
+                       if ( titlebarEnabledContent != null && 
titlebarEnabledContent.length() > 0 )
+                       {
+                               pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_TITLEBAR_ENABLED ).append( ": " 
).append( titlebarEnabledContent );
+                       }
+                       
+                       String resizebarEnabledContent = 
desktopPortletDecoration.getProperty( 
HeaderResource.HEADER_CONFIG_DESKTOP_WINDOW_RESIZEBAR_ENABLED );
+                       if ( resizebarEnabledContent != null && 
resizebarEnabledContent.length() > 0 )
+                       {
+                               pOut.append( ( pOut.length() > 0 ) ? ", " : "" 
).append( HeaderResource.DESKTOP_JSON_WINDOW_RESIZEBAR_ENABLED ).append( ": " 
).append( resizebarEnabledContent );
+                       }
+                       
+                       if ( pOut.length() > 0 )
+                       {
+                               if ( pDecsOut.length() == 0 )
+                               {
+                                       pDecsOut.append( 
DOJO_CONFIG_PORTLET_DECORATIONS_CONFIG_VAR_NAME ).append( " = { " );
+                               }
+                               else
+                               {
+                                       pDecsOut.append( ", " );
+                               }
+                               pDecsOut.append( "\"" ).append( 
desktopPortletDecorationName ).append( "\": { " ).append( pOut.toString() 
).append( " }" ).append( EOL );
+                       }
+                   }   // while ( desktopPortletDecorationsNamesIter.hasNext() 
)
+                   if ( pDecsOut.length() > 0 )
+                   {
+                       pDecsOut.append( " }" );
+                           dojoConfigAddOn.append( EOL ).append( "    " 
).append( pDecsOut.toString() ).append( ";" );
                    }
-            }
+                   
+                   dojoConfigContent = dojoConfigAddOn.toString();
+                   setCachedContent( dojoConfigContentCacheKey, 
dojoConfigContent );                       
+            }            
+            
             if ( dojoConfigContent != null )
             {
                hr.addHeaderSectionFragment( DOJO_CONFIG_LAYOUT_VAR_NAME, 
HeaderResource.HEADER_SECTION_DOJO_CONFIG, dojoConfigContent );
             }
-            if ( inclStyleLayout && styleLayoutContent != null && 
styleLayoutContent.length() > 0 )
+            
+            if ( inclStyleLayout )
             {
-               hr.setHeaderSectionType( 
HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, 
HeaderResource.HEADER_TYPE_LINK_TAG );
-               hr.addHeaderSectionFragment( "desktop.style.layout", 
HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, styleLayoutContent );       
           
+               String contextPath = request.getRequest().getContextPath();
+               String styleLayoutContentCacheKey = 
(HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT + "." + 
layoutDecorationName + "." + contextPath);
+               String styleLayoutContent = getCachedContent( 
styleLayoutContentCacheKey );
+               if ( styleLayoutContent == null )
+                {
+                       String portletDecorationsBasePath = 
decorationFactory.getPortletDecorationsBasePath();
+                   String portletDecorationsBaseRelative = 
portletDecorationsBasePath;
+                   if ( portletDecorationsBaseRelative != null && 
portletDecorationsBaseRelative.length() > 1 && 
portletDecorationsBaseRelative.indexOf( '/' ) == 0 )
+                   {
+                       portletDecorationsBaseRelative = 
portletDecorationsBaseRelative.substring( 1 );
+                   }
+                       StringBuffer desktopThemeStyleLink = new StringBuffer();
+                       
+                       int stylesheetCount = 0;
+                       Iterator stylesheetIter = 
theme.getStyleSheets().iterator();
+                       while ( stylesheetIter.hasNext() )
+                       {
+                           String stylesheetHref = 
(String)stylesheetIter.next();
+                           if ( stylesheetHref != null && 
stylesheetHref.length() > 0 )
+                           {
+                               if ( ! stylesheetHref.startsWith( 
portletDecorationsBaseRelative ) )
+                               {   // exclude portlet decorations - in desktop 
these are loaded via javascript
+                                   if ( stylesheetCount > 0 )
+                                   {
+                                       desktopThemeStyleLink.append( EOL );
+                                   }
+                                   
+                                   desktopThemeStyleLink.append( "<link 
rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" href=\"" );
+                                   //desktopThemeStyleLink.append( 
desktopContext.getPortalResourceUrl( stylesheetHref ) ).append( "\"/>" );
+                                   desktopThemeStyleLink.append( contextPath + 
"/" + stylesheetHref ).append( "\"/>" );
+                                   
+                                   stylesheetCount++;
+                               }
+                           }
+                       }
+                       styleLayoutContent = desktopThemeStyleLink.toString();
+                           setCachedContent( styleLayoutContentCacheKey, 
styleLayoutContent );
+                }
+                if ( styleLayoutContent != null && styleLayoutContent.length() 
> 0 )
+                {
+                       hr.setHeaderSectionType( 
HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, 
HeaderResource.HEADER_TYPE_LINK_TAG );
+                       hr.addHeaderSectionFragment( "desktop.style.layout", 
HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, styleLayoutContent );       
           
+                }
             }
             
             String layoutDecorationLocaleSuffix = "." + layoutDecorationName + 
"." + request.getLocale().toString();
@@ -433,7 +466,7 @@
                jsObjBuffer.append( indent );
         if ( varName != null )
                jsObjBuffer.append( varName ).append( " = " );
-        jsObjBuffer.append( "{" );
+        jsObjBuffer.append( "{ " );
         for ( int i = 0 ; i < resourceNames.length ; i++ )
         {
             String resourceValue = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to