portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r581756 - in /portals/jetspeed-2/trunk: components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/ components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/ jetspeed-commons/src/main/java/org/apache/jetspe...
Date Thu, 04 Oct 2007 01:16:41 GMT
Author: woonsan
Date: Wed Oct  3 18:16:35 2007
New Revision: 581756

URL: http://svn.apache.org/viewvc?rev=581756&view=rev
Log:
[JS2-634] edit_defaults custom portlet mode
Implemented edit_defaults and about custom portlet modes.
Only users having admin rights (based on constraints/permissions) can use edit_defaults mode,
and the default preferences are to be stored in PSML pages.
To enable this feature, the portlet decoration properties should have 'actions.factory=org.apache.jetspeed.decoration.CustomDecoratorActionsFactory'.
See /decorations/portlet/tigris/decorator.properties.
Implemented edit_defaults and about custom portlet modes for the PickANumber portlet.

[JS2-634] More advanced feature added:
If a portlet does not support edit_defaults mode, but it supports edit mode, then Jetspeed
can optionally provide automatic dispatching to doEdit() when the current portlet mode is
edit_defaults.

To enable this option:

 a) Set *autoSwitchingToEditDefaultsModes* to true for decorationValve in pipelines.xml like
the following:

     <property name="autoSwitchingToEditDefaultsModes"><value>true</value></property>

 b) Set the first constructor arg to true for portletFactory bean in registry.xml like the
following:

    <bean id="portletFactory" class="org.apache.jetspeed.factory.JetspeedPortletFactory">
        <!--
        If the following argument is true, then this factory will create proxy instances for
actual portlet instances. 
        Proxy instances will switch edit_defaults mode to edit mode automatically for portlets
not supporting edit_defaults mode.
        -->
        <constructor-arg index="0">
            <value>false</value>
        </constructor-arg>
    </bean>

Limitations or Assumptions:
 a) If the doEdit() method of a portlet is not public, then the system will not provide auto-dispatching
for the portlet with no error.
 b) If a portlet provide edit_defaults mode, then the system will not provide auto-dispatching.
Instead, it will hand over rendering to the portlet.

Added:
    portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletProxyInstance.java
    portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
    portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/BaseObjectProxy.java
Modified:
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
    portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/DecorationValve.java
    portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/registry.xml
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/theme-engine.xml
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/pages/page.security
    portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/decorations/portlet/tigris/decorator.properties

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
Wed Oct  3 18:16:35 2007
@@ -26,12 +26,11 @@
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.om.common.portlet.PortletApplication;
 import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.jetspeed.om.page.ContentPage;
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.SecurityAccessController;
 import org.apache.pluto.om.window.PortletWindow;
-import org.apache.jetspeed.administration.PortalConfiguration;
-import org.apache.jetspeed.administration.PortalConfigurationConstants;
 
 public class CustomDecoratorActionsFactory extends AbstractDecoratorActionsFactory
 {
@@ -44,17 +43,8 @@
     private final List supportedActions;
     private final List supportedSoloActions;
     
-    private PortalConfiguration configuration;
-    
     public CustomDecoratorActionsFactory()
     {
-        this(null);
-    }
-    
-    public CustomDecoratorActionsFactory(PortalConfiguration configuration)
-    {
-        this.configuration = configuration;
-        
         ArrayList list = new ArrayList(JetspeedActions.getStandardPortletModes());
         list.add(JetspeedActions.ABOUT_MODE);
         list.add(JetspeedActions.EDIT_DEFAULTS_MODE);
@@ -99,18 +89,15 @@
         // else if (printModeIndex != -1)
         //   support switching to different modes once in "solo" state, even back to "print"
         
-        String adminRoleName = "admin";
-        
-        if (this.configuration != null)
-        {
-            adminRoleName = this.configuration.getString(PortalConfigurationConstants.ROLES_DEFAULT_ADMIN,
adminRoleName);
-        }
-        
-        // Remove editDefaultsMode if the user does not have admin role.
         int editDefaultsModeIndex = actionTemplates.indexOf(EDIT_DEFAULTS_MODE_TEMPLATE);
         if (editDefaultsModeIndex != -1)
         {
-            if (!rc.getRequest().isUserInRole(adminRoleName))
+            try
+            {
+                ContentPage page = rc.getPage();
+                page.checkAccess(JetspeedActions.EDIT_DEFAULTS);
+            }
+            catch (SecurityException e)
             {
                 actionTemplates.remove(editDefaultsModeIndex);
             }

Modified: portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/DecorationValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/DecorationValve.java?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/DecorationValve.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/decoration/DecorationValve.java
Wed Oct  3 18:16:35 2007
@@ -18,7 +18,6 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Map;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -80,9 +79,9 @@
 
     private final PortletWindowAccessor windowAccessor;
     
-    private Map decoratorActionsAdapterMap;
+    private HashMap decoratorActionsAdapterCache = new HashMap();
     
-    private DecoratorActionsFactory defaultDecoratorActionsAdapter;
+    private DecoratorActionsFactory defaultDecoratorActionsFactory;
 
     private JetspeedContentCache cache = null;
     
@@ -90,9 +89,11 @@
     
     private boolean maxOnEdit = false;
     
-    /*
-     * For security constraint checks
-     */
+    private boolean autoSwitchingToEditDefaultsModes = true;
+         
+     /**
+      * For security constraint checks
+      */
      protected SecurityAccessController accessController;
 
      public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,SecurityAccessController
accessController)
@@ -106,40 +107,17 @@
          this(decorationFactory, windowAccessor, accessController, cache, false);
      }
      
-    public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
-                                SecurityAccessController accessController, JetspeedContentCache
cache,
-                                boolean useSessionForThemeCaching)
-    {
-        this(decorationFactory, windowAccessor, accessController, cache, false, null);
-    }
-     
-    public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
-                                SecurityAccessController accessController, JetspeedContentCache
cache,
-                                boolean useSessionForThemeCaching, Map decoratorActionsAdapterMap)
-    {
-        this(decorationFactory, windowAccessor, accessController, cache, false, decoratorActionsAdapterMap,
new DefaultDecoratorActionsFactory());
-    }
-    
-    public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
-                                SecurityAccessController accessController, JetspeedContentCache
cache,
-                                boolean useSessionForThemeCaching, Map decoratorActionsAdapterMap,

-                                DecoratorActionsFactory defaultDecoratorActionsAdapter)
-    {       
+     public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor,
+                                 SecurityAccessController accessController, JetspeedContentCache
cache,
+                                 boolean useSessionForThemeCaching)
+     {       
         this.decorationFactory = decorationFactory;
         this.windowAccessor = windowAccessor;
-        
+        this.defaultDecoratorActionsFactory = new DefaultDecoratorActionsFactory();     
  
         //added the accessController in portlet decorater for checking the actions
         this.accessController = accessController;        
         this.cache = cache;
         this.useSessionForThemeCaching = useSessionForThemeCaching;
-        this.decoratorActionsAdapterMap = decoratorActionsAdapterMap;
-        
-        if (this.decoratorActionsAdapterMap == null)
-        {
-            this.decoratorActionsAdapterMap = new HashMap();
-        }
-        
-        this.defaultDecoratorActionsAdapter = defaultDecoratorActionsAdapter;
     }
     
     public void invoke(RequestContext requestContext, ValveContext context) throws PipelineException
@@ -300,36 +278,35 @@
     
     public DecoratorActionsFactory getDecoratorActionsAdapter(Decoration decoration)
     {
-        DecoratorActionsFactory adapter = this.defaultDecoratorActionsAdapter;
-        
         // FIXME: why always get this property
-        String decoratorActionsAdapterName = decoration.getProperty("actions.factory");
-        
-        if ( decoratorActionsAdapterName != null )
+        String decoratorActionsAdapterClassName = decoration.getProperty("actions.factory");
+        if ( decoratorActionsAdapterClassName == null )
         {
-            adapter = (DecoratorActionsFactory) this.decoratorActionsAdapterMap.get(decoratorActionsAdapterName);
-            
-            if (adapter == null)
+            decoratorActionsAdapterClassName = defaultDecoratorActionsFactory.getClass().getName();
+        }
+        synchronized (decoratorActionsAdapterCache)
+        {
+            DecoratorActionsFactory adapter = (DecoratorActionsFactory)decoratorActionsAdapterCache.get(decoratorActionsAdapterClassName);
+            if ( adapter == null )
             {
                 try
                 {
-                    adapter = (DecoratorActionsFactory) Class.forName(decoratorActionsAdapterName).newInstance();
+                    adapter = (DecoratorActionsFactory)Class.forName(decoratorActionsAdapterClassName).newInstance();
                     adapter.setMaximizeOnEdit(this.maxOnEdit);
                 }
                 catch (Exception e)
                 {
-                    log.error("Failed to instantiate custom DecoratorActionsAdaptor "+decoratorActionsAdapterName+",
falling back to default.",e);
-                    adapter = this.defaultDecoratorActionsAdapter;
-                }
-                
-                synchronized (this.decoratorActionsAdapterMap)
-                {
-                    this.decoratorActionsAdapterMap.put(decoratorActionsAdapterName,adapter);
+                    log.error("Failed to instantiate custom DecoratorActionsAdaptor "+decoratorActionsAdapterClassName+",
falling back to default.",e);
+                    adapter = (DecoratorActionsFactory)decoratorActionsAdapterCache.get(defaultDecoratorActionsFactory.getClass().getName());
+                    if ( adapter == null )
+                    {
+                        adapter = defaultDecoratorActionsFactory;
+                    }
                 }
+                decoratorActionsAdapterCache.put(decoratorActionsAdapterClassName,adapter);
             }
+            return adapter;
         }
-        
-        return adapter;
     }
     
     /**
@@ -411,7 +388,7 @@
                         }
                         if ( ! equalsCurrentMode || isAjaxRequest )
                         {
-                            if ( content.supportsPortletMode(customMode) 
+                            if ( (content.supportsPortletMode(customMode) || isAutoSwitchableCustomMode(customMode))
                                  && (!PortletMode.EDIT.equals(customMode) || pageActionAccess.isEditAllowed())
                                  && pageActionAccess.checkPortletMode(fragmentId,
portletName, mappedMode)
                                  )
@@ -651,11 +628,34 @@
     public void setMaximizeOnEdit(boolean maxOnEdit)
     {
         this.maxOnEdit = maxOnEdit;
-        this.defaultDecoratorActionsAdapter.setMaximizeOnEdit(maxOnEdit);
+        this.defaultDecoratorActionsFactory.setMaximizeOnEdit(maxOnEdit);
     }
     
     public boolean getMaximizeOnEdit()
     {
         return this.maxOnEdit;
+    }
+    
+    public void setAutoSwitchingToEditDefaultsModes(boolean autoSwitchingToEditDefaultsModes)
+    {
+        this.autoSwitchingToEditDefaultsModes = autoSwitchingToEditDefaultsModes;
+    }
+    
+    public boolean getAutoSwitchingToEditDefaultsModes()
+    {
+        return this.autoSwitchingToEditDefaultsModes;
+    }
+    
+    private boolean isAutoSwitchableCustomMode(PortletMode customMode)
+    {
+        if (this.autoSwitchingToEditDefaultsModes)
+        {
+            if (JetspeedActions.EDIT_DEFAULTS_MODE.equals(customMode))
+            {
+                return true;
+            }
+        }
+        
+        return false;
     }
 }

Modified: portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
(original)
+++ portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
Wed Oct  3 18:16:35 2007
@@ -56,15 +56,24 @@
     
     private static final Log log = LogFactory.getLog(JetspeedPortletFactory.class);
     private final Map classLoaderMap;
+    
+    private boolean portletProxyUsed = false;
 
     /**
      * 
      */
     public JetspeedPortletFactory()
     {
+        this(false);
+    }
+    
+    public JetspeedPortletFactory(boolean portletProxyUsed)
+    {
         this.portletCache =  Collections.synchronizedMap(new HashMap());
         this.validatorCache = Collections.synchronizedMap(new HashMap());
         classLoaderMap = Collections.synchronizedMap(new HashMap());
+        
+        this.portletProxyUsed = portletProxyUsed;
     }
 
     public void registerPortletApplication(PortletApplication pa, ClassLoader cl)
@@ -205,7 +214,15 @@
                 // wrap new Portlet inside PortletInstance which ensures the destroy
                 // method will wait for all its invocation threads to complete
                 // and thereby releasing all its ClassLoader locks as needed for local portlets.
-                portlet = new JetspeedPortletInstance(pd.getName(), (Portlet)clazz.newInstance());
+                
+                if (this.portletProxyUsed)
+                {
+                    portlet = new JetspeedPortletProxyInstance(pd.getName(), (Portlet)clazz.newInstance());
+                }
+                else
+                {
+                    portlet = new JetspeedPortletInstance(pd.getName(), (Portlet)clazz.newInstance());
+                }
             }
               finally
             {

Added: portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletProxyInstance.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletProxyInstance.java?rev=581756&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletProxyInstance.java
(added)
+++ portals/jetspeed-2/trunk/components/jetspeed-portlet-factory/src/main/java/org/apache/jetspeed/factory/JetspeedPortletProxyInstance.java
Wed Oct  3 18:16:35 2007
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.factory;
+
+import javax.portlet.Portlet;
+
+import org.apache.jetspeed.portlet.PortletObjectProxy;
+
+/**
+ * JetspeedPortletProxyInstance
+ * 
+ * @author <a href="mailto:woonsan@apache.org">Woonsan Ko</a>
+ * @version $Id: JetspeedPortletProxyInstance.java 516448 2007-03-09 16:25:47Z ate $
+ *
+ */
+public class JetspeedPortletProxyInstance extends JetspeedPortletInstance
+{
+    public JetspeedPortletProxyInstance(String portletName, Portlet portlet)
+    {
+        super(portletName, (Portlet) PortletObjectProxy.createProxy(portlet));
+    }
+}

Added: portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java?rev=581756&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
(added)
+++ portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/portlet/PortletObjectProxy.java
Wed Oct  3 18:16:35 2007
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portlet;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Modifier;
+
+import java.io.IOException;
+
+import javax.portlet.Portlet;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.pluto.om.portlet.PortletDefinition;
+import org.apache.pluto.om.portlet.ContentTypeSet;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.util.BaseObjectProxy;
+import org.apache.jetspeed.container.JetspeedPortletConfig;
+
+/**
+ * PortletObjectProxy
+ * 
+ * @author <a href="mailto:woonsan@apache.org">Woonsan Ko</a>
+ * @version $Id: PortletObjectProxy.java 516448 2007-03-09 16:25:47Z ate $
+ */
+public class PortletObjectProxy extends BaseObjectProxy
+{
+
+    private static Method renderMethod;
+    
+    static 
+    {
+    	try 
+        {
+            renderMethod = Portlet.class.getMethod("render", new Class [] { RenderRequest.class,
RenderResponse.class });
+        } 
+        catch (NoSuchMethodException e) 
+        {
+    	    throw new NoSuchMethodError(e.getMessage());
+    	}
+    }
+    
+    private Object portletObject;
+    private boolean genericPortletInvocable;
+    private Method portletDoEditMethod;
+    private ContentTypeSet portletContentTypeSet;
+    
+    public static Object createProxy(Object proxiedObject)
+    {
+        Class proxiedClass = proxiedObject.getClass();
+        ClassLoader classLoader = proxiedClass.getClassLoader();
+        Class [] proxyInterfaces = new Class [] { Portlet.class };
+        InvocationHandler handler = new PortletObjectProxy(proxiedObject);
+        return Proxy.newProxyInstance(classLoader, proxyInterfaces, handler);
+    }
+
+    private PortletObjectProxy(Object portletObject)
+    {
+        this.portletObject = portletObject;
+        
+        if (portletObject instanceof GenericPortlet)
+        {
+            try
+            {
+                this.portletDoEditMethod = this.portletObject.getClass().getMethod("doEdit",
new Class [] { RenderRequest.class, RenderResponse.class });
+                
+                if (Modifier.isPublic(this.portletDoEditMethod.getModifiers()))
+                {
+                    this.genericPortletInvocable = true;
+                }
+            }
+            catch (NoSuchMethodException e)
+            {
+            }
+        }
+    }
+
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+    {
+        Object result = null;
+        boolean handledHere = false;
+        Class declaringClass = method.getDeclaringClass();
+        
+        if (declaringClass == Portlet.class)
+        {
+            if (renderMethod.equals(method))
+            {
+                proxyRender((RenderRequest) args[0], (RenderResponse) args[1]);
+                return null;
+            }
+            else
+            {
+                result = method.invoke(this.portletObject, args);
+            }
+        }
+        else
+        {
+            result = super.invoke(proxy, method, args);
+        }
+        
+        return result;
+    }
+
+    protected void proxyRender(RenderRequest request, RenderResponse response) throws PortletException,
IOException, Exception
+    {
+        boolean autoSwitchToEditMode = false;
+        
+        if (this.genericPortletInvocable)
+        {
+            PortletMode mode = request.getPortletMode();
+            
+            if (JetspeedActions.EDIT_DEFAULTS_MODE.equals(mode))
+            {
+                if (!isSupportingEditDefaultsMode((GenericPortlet) this.portletObject))
+                {
+                    autoSwitchToEditMode = true;
+                }
+            }
+        }
+        
+        if (autoSwitchToEditMode)
+        {
+            GenericPortlet genericPortlet = (GenericPortlet) this.portletObject;
+            
+            // Override GenericPortlet#render....
+            WindowState state = request.getWindowState();
+            
+            if (!WindowState.MINIMIZED.equals(state))
+            {
+                String title = genericPortlet.getPortletConfig().getResourceBundle(request.getLocale()).getString("javax.portlet.title");
+                response.setTitle(title);
+                
+                this.portletDoEditMethod.invoke(genericPortlet, new Object [] { request,
response });
+            }
+        }
+        else
+        {
+            ((Portlet) this.portletObject).render(request, response);
+        }
+    }
+    
+    private boolean isSupportingEditDefaultsMode(GenericPortlet portlet)
+    {
+        if (this.portletContentTypeSet == null)
+        {
+            try
+            {
+                JetspeedPortletConfig config = (JetspeedPortletConfig) portlet.getPortletConfig();
+                PortletDefinition portletDef = config.getPortletDefinition();
+                this.portletContentTypeSet = portletDef.getContentTypeSet();
+            }
+            catch (Exception e)
+            {
+            }
+        }
+        
+        if (this.portletContentTypeSet != null)
+        {
+            return this.portletContentTypeSet.supportsPortletMode(JetspeedActions.EDIT_DEFAULTS_MODE);
+        }
+        
+        return false;
+    }
+}

Added: portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/BaseObjectProxy.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/BaseObjectProxy.java?rev=581756&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/BaseObjectProxy.java
(added)
+++ portals/jetspeed-2/trunk/jetspeed-commons/src/main/java/org/apache/jetspeed/util/BaseObjectProxy.java
Wed Oct  3 18:16:35 2007
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.util;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * BaseObjectProxy
+ * 
+ * @author <a href="mailto:woonsan@apache.org">Woonsan Ko</a>
+ * @version $Id: BaseObjectProxy.java 516448 2007-03-09 16:25:47Z ate $
+ */
+public class BaseObjectProxy implements InvocationHandler 
+{
+
+    protected static Method hashCodeMethod;
+    protected static Method equalsMethod;
+    protected static Method toStringMethod;
+    
+    static 
+    {
+    	try 
+        {
+    	    hashCodeMethod = Object.class.getMethod("hashCode", null);
+    	    equalsMethod = Object.class.getMethod("equals", new Class [] { Object.class });
+    	    toStringMethod = Object.class.getMethod("toString", null);
+        } 
+        catch (NoSuchMethodException e) 
+        {
+    	    throw new NoSuchMethodError(e.getMessage());
+    	}
+    }
+    
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+    {
+        Object result = null;
+    	Class declaringClass = method.getDeclaringClass();
+
+    	if (declaringClass == Object.class) 
+        {
+    	    if (hashCodeMethod.equals(method)) 
+            {
+                result = proxyHashCode(proxy);
+    	    } 
+            else if (equalsMethod.equals(method)) 
+            {
+                result = proxyEquals(proxy, args[0]);
+    	    } 
+            else if (toStringMethod.equals(method)) 
+            {
+                result = proxyToString(proxy);
+    	    } 
+            else 
+            {
+                throw new InternalError("unexpected Object method dispatched: " + method);
+    	    }
+    	}
+        else
+        {
+            throw new InternalError("unexpected Object method dispatched: " + method);
+        }
+        
+        return result;
+    }
+    
+    protected Integer proxyHashCode(Object proxy) 
+    {
+    	return new Integer(System.identityHashCode(proxy));
+    }
+
+    protected Boolean proxyEquals(Object proxy, Object other) 
+    {
+    	return (proxy == other ? Boolean.TRUE : Boolean.FALSE);
+    }
+
+    protected String proxyToString(Object proxy) 
+    {
+    	return proxy.getClass().getName() + '@' + Integer.toHexString(proxy.hashCode());
+    }
+
+}

Modified: portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml
(original)
+++ portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/pipelines.xml
Wed Oct  3 18:16:35 2007
@@ -291,24 +291,14 @@
 		<constructor-arg index='2'>
 			<ref bean="org.apache.jetspeed.security.SecurityAccessController" />
 		</constructor-arg>
-        <constructor-arg index='3'>
-            <null/>
-            <!--
+		<!-- 
+       <constructor-arg index='3'>
 	        <ref bean="decorationContentCache"/>
-            -->
-        </constructor-arg>
-        <constructor-arg index='4'>
-            <value>false</value>
-        </constructor-arg>
-        <constructor-arg index='5'>
-            <map>
-                <entry key='CustomDecoratorActionsAdapter'>
-                    <ref bean="CustomDecoratorActionsAdapter" />
-                </entry>
-            </map>
-        </constructor-arg>
-        <!-- When clicking on Edit Mode, also switch to Maximize -->
+        </constructor-arg>       		
+         -->
+         <!-- When clicking on Edit Mode, also switch to Maximize -->
         <property name="maximizeOnEdit"><value>false</value></property>
        
+        <property name="autoSwitchingToEditDefaultsModes"><value>false</value></property>
   </bean>
 
   <bean id="loginViewValve"

Modified: portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/registry.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/registry.xml?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/registry.xml
(original)
+++ portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/registry.xml
Wed Oct  3 18:16:35 2007
@@ -19,7 +19,15 @@
 <beans>
 
     <!-- Portlet Factory -->
-    <bean id="portletFactory" class="org.apache.jetspeed.factory.JetspeedPortletFactory"></bean>
+    <bean id="portletFactory" class="org.apache.jetspeed.factory.JetspeedPortletFactory">
+        <!--
+        If the following argument is true, then this factory will create proxy instances
for actual portlet instances. 
+        Proxy instances will switch edit_defaults mode to edit mode automatically for portlets
not supporting edit_defaults mode.
+        -->
+        <constructor-arg index="0">
+            <value>false</value>
+        </constructor-arg>
+    </bean>
 
     <!-- Portlet Registry DAO-->
     <bean id="portletRegistryImpl" class="org.apache.jetspeed.components.portletregistry.PersistenceBrokerPortletRegistry"
init-method="init">

Modified: portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/theme-engine.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/theme-engine.xml?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/theme-engine.xml
(original)
+++ portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/assembly/theme-engine.xml
Wed Oct  3 18:16:35 2007
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
 <!--
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements.  See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You under the Apache License, Version 2.0
-(the "License"); you may not use this file except in compliance with
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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
@@ -33,11 +33,4 @@
 	</constructor-arg>
   </bean>  
 
-  <bean id="CustomDecoratorActionsAdapter"
-      class="org.apache.jetspeed.decoration.CustomDecoratorActionsFactory">
-    <constructor-arg index="0">
-        <ref bean="PortalConfiguration"/>
-    </constructor-arg>
-  </bean>
-  
 </beans>

Modified: portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/pages/page.security
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/pages/page.security?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/pages/page.security
(original)
+++ portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/WEB-INF/pages/page.security
Wed Oct  3 18:16:35 2007
@@ -23,7 +23,7 @@
   <security-constraints-def name="admin">
     <security-constraint>
       <roles>admin</roles>
-      <permissions>view, edit</permissions>
+      <permissions>view, edit, edit_defaults</permissions>
     </security-constraint>
   </security-constraints-def>
   <global-security-constraints-ref>admin</global-security-constraints-ref>
@@ -52,7 +52,7 @@
     </security-constraint>
     <security-constraint>
       <roles>admin</roles>
-      <permissions>view, edit</permissions>
+      <permissions>view, edit, edit_defaults</permissions>
     </security-constraint>    
   </security-constraints-def>
   <security-constraints-def name="public-edit">
@@ -64,7 +64,7 @@
   <security-constraints-def name="AEUV">
     <security-constraint>
       <roles>admin</roles>
-      <permissions>view, edit</permissions>
+      <permissions>view, edit, edit_defaults</permissions>
     </security-constraint>
     <security-constraint>
       <roles>user</roles>
@@ -79,7 +79,7 @@
     </security-constraint>
     <security-constraint>
       <roles>devmgr,admin</roles>
-      <permissions>view, edit</permissions>
+      <permissions>view, edit, edit_defaults</permissions>
     </security-constraint>
   </security-constraints-def>
 
@@ -90,14 +90,14 @@
     </security-constraint>
     <security-constraint>
       <roles>admin</roles>
-      <permissions>view, edit</permissions>
+      <permissions>view, edit, edit_defaults</permissions>
     </security-constraint>
   </security-constraints-def>
 
   <security-constraints-def name="delegated">
     <security-constraint>
       <roles>devmgr</roles>
-      <permissions>view,edit</permissions>
+      <permissions>view, edit, edit_defaults</permissions>
     </security-constraint>
   </security-constraints-def>
  

Modified: portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/decorations/portlet/tigris/decorator.properties
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/decorations/portlet/tigris/decorator.properties?rev=581756&r1=581755&r2=581756&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/decorations/portlet/tigris/decorator.properties
(original)
+++ portals/jetspeed-2/trunk/jetspeed-portal-resources/src/main/resources/webapp/decorations/portlet/tigris/decorator.properties
Wed Oct  3 18:16:35 2007
@@ -28,4 +28,4 @@
 
 decorates=portlet
 #actions.factory=org.apache.jetspeed.decoration.PrintSoloDecoratorActionsFactory
-actions.factory=CustomDecoratorActionsAdapter
+actions.factory=org.apache.jetspeed.decoration.CustomDecoratorActionsFactory



---------------------------------------------------------------------
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