portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cdore...@apache.org
Subject svn commit: r473305 - in /portals/pluto/branches/1.1-286-COMPATIBILITY: pluto-container/src/main/java/org/apache/pluto/ pluto-container/src/main/java/org/apache/pluto/core/ pluto-container/src/main/java/org/apache/pluto/internal/impl/ pluto-container/s...
Date Fri, 10 Nov 2006 10:35:33 GMT
Author: cdoremus
Date: Fri Nov 10 02:35:32 2006
New Revision: 473305

URL: http://svn.apache.org/viewvc?view=rev&rev=473305
Log:
Applied second patch in PLUTO-267. Thank you Christian.

Modified:
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/Constants.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/EventContainer.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/spi/EventProvider.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java
    portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/Constants.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/Constants.java?view=diff&rev=473305&r1=473304&r2=473305
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/Constants.java
(original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/Constants.java
Fri Nov 10 02:35:32 2006
@@ -101,10 +101,14 @@
      */
     public final static Integer METHOD_EVENT = new Integer(9);
     
-    /**
-    * The key used to bind the <code>PortletEvent</code> to the underlying
-    * <code>HttpServletRequest</code>.
-    */
-   public final static String PORTLET_EVENT = "javax.portlet.event";
+	/**
+	 * the public key, to store the EventProvider in the Request
+	 */
+	public static final String PROVIDER = "EventProvider";
+	
+	/**
+	 * The public key, to store the event name in the request 
+	 */
+	public static final String EVENT_NAME = "EventName";
 
 }

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/EventContainer.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/EventContainer.java?view=diff&rev=473305&r1=473304&r2=473305
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/EventContainer.java
(original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/EventContainer.java
Fri Nov 10 02:35:32 2006
@@ -15,6 +15,7 @@
  */
 package org.apache.pluto;
 
+
 import java.io.IOException;
 
 import javax.portlet.PortletException;
@@ -22,7 +23,25 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+/**
+ * The publicized entry point into Pluto for firing events
+ * @author <a href="mailto:chrisra@cs.uni-jena.de">Christian Raschka</a>
+ */
 public interface EventContainer {
+	
+	/**
+     * Indicates that an event should be fired in the current request and calls
+     * the processEvent method of this portlet.
+     * @param internalPortletWindow the portlet Window
+     * @param request               the servlet request
+     * @param response              the servlet response
+     * @throws PortletException          if one portlet has trouble fulfilling
+     *                                   the request
+     * @throws PortletContainerException if the portlet container implementation
+     *                                   has trouble fulfilling the request
+     */
+	public void fireEvent(HttpServletRequest request, HttpServletResponse response, 
+			PortletWindow window, String eventName) throws PortletException, IOException;
+	
 	public ServletContext getServletContext();
-	public void fireEvent(HttpServletRequest request, HttpServletResponse response, PortletWindow
window) throws PortletException, IOException;
 }

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java?view=diff&rev=473305&r1=473304&r2=473305
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
(original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/core/PortletContainerImpl.java
Fri Nov 10 02:35:32 2006
@@ -21,6 +21,7 @@
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.servlet.ServletContext;
@@ -29,6 +30,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.Constants;
 import org.apache.pluto.EventContainer;
 import org.apache.pluto.OptionalContainerServices;
 import org.apache.pluto.PortletContainer;
@@ -47,6 +49,7 @@
 import org.apache.pluto.internal.impl.RenderResponseImpl;
 import org.apache.pluto.internal.impl.ResourceRequestImpl;
 import org.apache.pluto.internal.impl.ResourceResponseImpl;
+import org.apache.pluto.internal.impl.StateAwareResponseImpl;
 import org.apache.pluto.spi.EventProvider;
 import org.apache.pluto.spi.PortletURLProvider;
 
@@ -56,6 +59,7 @@
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
  * @author <a href="mailto:esm@apache.org">Elliot Metsger</a>
+ * @author <a href="mailto:chrisra@cs.uni-jena.de">Christian Raschka</a>
  * @version 1.0
  * @since Sep 18, 2004
  */
@@ -255,30 +259,7 @@
             		.getPortalCallbackService()
             		.getPortletURLProvider(request, internalPortletWindow);
             
-            // Encode portlet mode if it is changed.
-            if (actionResponse.getChangedPortletMode() != null) {
-                redirectURL.setPortletMode(
-                		actionResponse.getChangedPortletMode());
-            }
-            
-            // Encode window state if it is changed.
-            if (actionResponse.getChangedWindowState() != null) {
-                redirectURL.setWindowState(
-                		actionResponse.getChangedWindowState());
-            }
-            
-            // Encode render parameters retrieved from action response.
-            Map renderParameters = actionResponse.getRenderParameters();
-            redirectURL.clearParameters();
-            redirectURL.setParameters(renderParameters);
-            
-            // Encode redirect URL as a render URL.
-            redirectURL.setAction(false);
-            
-            // Set secure of the redirect URL if necessary.
-            if (actionRequest.isSecure()) {
-                redirectURL.setSecure();
-            }
+            saveChangedParameters(actionRequest, actionResponse, redirectURL);
             
             // Encode the redirect URL to a string.
             location = actionResponse.encodeRedirectURL(redirectURL.toString());
@@ -373,6 +354,65 @@
         return portletAppDD;        
     }
     
+    public ServletContext getServletContext() {
+		return servletContext;
+	}
+    
+    /**
+     * Fire Event for the portlet associated with the given portlet window and eventName
+     * @param portletWindow  the portlet window.
+     * @param request  the servlet request.
+     * @param response  the servlet response.
+     * @param eventName the event name
+     * @throws PortletException
+     * @throws IOException
+     * @throws PortletContainerException
+     * 
+     * @see {@link javax.portlet.EventPortlet#processEvent(javax.portlet.EventRequest, javax.portlet.EventResponse)
+     */
+    public void fireEvent(HttpServletRequest request, HttpServletResponse response,
+    		PortletWindow window, String eventName) 
+    throws PortletException, IOException {
+
+    	ensureInitialized();
+
+    	InternalPortletWindow internalPortletWindow =
+    		new PortletWindowImpl(servletContext, window);
+    	debugWithName("Event request received for portlet: "
+    			+ window.getPortletName());
+
+    	EventRequestImpl eventRequest = new EventRequestImpl(
+    			this, internalPortletWindow, request);
+    	EventResponseImpl eventResponse = new EventResponseImpl(
+    			this, internalPortletWindow, request, response);
+    	
+    	// Save the name of the actual event to fire in the Request
+    	eventRequest.setAttribute(Constants.EVENT_NAME, eventName);
+
+    	PortletInvoker invoker = new PortletInvoker(internalPortletWindow);
+    	invoker.event(eventRequest, eventResponse);
+
+    	debugWithName("Portlet event processed for: "
+    			+ window.getPortletName());
+
+    	// After processing event, change the redirect URL for rendering.
+    	String location = eventResponse.getRedirectLocation();
+
+    	if (location == null) {
+
+    		// Create portlet URL provider to encode redirect URL.
+    		debugWithName("No redirect location specified.");
+    		PortletURLProvider redirectURL = requiredContainerServices
+    		.getPortalCallbackService()
+    		.getPortletURLProvider(request, internalPortletWindow);
+
+    		saveChangedParameters(eventRequest, eventResponse, redirectURL);
+
+    		// save redirectURL in request
+    		redirectURL.savePortalURL(request);
+    	}
+    }
+    
     
     // Private Methods ---------------------------------------------------------
     
@@ -417,77 +457,40 @@
         }
     }
 
-
-    public void fireEvent(HttpServletRequest request, HttpServletResponse response,
-    		PortletWindow window) 
-    throws PortletException, IOException {
-
-    	ensureInitialized();
-
-    	InternalPortletWindow internalPortletWindow =
-    		new PortletWindowImpl(servletContext, window);
-    	debugWithName("Event request received for portlet: "
-    			+ window.getPortletName());
-
-    	EventRequestImpl eventRequest = new EventRequestImpl(
-    			this, internalPortletWindow, request);
-    	EventResponseImpl eventResponse = new EventResponseImpl(
-    			this, internalPortletWindow, request, response);
-
-    	PortletInvoker invoker = new PortletInvoker(internalPortletWindow);
-    	invoker.event(eventRequest, eventResponse);
-
-    	debugWithName("Portlet event processed for: "
-    			+ window.getPortletName());
-
-//  	After processing event, change the redirect URL for rendering.
-    	String location = eventResponse.getRedirectLocation();
-
-    	if (location == null) {
-
-//  		Create portlet URL provider to encode redirect URL.
-    		debugWithName("No redirect location specified.");
-    		PortletURLProvider redirectURL = requiredContainerServices
-    		.getPortalCallbackService()
-    		.getPortletURLProvider(request, internalPortletWindow);
-
-//  		Encode portlet mode if it is changed.
-    		if (eventResponse.getChangedPortletMode() != null) {
-    			redirectURL.setPortletMode(
-    					eventResponse.getChangedPortletMode());
-    		}
-
-//  		Encode window state if it is changed.
-    		if (eventResponse.getChangedWindowState() != null) {
-    			redirectURL.setWindowState(
-    					eventResponse.getChangedWindowState());
-    		}
-
-//  		Encode render parameters retrieved from action response.
-    		Map renderParameters = eventResponse.getRenderParameters();
-    		redirectURL.clearParameters();
-    		redirectURL.setParameters(renderParameters);
-
-//  		Encode redirect URL as a render URL.
-    		redirectURL.setAction(false);
-
-//  		Set secure of the redirect URL if necessary.
-    		if (eventRequest.isSecure()) {
-    			redirectURL.setSecure();
-    		}
-
-//  		save redirectURL in request
-    		redirectURL.savePortalURL(request);
-
-//  		Encode the redirect URL to a string.
-    		location = eventResponse.encodeRedirectURL(redirectURL.toString());
-    	}
-    }
+	/**
+	 * @param request
+	 * @param response
+	 * @param redirectURL
+	 */
+	private void saveChangedParameters(PortletRequest request, StateAwareResponseImpl response,
PortletURLProvider redirectURL) {
+		// Encode portlet mode if it is changed.
+		if (response.getChangedPortletMode() != null) {
+			redirectURL.setPortletMode(
+					response.getChangedPortletMode());
+		}
+
+		// Encode window state if it is changed.
+		if (response.getChangedWindowState() != null) {
+			redirectURL.setWindowState(
+					response.getChangedWindowState());
+		}
+
+		// Encode render parameters retrieved from action response.
+		Map renderParameters = response.getRenderParameters();
+		redirectURL.clearParameters();
+		redirectURL.setParameters(renderParameters);
+
+		// Encode redirect URL as a render URL.
+		redirectURL.setAction(false);
+
+		// Set secure of the redirect URL if necessary.
+		if (request.isSecure()) {
+			redirectURL.setSecure();
+		}
+	}
 
 
-	public ServletContext getServletContext() {
-		return servletContext;
-	}
+	
     
 }
 

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java?view=diff&rev=473305&r1=473304&r2=473305
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
(original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/internal/impl/EventRequestImpl.java
Fri Nov 10 02:35:32 2006
@@ -15,6 +15,9 @@
  */
 package org.apache.pluto.internal.impl;
 
+
+import java.util.List;
+
 import javax.portlet.Event;
 import javax.portlet.EventRequest;
 import javax.portlet.PortletPreferences;
@@ -26,7 +29,14 @@
 import org.apache.pluto.PortletContainer;
 import org.apache.pluto.internal.InternalEventRequest;
 import org.apache.pluto.internal.InternalPortletWindow;
+import org.apache.pluto.spi.EventProvider;
 
+/**
+ * <code>javax.portlet.EventRequest</code> implementation.
+ * This class also implements InternalEventRequest.
+ *
+ * @author <a href="mailto:chrisra@cs.uni-jena.de">Christian Raschka</a>
+ */
 public class EventRequestImpl extends PortletRequestImpl 
 		implements EventRequest, InternalEventRequest {
 
@@ -36,7 +46,7 @@
 	//	 Private Member Variables ------------------------------------------------	
     
 	/** FIXME: The portlet preferences. 
-	 * see (ActionRequestImpl) 
+	 * @see (ActionRequestImpl) 
 	 */
 	private PortletPreferences portletPreferences = null;
 	
@@ -58,9 +68,18 @@
     //  EventRequest impl -------------------------------------------------------
     
     public Event getEvent(){
-        Event event = (Event) request.getAttribute(
-        		Constants.PORTLET_EVENT);
-    	return event;
+        EventProvider provider = 
+        	(EventProvider) request.getAttribute(Constants.PROVIDER);
+        String eventName = (String) this.getAttribute(Constants.EVENT_NAME);
+        List<Event> events = provider.getAllSavedEvents();
+        for (Event event : events) {
+        	if (eventName.contains(event.getName())){
+				return event;
+			}
+		}
+        
+        // should not be
+        throw new UnsupportedOperationException();
     }
     
     //  PortletRequestImpl impl -------------------------------------------------

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/spi/EventProvider.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/spi/EventProvider.java?view=diff&rev=473305&r1=473304&r2=473305
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/spi/EventProvider.java
(original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-container/src/main/java/org/apache/pluto/spi/EventProvider.java
Fri Nov 10 02:35:32 2006
@@ -104,7 +104,7 @@
 
 	/**
 	 * 
-	 * @return ArrayList containing all events
+	 * @return String list containing all events
 	 */
 	public abstract List<String> getAllEventLabelsList();
 

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java?view=diff&rev=473305&r1=473304&r2=473305
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java
(original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/container/EventProviderImpl.java
Fri Nov 10 02:35:32 2006
@@ -36,16 +36,14 @@
 import org.apache.pluto.EventContainer;
 import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.PortletWindow;
-import org.apache.pluto.core.PortletContextManager;
+import org.apache.pluto.core.PortletContainerImpl;
 import org.apache.pluto.driver.AttributeKeys;
 import org.apache.pluto.driver.config.DriverConfiguration;
 import org.apache.pluto.driver.core.PortletWindowImpl;
 import org.apache.pluto.driver.services.portal.PageConfig;
 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
 import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.driver.url.PortalURLParser;
 import org.apache.pluto.driver.url.impl.PortalURLParserImpl;
-import org.apache.pluto.internal.InternalPortletContext;
 import org.apache.pluto.spi.EventProvider;
 
 /**
@@ -63,15 +61,8 @@
     private HttpServletResponse response;
     
     /**
-     * the public key, to store the EventProvider in the Request
-     */
-    public static final String PROVIDER = EventProviderImpl.class.getName();
-
-	private static final String KEY = PortalURL.class.getName();
-    
-    /**
      * Map that contains our events. The key is a string with the name of the event. 
-     * The value is an ArrayList with all associated PortletWindows.
+     * The value is a List with all associated PortletWindows.
      * FIXME: should be in another class
      */
     private static Map<String, List<String>> portalEvts = 
@@ -81,19 +72,29 @@
     	
     /**
      * factory method
+     * gets the EventProvider out of the Request, or sets a new one
+     * @param request The {@link HttpServletRequest} of the EventProvider
+     * @param response The {@link HttpServletResponse} of the EventProvider
+     * @return The corresponding EventProvierImpl instance
      */
     public static EventProviderImpl getEventProviderImpl(HttpServletRequest request,
     		HttpServletResponse response) {
-    	EventProviderImpl event = (EventProviderImpl) request.getAttribute(PROVIDER);
+    	EventProviderImpl event = (EventProviderImpl) request.getAttribute(Constants.PROVIDER);
     	if (event == null) {
     		event = new EventProviderImpl();
     		event.request = request;
     		event.response = response;
-    		request.setAttribute(PROVIDER, event);
+    		request.setAttribute(Constants.PROVIDER, event);
     	}
     	return event;
     }
     
+    /**
+     * factory method, for accessing the static elements without a
+     * request / response
+     * FIXME: bad idea 
+     * @return The EventProvider for accessing the static elements
+     */
     public static EventProvider getEventProviderImpl() {
 		return new EventProviderImpl();
 	}
@@ -106,7 +107,7 @@
     }
     
     /**
-     * Register an event, which should be fired
+     * Register an event, which should be fired within that request
      * @param event
      * @throws {@link IOException} 
      * @throws {@link ServletException} 
@@ -115,18 +116,13 @@
      */
     public void registerToFireEvent(Event event) 
     throws ServletException, IOException, PortletException, PortletContainerException {
-    	
-    	includeEventInRequest(event);
     	savedEvents.add(event);	
     }
-    
-    private void includeEventInRequest(Event event){
-    	this.request.setAttribute(Constants.PORTLET_EVENT, event);
-    }
 
 	/**
+	 * Get all Portlets, which are registered to this event
      * @param evtLabel	- the name of the event
-     * @return ArrayList of associated InternalPortletWindows
+     * @return String list of associated InternalPortletWindows
      */
     public List<String> getAllPortletNames(String evtLabel) {
     	return portalEvts.get(evtLabel);
@@ -209,7 +205,7 @@
 
     /**
      * 
-     * @return Enumeration containing all events
+     * @return String enumeration containing all events
      */
     public Enumeration<String> getAllEventLabelsEnumeration () {
     	Vector<String> v = new Vector<String>();
@@ -222,7 +218,7 @@
     
     /**
      * 
-     * @return ArrayList containing all events
+     * @return String list containing all events
      */
     public List<String> getAllEventLabelsList () {
     	List<String> l = new ArrayList<String>();
@@ -262,6 +258,11 @@
 		this.savedEvents = savedEvents;
 	}
 
+	/**
+	 * Fire all saved events
+	 * Note, that the order isn't important @see PLT14.3.2 
+	 * @param eventContainer The {@link PortletContainerImpl} to fire the events
+	 */
 	public void fireEvents(EventContainer eventContainer) {
 		ServletContext servletContext = eventContainer.getServletContext();
 		DriverConfiguration driverConfig = (DriverConfiguration) servletContext.getAttribute(
@@ -269,15 +270,8 @@
 
 		PortalURL portalURL = PortalURLParserImpl.getParser().parse(request);
 
-		try {
-			InternalPortletContext portletContext = PortletContextManager.getManager()
-				.getPortletContext(servletContext);
-			portletContext.getPortletApplicationDefinition();
-		} catch (PortletContainerException ex) {
-			ex.printStackTrace();
-		}
-		
 		PageConfig pageConfig = portalURL.getPageConfig(servletContext); 
+		
 		// iterate all portlets on the page
         for (Object object : pageConfig.getPortletIds()) {
         	String portletId = (String) object;
@@ -293,7 +287,8 @@
             	for (String portlet : portletNames) {
             		if (portlet.equals(portletId)){
             			try {
-							eventContainer.fireEvent(this.request,this.response,window);
+							eventContainer.fireEvent(this.request,this.response,
+									window,event.getName());
 						} catch (PortletException e) {
 							// TODO Auto-generated catch block
 							e.printStackTrace();

Modified: portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java?view=diff&rev=473305&r1=473304&r2=473305
==============================================================================
--- portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
(original)
+++ portals/pluto/branches/1.1-286-COMPATIBILITY/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
Fri Nov 10 02:35:32 2006
@@ -31,10 +31,8 @@
 import org.apache.pluto.PortletContainer;
 import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.PortletWindow;
-import org.apache.pluto.core.PortletContextManager;
 import org.apache.pluto.descriptors.portlet.EventDD;
 import org.apache.pluto.descriptors.portlet.PortletDD;
-import org.apache.pluto.descriptors.portlet.RenderDD;
 import org.apache.pluto.driver.config.DriverConfiguration;
 import org.apache.pluto.driver.core.PortalRequestContext;
 import org.apache.pluto.driver.core.PortletWindowImpl;
@@ -42,7 +40,6 @@
 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
 import org.apache.pluto.driver.services.portal.SupportedModesService;
 import org.apache.pluto.driver.url.PortalURL;
-import org.apache.pluto.internal.InternalPortletContext;
 import org.apache.pluto.internal.InternalPortletWindow;
 import org.apache.pluto.spi.EventProvider;
 import org.springframework.context.ApplicationContext;
@@ -55,6 +52,7 @@
  * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
  * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
  * @author <a href="mailto:esm@apache.org">Elliot Metsger</a>
+ * @author <a href="mailto:chrisra@cs.uni-jena.de">Christian Raschka</a>
  * @version 1.0
  * @since Sep 22, 2004
  */
@@ -169,7 +167,7 @@
         	if (LOG.isDebugEnabled()) {
         		LOG.debug("Processing render request.");
         	}
-            PageConfig pageConfig = getPageConfig(portalURL);
+            PageConfig pageConfig = portalURL.getPageConfig(servletContext);
             if (pageConfig == null)
             {
                 LOG.error("PageConfig for render path [" + portalURL.getRenderPath() + "]
could not be found.");
@@ -207,15 +205,6 @@
     // Private Methods ---------------------------------------------------------
     
     private void registerPortlets(PageConfig pageConfig, PortalURL portalURL) throws ServletException
{
-    	// Retrieve the associated internal portlet context.
-		try {
-			InternalPortletContext portletContext = PortletContextManager.getManager()
-				.getPortletContext(getServletContext());
-			portletContext.getPortletApplicationDefinition();
-		} catch (PortletContainerException ex) {
-			ex.printStackTrace();
-            throw new ServletException(ex);
-		}
 		
 		// iterate all portlets on the page
         for (Object object : pageConfig.getPortletIds()) {
@@ -235,23 +224,29 @@
             List<EventDD> events = portletDD.getProcessingEvents();
             for (EventDD eventDD : events) {
 				eventProvider.registerEvent(eventDD.getName(),window.getId().getStringId());
-				LOG.debug(eventDD.getName()+" erfolgreich registriert!");
+				if (LOG.isDebugEnabled()){
+					LOG.debug(eventDD.getName()+ " successfully registered!");
+				}
+			}
+		}
+	}
+
+	/**
+	 * registers the Events of the given portletDD at the (static) EventProvider
+	 * @param window The PortletWindow to store the event
+	 * @param portletDD The PortletDD, where the event is declared
+	 */
+	private void registerEvents(PortletWindow window, PortletDD portletDD) {
+		EventProvider eventProvider = container.getRequiredContainerServices()
+			.getPortalCallbackService().getEventProvider();
+		List<EventDD> events = portletDD.getProcessingEvents();
+		for (EventDD eventDD : events) {
+			eventProvider.registerEvent(eventDD.getName(),window.getId().getStringId());
+			if (LOG.isDebugEnabled()){
+				LOG.debug(eventDD.getName()+" registered successfully!");
 			}
 		}
 	}
-    
-    /**
-     * Returns the config of the portal page to be rendered.
-     * @param currentURL  the current portal URL.
-     * @return the config of the portal page to be rendered.
-     */
-    private PageConfig getPageConfig(PortalURL currentURL) {
-        String requestedPageId = currentURL.getRenderPath();
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Rendering Portal: Requested Page: " + requestedPageId);
-        }
-        return getDriverConfiguration().getPageConfig(requestedPageId);
-    }
     
     /**
      * Returns the portal driver configuration object.



Mime
View raw message