portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity JetspeedVelocityViewServlet.java
Date Thu, 02 Dec 2004 21:48:08 GMT
taylor      2004/12/02 13:48:08

  Modified:    portal/src/java/org/apache/jetspeed/velocity
                        JetspeedVelocityViewServlet.java
  Log:
  patch from Randy Watler
  fix broken max mode from previous patch
  
  Revision  Changes    Path
  1.10      +29 -23    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java
  
  Index: JetspeedVelocityViewServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JetspeedVelocityViewServlet.java	2 Dec 2004 05:17:15 -0000	1.9
  +++ JetspeedVelocityViewServlet.java	2 Dec 2004 21:48:08 -0000	1.10
  @@ -177,7 +177,6 @@
                                      .append(request.getServerName()).append(":")
                                      .append(request.getServerPort()).append(renderRequest.getContextPath());
           ctx.put("appRoot", appRoot.toString());
  -
           
           // setup TLS for Context propagation
           handlingRequestContext.set(ctx);
  @@ -262,26 +261,30 @@
           RequestContext requestContext = (RequestContext) ctx.get("JS2RequestContext");
           if ((renderRequest != null) && (requestContext != null))
           {
  -            // get fragment type and decoration, fallback to
  -            // fragment page default decorations
  -            Fragment fragment = (Fragment) renderRequest.getAttribute(JetspeedPowerTool.FRAGMENT_ATTR);
  -            String fragmentType = fragment.getType();
  -            String fragmentDecoration = fragment.getDecorator();
  -            if (fragmentDecoration == null)
  +            // get layout type and decoration, fallback to
  +            // page default decorations
  +            Fragment layout = (Fragment) renderRequest.getAttribute(JetspeedPowerTool.LAYOUT_ATTR);
  +            if (layout == null)
  +            {
  +                layout = (Fragment) renderRequest.getAttribute(JetspeedPowerTool.FRAGMENT_ATTR);
  +            }
  +            String layoutType = layout.getType();
  +            String layoutDecoration = layout.getDecorator();
  +            if (layoutDecoration == null)
               {
  -                Page fragmentPage = (Page) renderRequest.getAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY);
  -                fragmentDecoration = fragmentPage.getDefaultDecorator(fragmentType);
  +                Page page = (Page) renderRequest.getAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY);
  +                layoutDecoration = page.getDefaultDecorator(layoutType);
               }
               
  -            // get fragment capabilites and locale
  +            // get layout capabilites and locale
               CapabilityMap capabilityMap = requestContext.getCapabilityMap();
               Locale locale = requestContext.getLocale();
  -            String fragmentMediaType = capabilityMap.getPreferredMediaType().getName();
  -            String fragmentLanguage = locale.getLanguage();
  -            String fragmentCountry = locale.getCountry();
  +            String layoutMediaType = capabilityMap.getPreferredMediaType().getName();
  +            String layoutLanguage = locale.getLanguage();
  +            String layoutCountry = locale.getCountry();
               
               // lookup cache config based on decoration cache key
  -            String cacheKey = fragmentDecoration + ":" + fragmentType + ":" + fragmentMediaType
+ ":" + fragmentLanguage + ":" + fragmentCountry;
  +            String cacheKey = layoutDecoration + ":" + layoutType + ":" + layoutMediaType
+ ":" + layoutLanguage + ":" + layoutCountry;
               VelocityEngineConfig config = null;
               synchronized (velocityEngineConfigCache)
               {
  @@ -323,13 +326,13 @@
               {
                   log.error("getVelocityEngine(): unable create base descriptor", tle);
               }
  -            descriptor.setMediaType(fragmentMediaType);
  -            descriptor.setCountry(fragmentCountry);
  -            descriptor.setLanguage(fragmentLanguage);
  -            descriptor.setType(fragmentType);
  +            descriptor.setMediaType(layoutMediaType);
  +            descriptor.setCountry(layoutCountry);
  +            descriptor.setLanguage(layoutLanguage);
  +            descriptor.setType(layoutType);
               
               // get decoration configuration properties descriptor
  -            descriptor.setName(fragmentDecoration + "/" + JetspeedPowerTool.DECORATOR_TYPE
+ ".properties");
  +            descriptor.setName(layoutDecoration + "/" + JetspeedPowerTool.DECORATOR_TYPE
+ ".properties");
               TemplateDescriptor propertiesDescriptor = null;
               try
               {
  @@ -369,7 +372,7 @@
                   // get decoration template macros descriptor if defined
                   if ((ext != null) && (ext.length() > 0) && (macros !=
null) && (macros.length() > 0))
                   {
  -                    descriptor.setName(fragmentDecoration + "/" + JetspeedPowerTool.DECORATOR_TYPE
+ macros + ext);
  +                    descriptor.setName(layoutDecoration + "/" + JetspeedPowerTool.DECORATOR_TYPE
+ macros + ext);
                       try
                       {
                           macrosDescriptor = decorationLocator.locateTemplate(descriptor);
  @@ -400,7 +403,7 @@
               boolean forceVelocityEngineRefresh = false;
               if (config == null)
               {
  -                config = new VelocityEngineConfig(fragmentDecoration, fragmentType, fragmentMediaType,
fragmentLanguage, fragmentCountry);
  +                config = new VelocityEngineConfig(layoutDecoration, layoutType, layoutMediaType,
layoutLanguage, layoutCountry);
                   synchronized (velocityEngineConfigCache)
                   {
                       velocityEngineConfigCache.put(cacheKey, config);
  @@ -454,7 +457,10 @@
                       {
                           // create and cache new velocity engine
                           velocity = initVelocity(macrosDescriptor);
  -                        velocityEngineCache.put(config.macros.getPath(), velocity);
  +                        if (velocity != null)
  +                        {
  +                            velocityEngineCache.put(config.macros.getPath(), velocity);
  +                        }
                       }
                   }
               }
  
  
  

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


Mime
View raw message