Package org.apache.jetspeed.headerresource

Examples of org.apache.jetspeed.headerresource.HeaderResource


            request.setAttribute( JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE, Boolean.TRUE );
           
            // get decorations
            Theme theme = decorationFactory.getTheme( page, request );
           
            HeaderResource hr = getHeaderResourceFactory().getHeaderResouce( request );
            JetspeedDesktopContext desktopContext = new JetspeedDesktopContextImpl( request, this.baseUrlAccess, theme, hr, defaultLayoutTemplateExtension );
           
            String layoutTemplateIdPropertyName = null;
            if ( "true".equals( request.getRequest().getParameter( "jsprintmode" ) ) )
                layoutTemplateIdPropertyName = JetspeedDesktopContext.LAYOUT_PRINT_TEMPLATE_ID_PROP;
           
            layoutDecorationTemplatePath = desktopContext.getLayoutTemplatePath( layoutTemplateIdPropertyName );
            layoutDecorationTemplatePathWasAssigned = true;
           
            RequestDispatcher dispatcher = request.getRequest().getRequestDispatcher( layoutDecorationTemplatePath );
           
            hr.dojoEnable();
           
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_CONTEXT_ATTRIBUTE, desktopContext );
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_REQUEST_CONTEXT_ATTRIBUTE, request );
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_COMPONENT_MANAGER_ATTRIBUTE, Jetspeed.getComponentManager() );
           
            String portletDecorationsBasePath = decorationFactory.getPortletDecorationsBasePath();
            String portletDecorationsBaseRelative = portletDecorationsBasePath;
            if ( portletDecorationsBaseRelative != null && portletDecorationsBaseRelative.length() > 1 && portletDecorationsBaseRelative.indexOf( '/' ) == 0 )
            {
                portletDecorationsBaseRelative = portletDecorationsBaseRelative.substring( 1 );
            }
            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( desktopContext.getLayoutDecorationName() ).append( "\";" ).append( EOL );
            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PORTLET_DECORATIONS_PATH_VAR_NAME ).append( " = \"" ).append( portletDecorationsBasePath ).append( "\";" ).append( EOL );
            String portletDecorationNamesContent = HeaderResourceLib.makeJSONStringArray( decorationFactory.getDesktopPortletDecorations( request ) );
            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PORTLET_DECORATIONS_ALLOWED_VAR_NAME ).append( " = " ).append( portletDecorationNamesContent ).append( ";" );
            hr.addHeaderSectionFragment( DOJO_CONFIG_LAYOUT_VAR_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, dojoConfigAddOn.toString() );
           
            if ( hr.isHeaderSectionIncluded( HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT ) )
            {
                hr.setHeaderSectionType( HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, HeaderResource.HEADER_TYPE_LINK_TAG );
                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++;
                        }
                    }
                }
                hr.addHeaderSectionFragment( "desktop.style.layout", HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, desktopThemeStyleLink.toString() );
            }
           
            // desktop action labels
            StringBuffer desktopActionLabels = new StringBuffer();
            ResourceBundle messages = desktopContext.getLayoutResourceBundle( request.getLocale() );
            for ( int i = 0 ; i < DESKTOP_ACTIONS.length ; i++ )
            {
                String actionLabel = messages.getString( DESKTOP_ACTION_RESOURCE_NAME_PREFIX + DESKTOP_ACTIONS[ i ] );
                if ( actionLabel != null )
                {
                    if ( desktopActionLabels.length() == 0 )
                    {
                        desktopActionLabels.append( "{ " );
                    }
                    else
                    {
                        desktopActionLabels.append( ", " );
                    }
                    desktopActionLabels.append( DESKTOP_ACTIONS[ i ] ).append( ": \"" ).append( actionLabel ).append( "\"" );
                }
            }
            if ( desktopActionLabels.length() > 0 )
            {
                dojoConfigAddOn = new StringBuffer();
                dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_ACTION_LABELS_NAME ).append( " = " ).append( desktopActionLabels.toString() ).append( " };" ).append( EOL );
                hr.addHeaderSectionFragment( DOJO_CONFIG_ACTION_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, dojoConfigAddOn.toString() );
            }
           
            dispatcher.include( request.getRequest(), request.getResponse() );
        }
        catch ( Exception e )
View Full Code Here


                    Portlet portlet = getPortletFactory().getPortletInstance( context.getConfig().getServletContext().getContext( portletApplicationContextPath ), pd ).getRealPortlet();           
                    if ( portlet != null && portlet instanceof SupportsHeaderPhase )
                    {
                        log.debug( "renderHeaderFragment: " + pd.getName() + " supports header phase" );
                       
                        HeaderResource hr = getHeaderResourceFactory().getHeaderResource( context, this.baseUrlAccess, isDesktop(), getHeaderConfiguration() );
                        PortletHeaderRequest headerRequest = new PortletHeaderRequestImpl( context, portletWindow, portletApplicationContextPath );
                        PortletHeaderResponse headerResponse = new PortletHeaderResponseImpl( context, hr, isDesktop(), getHeaderConfiguration(), getHeaderResourceRegistry() );
                        ((SupportsHeaderPhase)portlet).doHeader( headerRequest, headerResponse );
                        return true;
                    }
View Full Code Here

     */   
    public void doHeader(PortletHeaderRequest request, PortletHeaderResponse response)   
    throws PortletException
    {
        // use header resource component to ensure header logic is included only once
        HeaderResource headerResource = response.getHeaderResource();
       
        headerResource.dojoEnable();
        includeHeaderContent( headerResource );
       
        if ( this.headerPage != null )
        {
            include( request, response, this.headerPage );
View Full Code Here

     */   
    public void doHeader( PortletHeaderRequest request, PortletHeaderResponse response )
    throws PortletException
    {
        // use header resource component to ensure header logic is included only once
        HeaderResource headerResource = response.getHeaderResource();

        headerResource.dojoEnable();
        includeHeaderContent( headerResource );
       
        if ( this.headerPage != null )
        {
            include( request, response, this.headerPage );
View Full Code Here

                    Portlet portlet = getPortletFactory().getPortletInstance( context.getConfig().getServletContext().getContext( portletApplicationContextPath ), pd ).getRealPortlet();           
                    if ( portlet != null && portlet instanceof SupportsHeaderPhase )
                    {
                        log.debug( "renderHeaderFragment: " + pd.getName() + " supports header phase" );
                       
                        HeaderResource hr = getHeaderResourceFactory().getHeaderResource( context, this.baseUrlAccess, isDesktop(), getHeaderConfiguration() );
                        PortletHeaderRequest headerRequest = new PortletHeaderRequestImpl( context, portletWindow, portletApplicationContextPath );
                        PortletHeaderResponse headerResponse = new PortletHeaderResponseImpl( context, hr, isDesktop(), getHeaderConfiguration(), getHeaderResourceRegistry() );
                        ((SupportsHeaderPhase)portlet).doHeader( headerRequest, headerResponse );
                        return true;
                    }
View Full Code Here

            request.setAttribute( JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE, Boolean.TRUE );
           
            // get decorations
            Theme theme = decorationFactory.getTheme( page, request );
           
            HeaderResource hr = getHeaderResourceFactory().getHeaderResouce( request );
            JetspeedDesktopContext desktopContext = new JetspeedDesktopContextImpl( request, this.baseUrlAccess, theme, hr, defaultLayoutTemplateExtension );
           
            String layoutTemplateIdPropertyName = null;
            if ( "true".equals( request.getRequest().getParameter( "jsprintmode" ) ) )
                layoutTemplateIdPropertyName = JetspeedDesktopContext.LAYOUT_PRINT_TEMPLATE_ID_PROP;
           
            layoutDecorationTemplatePath = desktopContext.getLayoutTemplatePath( layoutTemplateIdPropertyName );
            layoutDecorationTemplatePathWasAssigned = true;
           
            RequestDispatcher dispatcher = request.getRequest().getRequestDispatcher( layoutDecorationTemplatePath );
           
            hr.dojoEnable();
           
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_CONTEXT_ATTRIBUTE, desktopContext );
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_REQUEST_CONTEXT_ATTRIBUTE, request );
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_COMPONENT_MANAGER_ATTRIBUTE, Jetspeed.getComponentManager() );
           
            String portletDecorationsBasePath = decorationFactory.getPortletDecorationsBasePath();
            String portletDecorationsBaseRelative = portletDecorationsBasePath;
            if ( portletDecorationsBaseRelative != null && portletDecorationsBaseRelative.length() > 1 && portletDecorationsBaseRelative.indexOf( '/' ) == 0 )
            {
                portletDecorationsBaseRelative = portletDecorationsBaseRelative.substring( 1 );
            }
            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( desktopContext.getLayoutDecorationName() ).append( "\";" ).append( EOL );
            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PORTLET_DECORATIONS_PATH_VAR_NAME ).append( " = \"" ).append( portletDecorationsBasePath ).append( "\";" ).append( EOL );
            String portletDecorationNamesContent = HeaderResourceLib.makeJSONStringArray( theme.getPortletDecorationNames() );
            dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_PORTLET_DECORATIONS_ALLOWED_VAR_NAME ).append( " = " ).append( portletDecorationNamesContent ).append( ";" );
            hr.addHeaderSectionFragment( DOJO_CONFIG_LAYOUT_VAR_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, dojoConfigAddOn.toString() );
           
            if ( hr.isHeaderSectionIncluded( HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT ) )
            {
                hr.setHeaderSectionType( HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, HeaderResource.HEADER_TYPE_LINK_TAG );
                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++;
                        }
                    }
                }
                hr.addHeaderSectionFragment( "desktop.style.layout", HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT, desktopThemeStyleLink.toString() );
            }
           
            // desktop action labels
            StringBuffer desktopActionLabels = new StringBuffer();
            ResourceBundle messages = desktopContext.getLayoutResourceBundle( request.getLocale() );
            for ( int i = 0 ; i < DESKTOP_ACTIONS.length ; i++ )
            {
                String actionLabel = messages.getString( DESKTOP_ACTION_RESOURCE_NAME_PREFIX + DESKTOP_ACTIONS[ i ] );
                if ( actionLabel != null )
                {
                    if ( desktopActionLabels.length() == 0 )
                    {
                        desktopActionLabels.append( "{ " );
                    }
                    else
                    {
                        desktopActionLabels.append( ", " );
                    }
                    desktopActionLabels.append( DESKTOP_ACTIONS[ i ] ).append( ": \"" ).append( actionLabel ).append( "\"" );
                }
            }
            if ( desktopActionLabels.length() > 0 )
            {
                dojoConfigAddOn = new StringBuffer();
                dojoConfigAddOn.append( "    " ).append( DOJO_CONFIG_ACTION_LABELS_NAME ).append( " = " ).append( desktopActionLabels.toString() ).append( " };" ).append( EOL );
                hr.addHeaderSectionFragment( DOJO_CONFIG_ACTION_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, dojoConfigAddOn.toString() );
            }
           
            dispatcher.include( request.getRequest(), request.getResponse() );
        }
        catch ( Exception e )
View Full Code Here

     */   
    public void doHeader( PortletHeaderRequest request, PortletHeaderResponse response )
    throws PortletException
    {
        // use header resource component to ensure header logic is included only once
        HeaderResource headerResource = response.getHeaderResource();

        headerResource.dojoEnable();
        includeHeaderContent( headerResource );
       
        if ( this.headerPage != null )
        {
            include( request, response, this.headerPage );
View Full Code Here

     */   
    public void doHeader(PortletHeaderRequest request, PortletHeaderResponse response)   
    throws PortletException
    {
        // use header resource component to ensure header logic is included only once
        HeaderResource headerResource = response.getHeaderResource();
       
        headerResource.dojoEnable();
        includeHeaderContent( headerResource );
       
        if ( this.headerPage != null )
        {
            include( request, response, this.headerPage );
View Full Code Here

            request.setAttribute( JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE, Boolean.TRUE );
           
            // get decorations
            Theme theme = decorationFactory.getTheme( page, request );
           
            HeaderResource hr = getHeaderResourceFactory().getHeaderResouce( request );
            JetspeedDesktopContext desktopContext = new JetspeedDesktopContextImpl( request, this.baseUrlAccess, theme, hr, defaultLayoutTemplateExtension );
           
            String layoutTemplateIdPropertyName = null;
            if ( "true".equals( request.getRequest().getParameter( "jsprintmode" ) ) )
                layoutTemplateIdPropertyName = JetspeedDesktopContext.LAYOUT_PRINT_TEMPLATE_ID_PROP;
           
            layoutDecorationTemplatePath = desktopContext.getLayoutTemplatePath( layoutTemplateIdPropertyName );
            layoutDecorationTemplatePathWasAssigned = true;
           
            RequestDispatcher dispatcher = request.getRequest().getRequestDispatcher( layoutDecorationTemplatePath );
           
            hr.dojoEnable();
           
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_CONTEXT_ATTRIBUTE, desktopContext );
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_REQUEST_CONTEXT_ATTRIBUTE, request );
            request.getRequest().setAttribute( JetspeedDesktopContext.DESKTOP_COMPONENT_MANAGER_ATTRIBUTE, Jetspeed.getComponentManager() );
           
            String layoutDecorationName = desktopContext.getLayoutDecorationName();
            boolean inclStyleLayout = hr.isHeaderSectionIncluded( HeaderResource.HEADER_SECTION_DESKTOP_STYLE_LAYOUT );
            String dojoConfigContentCacheKey = DOJO_CONFIG_LAYOUT_VAR_NAME + "." + layoutDecorationName;
            String dojoConfigContent = getCachedContent( dojoConfigContentCacheKey );
           
            if ( dojoConfigContent == null )
            {
              String portletDecorationsBasePath = decorationFactory.getPortletDecorationsBasePath();
              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 )
              {
                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_IMG_NAME_PREFIX + DESKTOP_LOADING_PROPERTY_NAMES[ i ] );
                      if ( propValue != null )
                      {
                          if ( atLeastOneFound )
                          {
                              loadingPropsBuffer.append( ", " );
                          }
                          else
                          {
                            atLeastOneFound = true;
                          }
                          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
              {
                log.error( "Failed to find desktop layout decoration " + layoutDecorationName + " - layout decoration properties cannot be added to content." );
              }
             
              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 );               
            }           
           
            if ( dojoConfigContent != null )
            {
              hr.addHeaderSectionFragment( DOJO_CONFIG_LAYOUT_VAR_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, dojoConfigContent );
            }
           
            if ( inclStyleLayout )
            {
              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();
            String desktopActionLabelsCacheKey = DOJO_CONFIG_ACTION_LABELS_NAME + layoutDecorationLocaleSuffix;
            String pageEditorLabelsCacheKey = DOJO_CONFIG_PAGEEDITOR_LABELS_NAME + layoutDecorationLocaleSuffix;
            String pageEditorDialogLabelsCacheKey = DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME + layoutDecorationLocaleSuffix;
           
            String desktopActionLabelsContent = getCachedContent( desktopActionLabelsCacheKey );
            String pageEditorLabelsContent = getCachedContent( pageEditorLabelsCacheKey );
            String pageEditorDialogLabelsContent = getCachedContent( pageEditorDialogLabelsCacheKey );
            if ( desktopActionLabelsContent == null || pageEditorLabelsContent == null || pageEditorDialogLabelsContent == null )
            {
              ResourceBundle messages = desktopContext.getLayoutResourceBundle( request.getLocale() );             
              if ( desktopActionLabelsContent == null )
              {
                desktopActionLabelsContent = getResourcesAsJavascriptObject( DESKTOP_ACTION_RESOURCE_NAME_PREFIX, DESKTOP_ACTION_RESOURCE_NAMES, messages, DOJO_CONFIG_ACTION_LABELS_NAME, "    ", true );
                setCachedContent( desktopActionLabelsCacheKey, desktopActionLabelsContent );
              }
              if ( pageEditorLabelsContent == null )
              {
                pageEditorLabelsContent = getResourcesAsJavascriptObject( DESKTOP_PAGEEDITOR_RESOURCE_NAME_PREFIX, DESKTOP_PAGEEDITOR_RESOURCE_NAMES, messages, DOJO_CONFIG_PAGEEDITOR_LABELS_NAME, "    ", true );
                setCachedContent( pageEditorLabelsCacheKey, pageEditorLabelsContent );
              }
              if ( pageEditorDialogLabelsContent == null )
              {
                pageEditorDialogLabelsContent = getResourcesAsJavascriptObject( DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAME_PREFIX, DESKTOP_PAGEEDITOR_DIALOG_RESOURCE_NAMES, messages, DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME, "    ", true );
                setCachedContent( pageEditorDialogLabelsCacheKey, pageEditorDialogLabelsContent );
              }
            }
            if ( desktopActionLabelsContent != null && desktopActionLabelsContent.length() > 0 )
            {
                hr.addHeaderSectionFragment( DOJO_CONFIG_ACTION_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, desktopActionLabelsContent );
            }
            if ( pageEditorLabelsContent != null && pageEditorLabelsContent.length() > 0 )
            {
                hr.addHeaderSectionFragment( DOJO_CONFIG_PAGEEDITOR_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, pageEditorLabelsContent );
            }
            if ( pageEditorDialogLabelsContent != null && pageEditorDialogLabelsContent.length() > 0 )
            {
                hr.addHeaderSectionFragment( DOJO_CONFIG_PAGEEDITOR_DIALOG_LABELS_NAME, HeaderResource.HEADER_SECTION_DOJO_CONFIG, pageEditorDialogLabelsContent );
            }
           
            dispatcher.include( request.getRequest(), request.getResponse() );
        }
        catch ( Exception e )
View Full Code Here

                    Portlet portlet = getPortletFactory().getPortletInstance( context.getConfig().getServletContext().getContext( portletApplicationContextPath ), pd ).getRealPortlet();           
                    if ( portlet != null && portlet instanceof SupportsHeaderPhase )
                    {
                        log.debug( "renderHeaderFragment: " + pd.getName() + " supports header phase" );
                       
                        HeaderResource hr = getHeaderResourceFactory().getHeaderResource( context, this.baseUrlAccess, isDesktop(), getHeaderConfiguration() );
                        PortletHeaderRequest headerRequest = new PortletHeaderRequestImpl( context, portletWindow, portletApplicationContextPath );
                        PortletHeaderResponse headerResponse = new PortletHeaderResponseImpl( context, hr, isDesktop(), getHeaderConfiguration(), getHeaderResourceRegistry() );
                        ((SupportsHeaderPhase)portlet).doHeader( headerRequest, headerResponse );
                        return true;
                    }
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.headerresource.HeaderResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.