Author: woonsan
Date: Sun Sep 30 21:40:02 2007
New Revision: 580838

URL: http://svn.apache.org/viewvc?rev=580838&view=rev
Log:
[JS2-634] edit_defaults custom portlet mode
My implementation had two options: (1) [default] based on 
constraints/permissions, (2) [optional]
based on request.isUserInRole().
However, IMO, the option (2) is not necessary because it is supported by the 
option (1).
Also, to have the option (2) seems making things complicated.
So, I removed the option (2) and reverted the xml files and DecorationValve.

Modified:
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml
    
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java?rev=580838&r1=580837&r2=580838&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/CustomDecoratorActionsFactory.java
 Sun Sep 30 21:40:02 2007
@@ -31,8 +31,6 @@
 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
 {
@@ -45,30 +43,8 @@
     private final List supportedActions;
     private final List supportedSoloActions;
     
-    private boolean adminRightsDelegatable = true;    
-    private PortalConfiguration configuration;
-    private String adminRoleName = "admin";
-    
     public CustomDecoratorActionsFactory()
     {
-        this(true);
-    }
-    
-    public CustomDecoratorActionsFactory(boolean adminRightsDelegatable)
-    {
-        this(adminRightsDelegatable, null);
-    }
-    
-    public CustomDecoratorActionsFactory(boolean adminRightsDelegatable, 
PortalConfiguration configuration)
-    {
-        this.adminRightsDelegatable = adminRightsDelegatable;
-        this.configuration = configuration;
-        
-        if (this.configuration != null)
-        {
-            this.adminRoleName = 
this.configuration.getString(PortalConfigurationConstants.ROLES_DEFAULT_ADMIN, 
this.adminRoleName);
-        }
-        
         ArrayList list = new 
ArrayList(JetspeedActions.getStandardPortletModes());
         list.add(JetspeedActions.ABOUT_MODE);
         list.add(JetspeedActions.EDIT_DEFAULTS_MODE);
@@ -116,19 +92,12 @@
         int editDefaultsModeIndex = 
actionTemplates.indexOf(EDIT_DEFAULTS_MODE_TEMPLATE);
         if (editDefaultsModeIndex != -1)
         {
-            if (this.adminRightsDelegatable)
+            try
             {
-                try
-                {
-                    ContentPage page = rc.getPage();
-                    page.checkAccess(JetspeedActions.EDIT_DEFAULTS);
-                }
-                catch (SecurityException e)
-                {
-                    actionTemplates.remove(editDefaultsModeIndex);
-                }
+                ContentPage page = rc.getPage();
+                page.checkAccess(JetspeedActions.EDIT_DEFAULTS);
             }
-            else if (!rc.getRequest().isUserInRole(this.adminRoleName))
+            catch (SecurityException e)
             {
                 actionTemplates.remove(editDefaultsModeIndex);
             }

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java?rev=580838&r1=580837&r2=580838&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
 Sun Sep 30 21:40:02 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,19 +79,19 @@
 
     private final PortletWindowAccessor windowAccessor;
     
-    private Map decoratorActionsAdapterMap;
+    private HashMap decoratorActionsAdapterCache = new HashMap();
     
-    private DecoratorActionsFactory defaultDecoratorActionsAdapter;
+    private DecoratorActionsFactory defaultDecoratorActionsFactory;
 
     private JetspeedContentCache cache = null;
     
     private boolean useSessionForThemeCaching = false;
     
     private boolean maxOnEdit = false;
-    
-    /*
-     * For security constraint checks
-     */
+         
+     /**
+      * For security constraint checks
+      */
      protected SecurityAccessController accessController;
 
      public DecorationValve(DecorationFactory decorationFactory, 
PortletWindowAccessor windowAccessor,SecurityAccessController accessController)
@@ -106,40 +105,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 +276,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;
     }
     
     /**
@@ -651,7 +626,7 @@
     public void setMaximizeOnEdit(boolean maxOnEdit)
     {
         this.maxOnEdit = maxOnEdit;
-        this.defaultDecoratorActionsAdapter.setMaximizeOnEdit(maxOnEdit);
+        this.defaultDecoratorActionsFactory.setMaximizeOnEdit(maxOnEdit);
     }
     
     public boolean getMaximizeOnEdit()

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml?rev=580838&r1=580837&r2=580838&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/pipelines.xml
 Sun Sep 30 21:40:02 2007
@@ -316,23 +316,12 @@
                <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>        
 
   </bean>
 

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml?rev=580838&r1=580837&r2=580838&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/WEB-INF/assembly/theme-engine.xml
 Sun Sep 30 21:40:02 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
@@ -32,19 +32,5 @@
                <ref bean="ResourceValidator" />
        </constructor-arg>
   </bean>  
-
-  <bean id="CustomDecoratorActionsAdapter"
-      class="org.apache.jetspeed.decoration.CustomDecoratorActionsFactory">
-    <!--
-      If true, admin rights can be delegated to others based on constraints 
and permissions. 
-      Otherwise, only users with the admin role can use admin actions such as 
edit_defaults.
-    -->
-    <constructor-arg index="0">
-        <value>true</value>
-    </constructor-arg>
-    <constructor-arg index="1">
-        <ref bean="PortalConfiguration"/>
-    </constructor-arg>
-  </bean>
-  
+       
 </beans>

Modified: 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties
URL: 
http://svn.apache.org/viewvc/portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties?rev=580838&r1=580837&r2=580838&view=diff
==============================================================================
--- 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties
 (original)
+++ 
portals/jetspeed-2/branches/JETSPEED-2.1.3/src/webapp/decorations/portlet/tigris/decorator.properties
 Sun Sep 30 21:40:02 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to