You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/08/30 22:11:45 UTC

svn commit: r264845 - /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java

Author: cziegeler
Date: Tue Aug 30 13:11:41 2005
New Revision: 264845

URL: http://svn.apache.org/viewcvs?rev=264845&view=rev
Log:
Start using pluto descriptors

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java?rev=264845&r1=264844&r2=264845&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java Tue Aug 30 13:11:41 2005
@@ -17,6 +17,7 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -44,6 +45,12 @@
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.xml.EntityResolver;
+import org.apache.pluto.descriptors.portlet.PortletAppDD;
+import org.apache.pluto.descriptors.services.PortletAppDescriptorService;
+import org.apache.pluto.descriptors.services.WebAppDescriptorService;
+import org.apache.pluto.descriptors.services.impl.FilePortletAppDescriptorServiceImpl;
+import org.apache.pluto.descriptors.services.impl.FileWebAppDescriptorServiceImpl;
+import org.apache.pluto.descriptors.servlet.WebAppDD;
 import org.apache.pluto.om.common.ObjectID;
 import org.apache.pluto.om.entity.PortletApplicationEntityList;
 import org.apache.pluto.om.entity.PortletApplicationEntityListCtrl;
@@ -93,14 +100,14 @@
     /** The entity resolver */
     protected EntityResolver resolver;
     
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
     public void contextualize(Context context) throws ContextException {
         this.context = context;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) 
@@ -109,7 +116,7 @@
         this.resolver = (EntityResolver) this.manager.lookup(EntityResolver.ROLE);
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
     public void dispose() {
@@ -121,12 +128,14 @@
         this.context = null;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
     public void initialize() throws Exception {
-        this.getLogger().debug("Initializing PortletDefinitionRegistry");
-        ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
+        if ( this.getLogger().isDebugEnabled() ) {
+            this.getLogger().debug("Initializing Portlet Definition Registry");
+        }
+        ServletConfig servletConfig = (ServletConfig) this.context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
         
         ServletContext servletContext = servletConfig.getServletContext();
 
@@ -178,7 +187,7 @@
             }
 
         } catch (Exception e) {
-            e.printStackTrace();
+            this.getLogger().error("Error during initialization of registry.", e);
         } finally {
             this.manager.release(resolver);
         } 
@@ -186,10 +195,16 @@
         ((PortletApplicationEntityListCtrl)this.portletApplicationEntities).add("cocoon");
     }
 
+    /**
+     * @see org.apache.cocoon.portal.pluto.om.PortletDefinitionRegistry#getPortletApplicationDefinitionList()
+     */
     public PortletApplicationDefinitionList getPortletApplicationDefinitionList() {
         return registry;
     }
 
+    /**
+     * @see org.apache.cocoon.portal.pluto.om.PortletDefinitionRegistry#getPortletDefinition(org.apache.pluto.om.common.ObjectID)
+     */
     public PortletDefinition getPortletDefinition(ObjectID id) {
         return (PortletDefinition)portletsKeyObjectId.get(id);
     }
@@ -313,6 +328,40 @@
         }
     }
 
+    private void loadWebApp(String baseDir,
+                            String webModule) {
+        final File directory = new File(baseDir + webModule);
+        if (this.getLogger().isDebugEnabled()) {
+            this.getLogger().debug("Searching in directory: " + directory);
+        }
+        PortletAppDescriptorService descService = new FilePortletAppDescriptorServiceImpl(directory);
+        
+        try {
+            PortletAppDD portletApp = descService.read();
+            // if there is no portlet.xml, a dummy app is created containing no portlets
+            if ( portletApp.getPortlets().size() > 0 ) {
+                if ( this.getLogger().isDebugEnabled() ) {
+                    this.getLogger().debug("Found portlet descriptor in directory " + directory);
+                }
+                WebAppDescriptorService waService = new FileWebAppDescriptorServiceImpl(directory);
+                try {
+                    WebAppDD webApp = waService.read();
+                    if ( this.getLogger().isDebugEnabled() ) {
+                        this.getLogger().debug("Found web descriptor in directory " + directory);
+                    }
+                    // TODO map this to pluto OM
+                } catch (IOException io) {
+                    this.getLogger().error("Error reading web descriptor in directory " + directory, io);
+                    return;
+                }
+            }
+        } catch (IOException io) {
+            this.getLogger().error("Error reading portlet descriptor in directory " + directory, io);
+            return;
+        }
+        
+    }
+
     private void load(InputSource portletXml, InputSource webXml, String webModule,
                       Mapping portletXMLMapping, Mapping webXMLMapping) throws Exception {
         if (this.getLogger().isDebugEnabled()) {
@@ -383,7 +432,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.pluto.om.PortletDefinitionRegistry#getPortletApplicationEntityList()
      */
     public PortletApplicationEntityList getPortletApplicationEntityList() {