You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by cd...@apache.org on 2008/07/21 03:25:30 UTC

svn commit: r678336 - in /portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core: PortletContainerImpl.java PortletContextManager.java

Author: cdoremus
Date: Sun Jul 20 18:25:30 2008
New Revision: 678336

URL: http://svn.apache.org/viewvc?rev=678336&view=rev
Log:
Manually applied PLUTO-488 patch.

Modified:
    portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
    portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java

Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java?rev=678336&r1=678335&r2=678336&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java Sun Jul 20 18:25:30 2008
@@ -446,13 +446,6 @@
         
         // obtain the context of the portlet
         ServletContext portletCtx = PortletContextManager.getPortletContext(servletContext, context);
-        if (portletCtx == null) {
-            final String msg = "Unable to obtain the servlet context for " +
-                "portlet context [" + context + "].  Ensure the portlet has " +
-                "been deployed and that cross context support is enabled.";
-            errorWithName(msg);
-            throw new PortletContainerException(msg);
-        }
         
         // obtain the portlet application descriptor for the portlet
         // context.

Modified: portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java?rev=678336&r1=678335&r2=678336&view=diff
==============================================================================
--- portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java (original)
+++ portals/pluto/branches/2.0-spi-refactoring/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java Sun Jul 20 18:25:30 2008
@@ -33,6 +33,7 @@
 import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.internal.InternalPortletConfig;
 import org.apache.pluto.internal.InternalPortletContext;
+import org.apache.pluto.internal.impl.Configuration;
 import org.apache.pluto.internal.impl.PortletConfigImpl;
 import org.apache.pluto.internal.impl.PortletContextImpl;
 import org.apache.pluto.om.portlet.Portlet;
@@ -248,6 +249,37 @@
         LOG.info("Portlet Context '" + context.getApplicationId() + "' removed.");
     }
 
+//
+// Utility
+
+    /**
+     * Retrieve the servlet context of the portlet web app.
+     * @param portalContext The servlet context of the portal web app.
+     * @param portletContextPath The context path of the portlet web app.
+     * The given path must be begin with "/" (see {@link ServletContext#getContext(String)}).
+     * @return The servlet context of the portlet web app.
+     * @throws PortletContainerException if the servlet context cannot be
+     * retrieved for the given context path
+     */
+    public static ServletContext getPortletContext(ServletContext portalContext,
+        String portletContextPath) throws PortletContainerException {
+        if (Configuration.preventUnecessaryCrossContext()) {
+            String portalPath = getContextPath(portalContext);
+            if (portalPath.equals(portletContextPath)) {
+                return portalContext;
+            }
+        }
+        ServletContext portletAppCtx = portalContext.getContext(portletContextPath);
+        if (portletAppCtx == null) {
+            final String msg = "Unable to obtain the servlet context for the " +
+              "portlet app context path [" + portletContextPath + "]. Make " +
+              "sure that the portlet app has been deployed and that cross " +
+              "context support is enabled for the portal app.";
+            throw new PortletContainerException(msg);
+        }
+        return portletAppCtx;
+    }
+
     /**
      * Servlet 2.5 ServletContext.getContextPath() method.
      */