portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdore...@apache.org
Subject svn commit: r577693 - in /portals/pluto/branches/1.1-286-trunk-merge: pluto-container/src/main/java/org/apache/pluto/internal/impl/ pluto-container/src/main/java/org/apache/pluto/spi/ pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/port...
Date Thu, 20 Sep 2007 11:37:00 GMT
Author: cdoremus
Date: Thu Sep 20 04:36:58 2007
New Revision: 577693

URL: http://svn.apache.org/viewvc?rev=577693&view=rev
Log:
Applied PortletURLGenerationListener091107.patch from PLUTO-431. Thanks, Torsten!

Added:
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortletURLListener.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLListenerImpl.java
Modified:
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceURLImpl.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortalCallbackService.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/portlet/PortletDD.java
    portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackServiceImpl.java

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java?rev=577693&r1=577692&r2=577693&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/BaseURLImpl.java
Thu Sep 20 04:36:58 2007
@@ -22,6 +22,7 @@
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import javax.portlet.BaseURL;
@@ -36,6 +37,7 @@
 import org.apache.pluto.descriptors.portlet.PortletDD;
 import org.apache.pluto.descriptors.portlet.SupportsDD;
 import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.spi.PortletURLListener;
 import org.apache.pluto.spi.PortletURLProvider;
 import org.apache.pluto.spi.PublicRenderParameterProvider;
 import org.apache.pluto.util.StringManager;
@@ -148,6 +150,7 @@
             throw new IllegalArgumentException(
                 "Render parameters must not be null.");
         }
+        
         for (Iterator iter = parameters.entrySet().iterator(); iter.hasNext();) {
             Map.Entry entry = (Map.Entry) iter.next();
             if (!(entry.getKey() instanceof String)) {
@@ -162,9 +165,18 @@
         
         this.parameters.clear();
         this.publicRenderParameters.clear();
+        List<String> publicPortletRenderParameterNames = internalPortletWindow.getPortletEntity().getPortletDefinition().getPublicRenderParameter();
         if (parameters.keySet()!= null){
         	for (Object key : parameters.keySet()) {
-        		this.setParameter((String)key, (String[])parameters.get(key));
+        		if (publicPortletRenderParameterNames == null)
+        			this.setParameter((String)key, (String[])parameters.get(key));
+        		else{
+        			//test if this is a public parameter
+        			if (publicPortletRenderParameterNames.contains(key))
+        				publicRenderParameters.put((String)key, (String[])parameters.get(key));
+        			else
+        				this.setParameter((String)key, (String[])parameters.get(key));
+        		}
     		}
         }
         
@@ -183,6 +195,9 @@
 	    		.getPortalCallbackService()
 	    		.getPortletURLProvider(servletRequest, internalPortletWindow);
 	
+	    PortletURLListener portletURLFilterListener = portletURLFilterListener = container
+			.getRequiredContainerServices()
+			.getPortalCallbackService().getPortletURLListener();
 	    if (mode != null) {
 	        urlProvider.setPortletMode(mode);
 	    }
@@ -192,15 +207,19 @@
 	    if (isAction) {
 	        urlProvider.setAction(true);
 	    }
-	    if (isResourceServing){
+	    else if (isResourceServing){
 	    	urlProvider.setResourceServing(true);
 	    }
+
+        portletURLFilterListener.callListener(internalPortletWindow,this,isAction,isResourceServing);
+	    
 	    if (secure) {
 	        urlProvider.setSecure();
 	    }
 	    if (!isResourceServing)
 	    	urlProvider.clearParameters();
 	    
+			
 	    urlProvider.setParameters(parameters);
 	    
 	    urlProvider.setPublicRenderParameters(publicRenderParameters);
@@ -255,13 +274,15 @@
 	    Iterator supports = dd.getSupports().iterator();
 	    while(supports.hasNext()) {
 	        SupportsDD support = (SupportsDD)supports.next();
-	        Iterator modes = support.getPortletModes().iterator();
-	        while(modes.hasNext()) {
-	            String md = (String)modes.next();
-	            if (md.toUpperCase().equals(
-	                mode.toString().toUpperCase())) {
-	                return true;
-	            }
+	        if (support.getPortletModes() != null){
+	        	Iterator modes = support.getPortletModes().iterator();
+		        while(modes.hasNext()) {
+		            String md = (String)modes.next();
+		            if (md.toUpperCase().equals(
+		                mode.toString().toUpperCase())) {
+		                return true;
+		            }
+		        }
 	        }
 	    }
 	    String message = EXCEPTIONS.getString(

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java?rev=577693&r1=577692&r2=577693&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/PortletRequestImpl.java
Thu Sep 20 04:36:58 2007
@@ -24,6 +24,7 @@
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
@@ -445,14 +446,14 @@
 
     public String getParameter(String name) {
     	ArgumentUtility.validateNotNull("parameterName", name);
-    	PublicRenderParameterProvider provider = container
-    		.getRequiredContainerServices()
-    		.getPortalCallbackService()
-    		.getPublicRenderParameterProvider();
+    	List<String> publicRenderParameterNames = internalPortletWindow.getPortletEntity().getPortletDefinition().getPublicRenderParameter();
     	PortletURLProvider urlProvider = container.getRequiredContainerServices().getPortalCallbackService().getPortletURLProvider(getHttpServletRequest(),
internalPortletWindow);
     	String[] values = null;
-    	if (provider.isPublicRenderParameter(internalPortletWindow.getId().getStringId(), name)){
-    		values = urlProvider.getPublicRenderParameters(name);
+    	if (publicRenderParameterNames != null){
+    		if (publicRenderParameterNames.contains(name))
+    			values = urlProvider.getPublicRenderParameters(name);
+    		else
+    			values = (String[]) baseGetParameterMap().get(name);
     	}
     	else{
     			values = (String[]) baseGetParameterMap().get(name);
@@ -470,15 +471,17 @@
 
     public String[] getParameterValues(String name) {
     	ArgumentUtility.validateNotNull("parameterName", name);
-    	PublicRenderParameterProvider provider = container
-		.getRequiredContainerServices()
-		.getPortalCallbackService()
-		.getPublicRenderParameterProvider();
-    	PortletURLProvider urlProvider = container.getRequiredContainerServices().getPortalCallbackService().getPortletURLProvider(getHttpServletRequest(),
internalPortletWindow);
+    	List<String> publicRenderParameterNames = internalPortletWindow.getPortletEntity().getPortletDefinition().getPublicRenderParameter();
+    	PortletURLProvider urlProvider = container.getRequiredContainerServices()
+    											  .getPortalCallbackService()
+    											  .getPortletURLProvider(getHttpServletRequest(), internalPortletWindow);
     	
     	String[] values = null;
-    	if (provider.isPublicRenderParameter(internalPortletWindow.getId().getStringId(), name)){
-    		values = urlProvider.getPublicRenderParameters(name);
+    	if (publicRenderParameterNames != null){
+    		if (publicRenderParameterNames.contains(name))
+    			values = urlProvider.getPublicRenderParameters(name);
+    		else
+    			values = (String[]) baseGetParameterMap().get(name);
     	}
     	else{
     			values = (String[]) baseGetParameterMap().get(name);
@@ -491,7 +494,22 @@
     }
     
     public Map getParameterMap() {
-    	return Collections.unmodifiableMap(StringUtils.copyParameters(baseGetParameterMap()));
+    	Map<String, String[]>map = StringUtils.copyParameters(baseGetParameterMap());
+    	List<String> publicRenderParameterNames = internalPortletWindow.getPortletEntity().getPortletDefinition().getPublicRenderParameter();
+    	if (publicRenderParameterNames!=null){
+    		PortletURLProvider urlProvider = container
+    			.getRequiredContainerServices()
+    			.getPortalCallbackService()
+    			.getPortletURLProvider(getHttpServletRequest(), internalPortletWindow);
+    		String[] values = null;
+    		for (String string : publicRenderParameterNames) {
+    			values = urlProvider.getPublicRenderParameters(string);
+    			if (values != null){
+    				map.put(string, values);
+    			}
+			}
+    	}
+    	return Collections.unmodifiableMap(map);
     }
 
     public boolean isSecure() {
@@ -758,8 +776,7 @@
 	}
 
 	public Map<String, String[]> getPrivateParameterMap() {
-		// TODO Auto-generated method stub
-		throw new UnsupportedOperationException("This method needs to be implemented.");
+		return Collections.unmodifiableMap(StringUtils.copyParameters(baseGetParameterMap()));
 	}
 
 	public Map<String, String[]> getPublicParameterMap() {

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceURLImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceURLImpl.java?rev=577693&r1=577692&r2=577693&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceURLImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/internal/impl/ResourceURLImpl.java
Thu Sep 20 04:36:58 2007
@@ -71,8 +71,8 @@
 	    }
 	    else{
 	    	String[] values = new String[tmp.length+1];
-	    	System.arraycopy(tmp, 0, values, 0, tmp.length);
-	    	values[tmp.length] = value;
+	    	values[0] = value;
+	    	System.arraycopy(tmp, 0, values, 1, tmp.length);
 	    	super.setParameter(name, values);
 	    }
 	}
@@ -89,8 +89,8 @@
 	    }
 	    else{
 	    	String[] tmpValues = new String[tmp.length+values.length];
-	    	System.arraycopy(tmp, 0, tmpValues, 0, tmp.length);
-	    	System.arraycopy(values, 0, tmpValues, tmp.length, values.length);
+	    	System.arraycopy(values, 0, tmpValues, 0, values.length);
+	    	System.arraycopy(tmp, 0, tmpValues, values.length, tmp.length);
 	    	super.setParameter(name, tmpValues);
 	    }
 	}

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortalCallbackService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortalCallbackService.java?rev=577693&r1=577692&r2=577693&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortalCallbackService.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortalCallbackService.java
Thu Sep 20 04:36:58 2007
@@ -18,6 +18,7 @@
 
 import java.util.Map;
 
+import javax.portlet.BaseURL;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -92,5 +93,11 @@
      * @return FilterManager
      */
     public FilterManager getFilterManager(); 
+    
+    /**
+     * Returns the PortletURLListener which calls the Filter for the URL.
+     * @return
+     */
+    public PortletURLListener getPortletURLListener();
 
 }

Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortletURLListener.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortletURLListener.java?rev=577693&view=auto
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortletURLListener.java
(added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-container/src/main/java/org/apache/pluto/spi/PortletURLListener.java
Thu Sep 20 04:36:58 2007
@@ -0,0 +1,25 @@
+/*
+ * 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.pluto.spi;
+
+import javax.portlet.BaseURL;
+
+import org.apache.pluto.internal.InternalPortletWindow;
+
+public interface PortletURLListener {
+	public void callListener(InternalPortletWindow internalPortletWindow, BaseURL baseURL, boolean
isAction, boolean isResource);
+}

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/portlet/PortletDD.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/portlet/PortletDD.java?rev=577693&r1=577692&r2=577693&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/portlet/PortletDD.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-descriptor-api/src/main/java/org/apache/pluto/descriptors/portlet/PortletDD.java
Thu Sep 20 04:36:58 2007
@@ -198,7 +198,12 @@
     /** the supported public render parameter */
 	@XmlElement(name = "supported-public-render-parameter")
     private List<String> publicRenderParameter = null;
+ 	
+	/** the supported public render parameter */
+	@XmlElement(name = "url-generation-listener")
+    private List<String> urlGenerationListener = null;
 	
+		
 	/** the container runtime options of this portlet */
 	@XmlElement(name = "container-runtime-option")
 	private List<ContainerRuntimeOptionDD> containerRuntimeOption = null;
@@ -458,6 +463,16 @@
 
 	public List<ContainerRuntimeOptionDD> getContainerRuntimeOption() {
 		return containerRuntimeOption;
+	}
+
+
+	public List<String> getUrlGenerationListener() {
+		return urlGenerationListener;
+	}
+
+
+	public void setUrlGenerationListener(List<String> urlGenerationListener) {
+		this.urlGenerationListener = urlGenerationListener;
 	}
 }
 

Modified: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackServiceImpl.java?rev=577693&r1=577692&r2=577693&view=diff
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackServiceImpl.java
(original)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackServiceImpl.java
Thu Sep 20 04:36:58 2007
@@ -20,6 +20,7 @@
 import java.util.Collections;
 import java.util.Map;
 
+import javax.portlet.BaseURL;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -30,9 +31,10 @@
 import org.apache.pluto.spi.EventProvider;
 import org.apache.pluto.spi.FilterManager;
 import org.apache.pluto.spi.PortalCallbackService;
+import org.apache.pluto.spi.PortletURLListener;
 import org.apache.pluto.spi.PortletURLProvider;
-import org.apache.pluto.spi.ResourceURLProvider;
 import org.apache.pluto.spi.PublicRenderParameterProvider;
+import org.apache.pluto.spi.ResourceURLProvider;
 
 /**
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
@@ -120,6 +122,11 @@
      */
 	public FilterManager getFilterManager() {
 		return FilterManagerImpl.getFilterManager();
+	}
+
+
+	public PortletURLListener getPortletURLListener() {
+		return PortletURLListenerImpl.getPortletURLListener();
 	}
 }
 

Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLListenerImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLListenerImpl.java?rev=577693&view=auto
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLListenerImpl.java
(added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/PortletURLListenerImpl.java
Thu Sep 20 04:36:58 2007
@@ -0,0 +1,78 @@
+/*
+ * 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.pluto.driver.services.container;
+
+import java.util.List;
+
+import javax.portlet.BaseURL;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletURLGenerationListener;
+import javax.portlet.ResourceURL;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.spi.PortletURLListener;
+
+public class PortletURLListenerImpl implements PortletURLListener {
+	/** Logger. */
+    private static final Log LOG = LogFactory.getLog(PortletURLListenerImpl.class);
+	private static PortletURLListenerImpl portletURLListener = new PortletURLListenerImpl();
+	
+	public static PortletURLListener getPortletURLListener(){
+		return portletURLListener;
+	}
+	
+	
+	public synchronized void callListener(InternalPortletWindow internalPortletWindow, BaseURL
baseURL, boolean isAction, boolean isResource){
+		if (isAction&&isResource){
+			String message = "It is not allowed to set both values from isAction and isResource to
true";
+			LOG.error(message, new IllegalArgumentException(message));
+		}
+		//this list is needed for the classnames
+		List<String> portletURLFilterList = internalPortletWindow.getPortletEntity().getPortletDefinition().getUrlGenerationListener();
+		//Iterate over the classnames and for each entry in the list the filter..URL is called.
+		if (portletURLFilterList != null){
+			for (String string : portletURLFilterList) {
+				ClassLoader loader = Thread.currentThread().getContextClassLoader();
+				Class clazz;
+				try {
+					clazz = loader.loadClass(string);
+					if (clazz != null){
+						PortletURLGenerationListener portletURLGenerationListener = (PortletURLGenerationListener)clazz.newInstance();
+						if (isAction)
+							portletURLGenerationListener.filterActionURL((PortletURL)baseURL);
+						else if (isResource)
+							portletURLGenerationListener.filterResourceURL((ResourceURL)baseURL);
+						else
+							portletURLGenerationListener.filterRenderURL((PortletURL)baseURL);
+					}
+				} catch (ClassNotFoundException e) {
+					String message = "The class isn't found.";
+					LOG.error(message);
+				} catch (InstantiationException e) {
+					String message = "The instantioation fail.";
+					LOG.error(message);
+				} catch (IllegalAccessException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		}
+	}
+}



Mime
View raw message