You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by es...@apache.org on 2006/09/10 22:39:04 UTC

svn commit: r442003 - /portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java

Author: esm
Date: Sun Sep 10 13:39:03 2006
New Revision: 442003

URL: http://svn.apache.org/viewvc?view=rev&rev=442003
Log:
Configured exceptions to be logged prior to being thrown. 
Updated to use the PortletContainer.getPortletApplicationDescription(contextPath) method.

Modified:
    portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java

Modified: portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java?view=diff&rev=442003&r1=442002&r2=442003
==============================================================================
--- portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java (original)
+++ portals/pluto/trunk/pluto-portal-driver-impl/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletRegistryServiceImpl.java Sun Sep 10 13:39:03 2006
@@ -15,19 +15,25 @@
  */
 package org.apache.pluto.driver.services.impl.resource;
 
-import org.apache.pluto.driver.config.DriverConfigurationException;
-import org.apache.pluto.driver.services.portal.*;
-import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
-import org.apache.pluto.driver.services.portal.admin.DriverAdministrationException;
-import org.apache.pluto.descriptors.portlet.PortletAppDD;
-import org.apache.pluto.descriptors.portlet.PortletDD;
-import org.apache.pluto.internal.PortletDescriptorRegistry;
-import org.apache.pluto.PortletContainerException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Set;
 
 import javax.servlet.ServletContext;
-import java.util.Set;
-import java.util.Iterator;
-import java.io.InputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.portlet.PortletDD;
+import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.driver.config.DriverConfigurationException;
+import org.apache.pluto.driver.services.portal.PortletApplicationConfig;
+import org.apache.pluto.driver.services.portal.PortletRegistryService;
+import org.apache.pluto.driver.services.portal.PortletWindowConfig;
+import org.apache.pluto.driver.services.portal.admin.DriverAdministrationException;
+import org.apache.pluto.driver.services.portal.admin.PortletRegistryAdminService;
 
 /**
  * Implementation of <code>PortletRegistryService</code> and
@@ -40,9 +46,10 @@
 public class PortletRegistryServiceImpl
 implements PortletRegistryService, PortletRegistryAdminService {
 
+    private static final Log LOG = LogFactory.getLog(PortletRegistryServiceImpl.class);
     private ResourceConfig config;
     private ServletContext servletContext;
-    
+    private PortletContainer container;
     
     // Constructor -------------------------------------------------------------
     
@@ -70,6 +77,7 @@
         } catch (Exception ex) {
             throw new DriverConfigurationException(ex);
         }
+
     }
 
     public void destroy() throws DriverConfigurationException {
@@ -108,19 +116,23 @@
 
             ServletContext portletAppServletContext = servletContext.getContext(contextPath);
             if (portletAppServletContext == null) {
-                throw new DriverAdministrationException(
-                		"Unable to locate servlet context: " + contextPath
-                		+ ": ensure that crossContext support is enabled "
-                		+ "and the portlet application has been deployed.");
+                final String msg = "Unable to locate servlet context: " + contextPath                    
+                    + ": ensure that crossContext support is enabled "
+                    + "and the portlet application has been deployed.";
+                LOG.error(msg);
+                throw new DriverAdministrationException(msg);
             }
-
-            PortletAppDD portletAppDD = getPortletDescriptor(
-            		portletAppServletContext);
+            
+            PortletContainer container = (PortletContainer)servletContext
+                .getAttribute(AttributeKeys.PORTLET_CONTAINER);
+            PortletAppDD portletAppDD = container.getPortletApplicationDescriptor(contextPath);
+            
             if (portletAppDD == null) {
-            	throw new DriverAdministrationException(
-            			"Unable to retrieve portlet application descriptor from "
-            			+ contextPath + ": ensure that the portlet application "
-            			+ "has been deployed.");
+                final String msg = "Unable to retrieve portlet application descriptor from "
+                    + contextPath + ": ensure that the portlet application "
+                    + "has been deployed.";
+                LOG.error(msg);
+            	throw new DriverAdministrationException(msg);
             }
             for (Iterator it = portletAppDD.getPortlets().iterator();
             		it.hasNext(); ) {
@@ -133,8 +145,9 @@
             config.addPortletApp(portletAppConfig);
             
         } catch (PortletContainerException ex) {
-            throw new DriverAdministrationException(
-            		"Unable to add portlet application from " + contextPath, ex);
+            final String msg = "Unable to add portlet application from " + contextPath;
+            LOG.error(msg);
+            throw new DriverAdministrationException(msg, ex);
         }
     }
     
@@ -144,13 +157,5 @@
     public PortletWindowConfig getPortletWindowConfig(String id) {
         return config.getPortletWindowConfig(id);
     }
-    
-    
-    // Private Methods ---------------------------------------------------------
-    
-    private PortletAppDD getPortletDescriptor(ServletContext context)
-    throws PortletContainerException {
-        return PortletDescriptorRegistry.getRegistry().getPortletAppDD(context);
-    }
-    
+            
 }