portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r387412 - in /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed: container/state/impl/ container/url/impl/ desktop/ desktop/impl/ velocity/
Date Tue, 21 Mar 2006 04:51:30 GMT
Author: taylor
Date: Mon Mar 20 20:51:28 2006
New Revision: 387412

URL: http://svn.apache.org/viewcvs?rev=387412&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-514

Added:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/DesktopValveImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopContextImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java
Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLValveImpl.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java?rev=387412&r1=387411&r2=387412&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/state/impl/JetspeedNavigationalStateComponent.java
Mon Mar 20 20:51:28 2006
@@ -44,6 +44,7 @@
 {
     private final String navBeanName;
     private final String urlBeanName;    
+    private final String desktopUrlBeanName;
     
     // maps containing allowed PortletMode and WindowState objects on their lowercase name
     // ensuring only allowed, and always the same objects are returned and allowing comparision
by value
@@ -65,13 +66,14 @@
      *             if <code>navClassName</code> or <code>urlClassName</code>
      *             do not exist.
      */
-    public JetspeedNavigationalStateComponent( String  navBeanName, String urlBeanName, PortalContext
portalContext )
+    public JetspeedNavigationalStateComponent(String  navBeanName, String urlBeanName, PortalContext
portalContext, String desktopUrlBeanName)
             throws ClassNotFoundException
     {
         ArgUtil.assertNotNull(String.class, navBeanName, this);
         ArgUtil.assertNotNull(String.class, urlBeanName, this);        
         this.navBeanName = navBeanName;
-        this.urlBeanName = urlBeanName;        
+        this.urlBeanName = urlBeanName;
+        this.desktopUrlBeanName = desktopUrlBeanName;
 
         Enumeration portletModesEnum = portalContext.getSupportedPortletModes();
         PortletMode portletMode;
@@ -145,5 +147,11 @@
         this.beanFactory = beanFactory;        
     }
     
-
+    public PortalURL createDesktopURL(HttpServletRequest request, String characterEncoding)
+    {
+        PortalURL url = (PortalURL) beanFactory.getBean(desktopUrlBeanName, PortalURL.class);
+        url.setRequest(request);
+        url.setCharacterEncoding(characterEncoding);
+        return url;        
+    }
 }

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java?rev=387412&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java
(added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/DesktopEncodingPortalURL.java
Mon Mar 20 20:51:28 2006
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.container.url.impl;
+
+import java.util.StringTokenizer;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.jetspeed.PortalContext;
+import org.apache.jetspeed.container.state.NavigationalState;
+import org.apache.jetspeed.container.url.BasePortalURL;
+
+/**
+ * PathInfoEncodingPortalURL encodes the NavigationalState as PathInfo element
+ * *
+ * @author <a href="mailto:ate@apache.org">Ate Douma</a>
+ * @version $Id: PathInfoEncodingPortalURL.java 367856 2006-01-11 01:04:09Z taylor $
+ */
+public class DesktopEncodingPortalURL extends AbstractPortalURL
+{
+    private final String javascriptDoRender;
+    
+    public DesktopEncodingPortalURL(NavigationalState navState, PortalContext portalContext,
String javascriptDoRender, BasePortalURL base)
+    {
+        super(navState, portalContext, base);
+        this.javascriptDoRender = javascriptDoRender;        
+    }
+
+    public DesktopEncodingPortalURL(NavigationalState navState, PortalContext portalContext,
String javascriptDoRender)
+    {
+        super(navState, portalContext);
+        this.javascriptDoRender = javascriptDoRender;                
+    }
+
+    public DesktopEncodingPortalURL(String characterEncoding, NavigationalState navState,
PortalContext portalContext)
+    {
+        super(characterEncoding, navState, portalContext);
+        this.javascriptDoRender = null;
+    }
+
+    public DesktopEncodingPortalURL(HttpServletRequest request, String characterEncoding,
NavigationalState navState, PortalContext portalContext)
+    {
+        super(request, characterEncoding, navState, portalContext);
+        this.javascriptDoRender = null;        
+    }
+
+    protected void decodePathAndNavigationalState(HttpServletRequest request)
+    {
+        String path = null;
+        String encodedNavState = null;
+
+        String pathInfo = request.getPathInfo();
+        if (pathInfo != null)
+        {
+            StringTokenizer tokenizer = new StringTokenizer(request.getPathInfo(),"/");
+            StringBuffer buffer = new StringBuffer();
+            String token;
+            boolean foundNavState = false;
+            String navStatePrefix = getNavigationalStateParameterName() +":";
+            while (tokenizer.hasMoreTokens())
+            {
+                token = tokenizer.nextToken();
+                if (!foundNavState && token.startsWith(navStatePrefix))
+                {
+                    foundNavState = true;
+                    if ( token.length() > navStatePrefix.length() )
+                    {
+                        encodedNavState = token.substring(navStatePrefix.length());
+                    }
+                }
+                else
+                {
+                    buffer.append("/");
+                    buffer.append(token);
+                }
+            }
+            if ( buffer.length() > 0 )
+            {
+                path = buffer.toString();
+            }
+            else
+            {
+                path = "/";
+            }
+        }
+        setPath(path);
+        setEncodedNavigationalState(encodedNavState);
+    }
+
+    protected String createPortletURL(String encodedNavState, boolean secure)
+    {   
+        StringBuffer buffer = new StringBuffer("");
+        if (this.javascriptDoRender != null)
+        {
+            buffer.append(this.javascriptDoRender + "(\"");
+        }        
+        buffer.append(getBaseURL(secure));
+        buffer.append(getBasePath());
+        if ( encodedNavState != null )
+        {
+            buffer.append("/");
+            buffer.append(getNavigationalStateParameterName());
+            buffer.append(":");
+            buffer.append(encodedNavState);
+        }
+        if ( getPath() != null )
+        {
+            buffer.append(getPath());
+        }
+        if (this.javascriptDoRender != null)
+        {
+            buffer.append("\")");
+        }
+        return buffer.toString();
+    }        
+}

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLValveImpl.java?rev=387412&r1=387411&r2=387412&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLValveImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/PortalURLValveImpl.java
Mon Mar 20 20:51:28 2006
@@ -18,7 +18,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.container.state.NavigationalStateComponent;
 import org.apache.jetspeed.pipeline.PipelineException;
 import org.apache.jetspeed.pipeline.valve.AbstractValve;
@@ -34,6 +33,12 @@
 public class PortalURLValveImpl extends AbstractValve
 {
     private static final Log log = LogFactory.getLog(PortalURLValveImpl.class);
+    private NavigationalStateComponent navComponent;
+
+    public PortalURLValveImpl(NavigationalStateComponent navComponent)
+    {
+        this.navComponent = navComponent;
+    }
     
     public void invoke(RequestContext request, ValveContext context)
         throws PipelineException
@@ -42,9 +47,16 @@
         {  
             if ( request.getPortalURL() == null )
             {
-                NavigationalStateComponent navComponent = (NavigationalStateComponent)Jetspeed.getComponentManager()
-                    .getComponent(NavigationalStateComponent.class);
-                request.setPortalURL(navComponent.createURL(request.getRequest(), request.getCharacterEncoding()));
+                String encoding = request.getRequestParameter("encoder");
+                if (encoding != null && encoding.equals("desktop"))
+                {
+                    request.setPortalURL(navComponent.createDesktopURL(request.getRequest(),
request.getCharacterEncoding()));
+                }
+                else
+                {
+                    request.setPortalURL(navComponent.createURL(request.getRequest(), request.getCharacterEncoding()));
+                }
+                
             }
         }
         catch (Exception e)

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/DesktopValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/DesktopValveImpl.java?rev=387412&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/DesktopValveImpl.java
(added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/DesktopValveImpl.java
Mon Mar 20 20:51:28 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.desktop.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.desktop.JetspeedDesktop;
+import org.apache.jetspeed.pipeline.PipelineException;
+import org.apache.jetspeed.pipeline.valve.AbstractValve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Desktop Valve
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class DesktopValveImpl extends AbstractValve
+{
+    private static final Log log = LogFactory.getLog(DesktopValveImpl.class);
+    private JetspeedDesktop desktop;
+    
+    public DesktopValveImpl(JetspeedDesktop desktop)
+    {
+        this.desktop = desktop;
+    }
+        
+    public void invoke( RequestContext request, ValveContext context )
+        throws PipelineException
+    {
+        try
+        {
+            System.out.println("dispatching desktop now " + request.getRequest().getPathInfo());
+            desktop.render(request);
+        }
+        catch (Exception e)
+        {
+            throw new PipelineException(e);
+        }
+        context.invokeNext( request );
+    }
+
+    public String toString()
+    {
+        return "DesktopValve";
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopContextImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopContextImpl.java?rev=387412&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopContextImpl.java
(added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopContextImpl.java
Mon Mar 20 20:51:28 2006
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.desktop.impl;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.jetspeed.container.url.BasePortalURL;
+import org.apache.jetspeed.desktop.JetspeedDesktopContext;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * Jetspeed Desktop 
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class JetspeedDesktopContextImpl implements JetspeedDesktopContext
+{
+    /** Jetspeed Request Context */
+    RequestContext context;
+    
+    /** base portal URL to override default URL server info from servlet */
+    private BasePortalURL baseUrlAccess = null;
+        
+    public JetspeedDesktopContextImpl(RequestContext context, BasePortalURL baseUrlAccess)
+    {
+        this.context = context;
+        this.baseUrlAccess = baseUrlAccess;
+    }
+    
+    public String getPortalResourceUrl(String relativePath)
+    {        
+        HttpServletRequest request = context.getRequest();
+        HttpServletResponse response = context.getResponse();
+        
+        // only rewrite a non-absolute url
+        if (relativePath != null && relativePath.indexOf("://") == -1 &&
relativePath.indexOf("mailto:") == -1)            
+        {
+            StringBuffer path = new StringBuffer();
+            if (this.baseUrlAccess == null)
+            {
+                return response.encodeURL(path.append(request.getScheme()).append("://").append(
+                request.getServerName()).append(":").append(request.getServerPort()).append(
+                request.getContextPath()).append(relativePath).toString());             
  
+            }
+            else
+            {
+                return response.encodeURL(path.append(baseUrlAccess.getServerScheme()).append("://").append(
+                        baseUrlAccess.getServerName()).append(":").append(baseUrlAccess.getServerPort()).append(
+                        request.getContextPath()).append(relativePath).toString());     
                          
+            }
+        }
+        else
+        {
+            return relativePath;
+        }
+    }
+    
+    public String getPortalUrl(String relativePath)
+    {        
+        HttpServletRequest request = context.getRequest();
+        HttpServletResponse response = context.getResponse();
+
+        // only rewrite a non-absolute url
+        if (relativePath != null && relativePath.indexOf("://") == -1 &&
relativePath.indexOf("mailto:") == -1)            
+        {
+            StringBuffer path = new StringBuffer();
+            if (this.baseUrlAccess == null)
+            {
+                return response.encodeURL(path.append(request.getScheme()).append("://").append(
+                request.getServerName()).append(":").append(request.getServerPort()).append(
+                request.getContextPath()).append(request.getServletPath()).append(relativePath).toString());
               
+            }
+            else
+            {
+                return response.encodeURL(path.append(baseUrlAccess.getServerScheme()).append("://").append(
+                        baseUrlAccess.getServerName()).append(":").append(baseUrlAccess.getServerPort()).append(
+                        request.getContextPath()).append(request.getServletPath()).append(relativePath).toString());
                               
+            }
+        }
+        else
+        {
+            return relativePath;
+        }
+    }
+    
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java?rev=387412&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java
(added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/desktop/impl/JetspeedDesktopImpl.java
Mon Mar 20 20:51:28 2006
@@ -0,0 +1,205 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.desktop.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.container.url.BasePortalURL;
+import org.apache.jetspeed.desktop.JetspeedDesktop;
+import org.apache.jetspeed.desktop.JetspeedDesktopContext;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.request.RequestContext;
+import org.springframework.web.context.ServletContextAware;
+
+/**
+ * Desktop Valve
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: $
+ */
+public class JetspeedDesktopImpl implements JetspeedDesktop, ServletContextAware
+{
+    private static final Log log = LogFactory.getLog( JetspeedDesktopImpl.class );
+
+    /** the webapp relative root of all themes */
+    private String themesRoot;
+    
+    /** default theme when no theme supplied in desktop page */
+    private String defaultTheme;
+    
+    /** default extension for theme templates */
+    private String defaultExtension;
+    
+    /** property settings for each theme available */
+    private Map themesProperties = new HashMap();
+
+    /** spring-fed servlet context property */
+    private ServletContext servletContext;
+    
+    /** base portal URL to override default URL server info from servlet */
+    private BasePortalURL baseUrlAccess = null;
+    
+    public JetspeedDesktopImpl(String themesRoot, String defaultTheme, String defaultExtension)
+    {
+        this.themesRoot = themesRoot;
+        this.defaultTheme = defaultTheme;
+        this.defaultExtension = defaultExtension;
+    }
+
+    public JetspeedDesktopImpl(String themesRoot, String defaultTheme, String defaultExtension,
BasePortalURL baseUrlAccess)
+    {
+        this(themesRoot, defaultTheme, defaultExtension);
+        this.baseUrlAccess = baseUrlAccess;
+    }
+    
+    public void render(RequestContext request)    
+    {
+        Page page = request.getPage();
+        String theme = page.getSkin();
+        if (theme == null)
+        {
+            theme = defaultTheme;
+        }        
+        String path = getThemePath(theme);               
+        try
+        {
+            RequestDispatcher dispatcher = request.getRequest().getRequestDispatcher(path);
               
+            JetspeedDesktopContext desktopContext = new JetspeedDesktopContextImpl(request,
this.baseUrlAccess);
+            request.getRequest().setAttribute(JetspeedDesktopContext.DESKTOP_ATTRIBUTE, desktopContext);
+            dispatcher.include(request.getRequest(), request.getResponse());
+        }
+        catch (Exception e)
+        {
+            try
+            {
+                log.error("Failed to include Desktop theme " + path, e);
+                request.getResponse().getWriter().println("Desktop theme " + theme + " is
not available");
+            }
+            catch (IOException ioe)
+            {
+                log.error("Failed to write exception information to servlet output writer",
ioe);
+            }
+        
+        }
+    }
+    
+    public String getDefaultTheme()
+    {
+        return defaultTheme;
+    }
+
+    
+    public void setDefaultTheme(String defaultTheme)
+    {
+        this.defaultTheme = defaultTheme;
+    }
+
+    protected String getThemeConfigurationPath(String theme)
+    {
+        return this.themesRoot + "/" +  theme + "/" + JetspeedDesktop.CONFIG_FILE_NAME;
+    }
+    
+    protected String getThemePath(String theme)
+    {
+        Properties themeConfiguration = (Properties)themesProperties.get(theme);
+        if (themeConfiguration == null)
+        {
+            themeConfiguration = getConfiguration(theme);
+        }
+        String id = themeConfiguration.getProperty("id");
+        if (id == null)
+            id = theme;
+        String ext = themeConfiguration.getProperty("template.extension");
+        if (ext == null)
+            ext = this.defaultExtension;
+        if (this.themesRoot.endsWith("/"))
+            return this.themesRoot + theme + "/" + id + ext;
+        else
+            return this.themesRoot + "/" + theme + "/" + id + ext;
+    }
+    
+    protected Properties getConfiguration(String theme)
+    {
+        Properties props = (Properties)this.themesProperties.get(theme);
+        if (props != null)
+        {
+            return props;
+        }
+        
+        props = new Properties();
+        InputStream is = null;
+        try
+        {
+            is = this.servletContext.getResourceAsStream(getThemeConfigurationPath(theme));
+            if (is != null)
+            {                
+                props.load(is);
+            }
+            else
+            {
+                log.warn("Could not locate the theme.properties configuration file for theme
\""
+                        + theme +
+                     "\".  This theme may not exist.");
+                props.setProperty("id", theme);
+                props.setProperty("extension", this.defaultExtension);
+            }                
+        }
+        catch (Exception e)
+        {
+            log.warn("Failed to load theme configuration.", e);
+            props.setProperty("id", theme);
+        }
+        finally
+        {
+            if (is != null)
+            {
+                try
+                {
+                    is.close();
+                }
+                catch (IOException e)
+                {
+                    log.warn("Failed to close them configuration.", e);
+                }
+            }
+        }
+        this.themesProperties.put(theme, props);
+        return props;
+    }
+
+    
+    public ServletContext getServletContext()
+    {
+        return servletContext;
+    }
+
+    
+    public void setServletContext(ServletContext servletContext)
+    {
+        this.servletContext = servletContext;
+    }
+    
+}
+    
\ No newline at end of file

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java?rev=387412&r1=387411&r2=387412&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedVelocityViewServlet.java
Mon Mar 20 20:51:28 2006
@@ -42,6 +42,7 @@
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.capabilities.CapabilityMap;
 import org.apache.jetspeed.components.ComponentManager;
+import org.apache.jetspeed.desktop.JetspeedDesktopContext;
 import org.apache.jetspeed.locator.LocatorDescriptor;
 import org.apache.jetspeed.locator.TemplateDescriptor;
 import org.apache.jetspeed.locator.TemplateLocator;
@@ -175,6 +176,24 @@
      */
     protected Template handleRequest(HttpServletRequest request, HttpServletResponse response,
Context ctx) throws Exception
     {
+        RequestContext requestContext = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        if(requestContext == null)
+        {
+            throw new IllegalStateException("JetspeedVelocityViewServlet unable to handle
request because there is no RequestContext in "+
+                   "the HttpServletRequest.");
+        }
+        
+        JetspeedDesktopContext desktopContext = (JetspeedDesktopContext)request.getAttribute(JetspeedDesktopContext.DESKTOP_ATTRIBUTE);
       
+        if (desktopContext != null)
+        {
+            // standard render request and response also available in context
+            ctx.put(JetspeedDesktopContext.DESKTOP_ATTRIBUTE, desktopContext);
+            ctx.put("JS2RequestContext", requestContext);
+            
+            // setup TLS for Context propagation
+            handlingRequestContext.set(ctx);            
+            return super.handleRequest(request, response, ctx);            
+        }
         // configure velocity context
         PortletRequest renderRequest = (PortletRequest) request.getAttribute(Constants.PORTLET_REQUEST);
         RenderResponse renderResponse = (RenderResponse) request.getAttribute(Constants.PORTLET_RESPONSE);
@@ -183,14 +202,7 @@
         {
             renderRequest.setAttribute(VELOCITY_CONTEXT_ATTR, ctx);
         }
-        
-        RequestContext requestContext = (RequestContext)request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
-        if(requestContext == null)
-        {
-            throw new IllegalStateException("JetspeedVelocityViewServlet unable to handle
request because there is no RequestContext in "+
-                   "the HttpServletRequest.");
-        }
-        
+                
         JetspeedPowerTool jpt = (JetspeedPowerTool) renderRequest.getAttribute(PortalReservedParameters.JETSPEED_POWER_TOOL_REQ_ATTRIBUTE);
         if(jpt == null)
         {
@@ -359,9 +371,18 @@
      */
     private VelocityEngine getVelocityEngine(Context ctx)
     {
+        RequestContext requestContext = (RequestContext) ctx.get("JS2RequestContext");  
     
+        JetspeedDesktopContext desktopContext = (JetspeedDesktopContext)requestContext.getRequest().getAttribute(JetspeedDesktopContext.DESKTOP_ATTRIBUTE);
       
+        if (desktopContext != null)
+        {
+            if (defaultVelocityEngine == null)
+            {
+                defaultVelocityEngine = initVelocity((TemplateDescriptor)null);
+            }
+            return defaultVelocityEngine;            
+        }                
         // get render request and request context from Context
         RenderRequest renderRequest = (RenderRequest) ctx.get("renderRequest");
-        RequestContext requestContext = (RequestContext) ctx.get("JS2RequestContext");
         JetspeedPowerTool jpt = (JetspeedPowerTool) ctx.get("jetspeed");
         if ((renderRequest != null) && (requestContext != null))
         {



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


Mime
View raw message