portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r768291 - in /portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl: PortletRequestImpl.java PortletResponseImpl.java PortletURLImpl.java
Date Fri, 24 Apr 2009 12:53:28 GMT
Author: ate
Date: Fri Apr 24 12:53:27 2009
New Revision: 768291

URL: http://svn.apache.org/viewvc?rev=768291&view=rev
Log:
Fix for PLUTO-513: Support portlet managed custom modes as defined in PLT.8.4 of JSR-286 spec
See: http://issues.apache.org/jira/browse/PLUTO-513
- (re) implemented this in the portletcontainer

Modified:
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
    portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java?rev=768291&r1=768290&r2=768291&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletRequestImpl.java
Fri Apr 24 12:53:27 2009
@@ -50,6 +50,7 @@
 import org.apache.pluto.container.PortletRequestContext;
 import org.apache.pluto.container.PortletResponseContext;
 import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.om.portlet.CustomPortletMode;
 import org.apache.pluto.container.om.portlet.PortletDefinition;
 import org.apache.pluto.container.om.portlet.SecurityRoleRef;
 import org.apache.pluto.container.om.portlet.Supports;
@@ -132,42 +133,6 @@
         }
     }
 
-    private boolean isPortletModeAllowedByPortlet(PortletMode mode) 
-    {
-        if(PortletMode.VIEW.equals(mode))
-        {
-            return true;
-        }
-
-        PortletDefinition dd = getPortletWindow().getPortletEntity().getPortletDefinition();
-
-        for (Supports sup : dd.getSupports())
-        {
-            for (String m : sup.getPortletModes())
-            {
-                if (m.equalsIgnoreCase(mode.toString())) 
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    private boolean isPortletModeAllowedByPortal(PortletMode mode) 
-    {
-        Enumeration<PortletMode> supportedModes = portalContext.getSupportedPortletModes();
-        while (supportedModes.hasMoreElements()) 
-        {
-            if (supportedModes.nextElement().toString().equalsIgnoreCase(
-                    (mode.toString()))) 
-            {
-                return true;
-            }
-        }
-        return false;
-    }    
-    
     protected static Map<String, String[]> cloneParameterMap(Map<String, String[]>
map)
     {
         if (!map.isEmpty())
@@ -638,8 +603,40 @@
     
     public boolean isPortletModeAllowed(PortletMode mode) 
     {
-        return (isPortletModeAllowedByPortlet(mode)
-                && isPortletModeAllowedByPortal(mode));
+        if(PortletMode.VIEW.equals(mode))
+        {
+            return true;
+        }
+        
+        String modeName = mode.toString();
+
+        PortletDefinition dd = getPortletWindow().getPortletEntity().getPortletDefinition();
+
+        for (Supports sup : dd.getSupports())
+        {
+            for (String m : sup.getPortletModes())
+            {
+                if (m.equalsIgnoreCase(modeName)) 
+                {
+                    // check if a portlet managed mode which is always allowed.
+                    CustomPortletMode cpm = dd.getApplication().getCustomPortletMode(modeName);
+                    if (cpm != null && !cpm.isPortalManaged())
+                    {
+                        return true;
+                    }
+                    Enumeration<PortletMode> supportedModes = portalContext.getSupportedPortletModes();
+                    while (supportedModes.hasMoreElements()) 
+                    {
+                        if (supportedModes.nextElement().equals(mode)) 
+                        {
+                            return true;
+                        }
+                    }
+                    return false;
+                }
+            }
+        }
+        return false;
     }
 
     public boolean isRequestedSessionIdValid() 

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java?rev=768291&r1=768290&r2=768291&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
Fri Apr 24 12:53:27 2009
@@ -28,6 +28,8 @@
 import org.apache.pluto.container.PortletResponseContext;
 import org.apache.pluto.container.PortletWindow;
 import org.apache.pluto.container.ResourceURLProvider;
+import org.apache.pluto.container.om.portlet.CustomPortletMode;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
 import org.apache.pluto.container.om.portlet.Supports;
 import org.apache.pluto.container.util.ArgumentUtility;
 import org.w3c.dom.DOMException;
@@ -80,44 +82,42 @@
 
     protected boolean isPortletModeAllowed(PortletMode mode)
     {
-        return isPortletModeAllowedByPortlet(mode) && isPortletModeAllowedByPortal(mode);
-    }
-
-    protected boolean isPortletModeAllowedByPortlet(PortletMode portletMode)
-    {
-        //Not checking for VIEW mode in portetlDefinition, as VIEW mode is default
-        // as per specs.
-        if(PortletMode.VIEW.equals(portletMode))
+        if(PortletMode.VIEW.equals(mode))
+        {
             return true;
+        }
         
-        String mode = portletMode.toString();
-        for (Supports sub : getPortletWindow().getPortletEntity().getPortletDefinition().getSupports())
+        String modeName = mode.toString();
+
+        PortletDefinition dd = getPortletWindow().getPortletEntity().getPortletDefinition();
+
+        for (Supports sup : dd.getSupports())
         {
-            for (String pm : sub.getPortletModes())
+            for (String m : sup.getPortletModes())
             {
-                if (mode.equalsIgnoreCase(pm))
+                if (m.equalsIgnoreCase(modeName)) 
                 {
-                    return true;
+                    // check if a portlet managed mode which is always allowed.
+                    CustomPortletMode cpm = dd.getApplication().getCustomPortletMode(modeName);
+                    if (cpm != null && !cpm.isPortalManaged())
+                    {
+                        return true;
+                    }
+                    Enumeration<PortletMode> supportedModes = getPortalContext().getSupportedPortletModes();
+                    while (supportedModes.hasMoreElements()) 
+                    {
+                        if (supportedModes.nextElement().equals(mode)) 
+                        {
+                            return true;
+                        }
+                    }
+                    return false;
                 }
             }
         }
         return false;
     }
 
-    protected boolean isPortletModeAllowedByPortal(PortletMode mode)
-    {
-        Enumeration<PortletMode> supportedModes = getPortalContext().getSupportedPortletModes();
-        while (supportedModes.hasMoreElements())
-        {
-            if (supportedModes.nextElement().equals(mode))
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    
     // PortletResponse Impl ----------------------------------------------------
     
     public void addProperty(Cookie cookie)

Modified: portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java?rev=768291&r1=768290&r2=768291&view=diff
==============================================================================
--- portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
(original)
+++ portals/pluto/trunk/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletURLImpl.java
Fri Apr 24 12:53:27 2009
@@ -40,6 +40,7 @@
 import org.apache.pluto.container.PortletResponseContext;
 import org.apache.pluto.container.PortletURLListenerService;
 import org.apache.pluto.container.PortletURLProvider;
+import org.apache.pluto.container.om.portlet.CustomPortletMode;
 import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
 import org.apache.pluto.container.om.portlet.PortletDefinition;
 import org.apache.pluto.container.om.portlet.Supports;
@@ -84,15 +85,12 @@
 
     private boolean isPortletModeAllowed(PortletMode mode)
     {
-        return isPortletModeAllowedByPortlet(mode) && isPortletModeAllowedByPortal(mode);
-    }
-
-    private boolean isPortletModeAllowedByPortlet(PortletMode mode) 
-    {
         if(PortletMode.VIEW.equals(mode))
         {
             return true;
         }
+        
+        String modeName = mode.toString();
 
         PortletDefinition dd = responseContext.getPortletWindow().getPortletEntity().getPortletDefinition();
 
@@ -100,29 +98,29 @@
         {
             for (String m : sup.getPortletModes())
             {
-                if (m.equalsIgnoreCase(mode.toString())) 
+                if (m.equalsIgnoreCase(modeName)) 
                 {
-                    return true;
+                    // check if a portlet managed mode which is always allowed.
+                    CustomPortletMode cpm = dd.getApplication().getCustomPortletMode(modeName);
+                    if (cpm != null && !cpm.isPortalManaged())
+                    {
+                        return true;
+                    }
+                    Enumeration<PortletMode> supportedModes = portalContext.getSupportedPortletModes();
+                    while (supportedModes.hasMoreElements()) 
+                    {
+                        if (supportedModes.nextElement().equals(mode)) 
+                        {
+                            return true;
+                        }
+                    }
+                    return false;
                 }
             }
         }
         return false;
     }
 
-    private boolean isPortletModeAllowedByPortal(PortletMode mode) 
-    {
-        Enumeration<PortletMode> supportedModes = portalContext.getSupportedPortletModes();
-        while (supportedModes.hasMoreElements()) 
-        {
-            if (supportedModes.nextElement().toString().equalsIgnoreCase(
-                    (mode.toString()))) 
-            {
-                return true;
-            }
-        }
-        return false;
-    }    
-    
     private boolean isWindowStateAllowed(WindowState state)
     {
         Enumeration<WindowState> supportedStates = portalContext.getSupportedWindowStates();



Mime
View raw message