portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdore...@apache.org
Subject svn commit: r678278 - in /portals/pluto/trunk/pluto-container/src: main/java/org/apache/pluto/core/PortletContainerImpl.java main/java/org/apache/pluto/core/PortletContextManager.java test/java/org/apache/pluto/core/PortletContextManagerTest.java
Date Sun, 20 Jul 2008 14:39:46 GMT
Author: cdoremus
Date: Sun Jul 20 07:39:45 2008
New Revision: 678278

URL: http://svn.apache.org/viewvc?rev=678278&view=rev
Log:
Applied PLUTO-488 patch. Thank you Nikita!

Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
    portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/PortletContextManagerTest.java

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java?rev=678278&r1=678277&r2=678278&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
Sun Jul 20 07:39:45 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/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java?rev=678278&r1=678277&r2=678278&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/core/PortletContextManager.java
Sun Jul 20 07:39:45 2008
@@ -282,14 +282,32 @@
 //
 // Utility
 
-    public static ServletContext getPortletContext(ServletContext portalContext, String portletContextPath)
{
+    /**
+     * 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;
             }
         }
-        return portalContext.getContext(portletContextPath);
+        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;
     }
 
     /**

Modified: portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/PortletContextManagerTest.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/PortletContextManagerTest.java?rev=678278&r1=678277&r2=678278&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/PortletContextManagerTest.java
(original)
+++ portals/pluto/trunk/pluto-container/src/test/java/org/apache/pluto/core/PortletContextManagerTest.java
Sun Jul 20 07:39:45 2008
@@ -51,4 +51,13 @@
             assertEquals("/my-test-context", manager.computeContextPath(context));
         */
         }
+    
+    /* Java5 Required!
+    public void testGetPortletContext_InvalidPortletAppContextPath() throws Exception {
+      try {
+        PortletContextManager.getPortletContext(context, "/my-invalid-context");
+        fail();
+      } catch (PortletContainerException expected) {}
+    }
+    */
 }



Mime
View raw message