portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddew...@apache.org
Subject svn commit: rev 54204 - in portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto: core core/impl services
Date Sun, 10 Oct 2004 02:43:07 GMT
Author: ddewolf
Date: Sat Oct  9 19:43:07 2004
New Revision: 54204

Modified:
   portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/PortletEntity.java
   portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/ActionRequestImpl.java
   portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
   portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java
   portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/services/PortletPreferencesFactory.java
Log:
Portlet Preferences Support.

Modified: portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/PortletEntity.java
==============================================================================
--- portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/PortletEntity.java
(original)
+++ portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/PortletEntity.java
Sat Oct  9 19:43:07 2004
@@ -25,10 +25,14 @@
 import javax.servlet.ServletContext;
 
 import org.apache.pluto.PortletWindow;
+import org.apache.pluto.core.impl.PortletPreferenceImpl;
 import org.apache.pluto.binding.PortletAppDD;
 import org.apache.pluto.binding.PortletDD;
 import org.apache.pluto.binding.ServletDD;
 import org.apache.pluto.binding.XMLBindingFactory;
+import org.apache.pluto.binding.PortletPreferenceDD;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
 
 /**
  * The PortletEntity encapsulates all data pertaining to a single portlet
@@ -38,6 +42,9 @@
  * information as defined by the{@link ServletDD}
  */
 public class PortletEntity {
+    private static final Log LOG =
+        LogFactory.getLog(PortletEntity.class);
+
     private static final String PREFIX = "/PlutoInvoker/";
 
     private ServletContext ctx;
@@ -45,6 +52,7 @@
 
     //  Looked up and Cached
     private PortletDD dd;
+    private PortletPreference[] prefs;
 
     PortletEntity(ServletContext ctx, PortletWindow window) {
         this.ctx = ctx;
@@ -56,7 +64,18 @@
      * @return the preference set
      */
     public PortletPreference[] getDefaultPreferences() {
-        return null;
+        if(prefs == null) {
+            PortletDD dd = getPortletDefinition();
+            PortletPreferenceDD[] pdd = dd.getPortletPreferences();
+            prefs = new PortletPreference[pdd.length];
+            for(int i = 0;i<pdd.length;i++) {
+                prefs[i] = new PortletPreferenceImpl(
+                    pdd[i].getName(),
+                    new String[] { pdd[i].getValue()}
+                );
+            }
+        }
+        return prefs;
     }
 
     /**
@@ -72,7 +91,14 @@
     }
 
     private void load() {
-        ServletContext ctx = this.ctx.getContext(window.getContextPath());
+        String context = window.getContextPath();
+        if(LOG.isDebugEnabled()) {
+            LOG.debug("Loading PortletAppDD for context: "+context);
+        }
+        ServletContext ctx = this.ctx.getContext(context);
+        if(LOG.isDebugEnabled()) {
+            LOG.debug("Retrieved context: "+ctx);
+        }
         InputStream in = ctx.getResourceAsStream(PortletAppDD.PORTLET_XML);
         try {
             PortletAppDD appDD = XMLBindingFactory.createXMLBinding().getPortletAppDD(in);

Modified: portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/ActionRequestImpl.java
==============================================================================
--- portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/ActionRequestImpl.java
(original)
+++ portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/ActionRequestImpl.java
Sat Oct  9 19:43:07 2004
@@ -28,6 +28,8 @@
 import org.apache.pluto.Constants;
 import org.apache.pluto.PortletContainer;
 import org.apache.pluto.core.InternalPortletWindow;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
 
 /**
  * To change this generated comment edit the template variable "typecomment":
@@ -36,6 +38,8 @@
  */
 public class ActionRequestImpl
     extends PortletRequestImpl implements ActionRequest {
+
+    private static final Log LOG = LogFactory.getLog(ActionRequestImpl.class);
     /**
      * Holds the portlet preferences
      */
@@ -45,6 +49,8 @@
                              InternalPortletWindow internalPortletWindow,
                              HttpServletRequest servletRequest) {
         super(container, internalPortletWindow, servletRequest);
+        LOG.debug("Created action request for: "+internalPortletWindow);
+
     }
 
     // javax.portlet.ActionRequest implementation -------------------------------------------------
@@ -69,6 +75,7 @@
     // PortletRequestImpl implementation ----------------------------------------------------------
     public PortletPreferences getPreferences() {
         if (this.portletPreferences == null) {
+            InternalPortletWindow window = getWindow();
             portletPreferences = new PortletPreferencesImpl(getContainer(),
                                                             getWindow(), this,
                                                             Constants.METHOD_ACTION);

Modified: portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
==============================================================================
--- portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
(original)
+++ portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletPreferencesImpl.java
Sat Oct  9 19:43:07 2004
@@ -32,13 +32,18 @@
 
 import org.apache.pluto.Constants;
 import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.core.InternalPortletRequest;
 import org.apache.pluto.core.InternalPortletWindow;
 import org.apache.pluto.core.PortletPreference;
+import org.apache.pluto.core.PortletEntity;
 import org.apache.pluto.services.PortletPreferencesFactory;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
 
 
 public class PortletPreferencesImpl implements PortletPreferences {
+    private static final Log LOG = LogFactory.getLog(PortletPreferencesImpl.class);
 
     private PortletPreferencesFactory factory;
 
@@ -65,20 +70,25 @@
 
         this.preferences = new java.util.HashMap();
 
-        PortletPreference[] prefs
-            = window.getPortletEntity().getDefaultPreferences();
+        PortletEntity entity = window.getPortletEntity();
+        PortletPreference[] prefs = entity.getDefaultPreferences();
 
         for (int i = 0; i < prefs.length; i++) {
-            preferences.put(prefs[i].getName(), prefs);
+            preferences.put(prefs[i].getName(), prefs[i]);
         }
 
         PortletPreferencesFactory factory
             = container.getContainerServices().getPortletPreferencesFactory();
 
-        prefs = factory.getStoredPreferences(window, request);
+        try {
+            prefs = factory.getStoredPreferences(window, request);
+        }
+        catch(PortletContainerException pe) {
+            LOG.error("Error retrieving preferences.", pe);
+        }
 
         for (int i = 0; i < prefs.length; i++) {
-            preferences.put(prefs[i].getName(), prefs);
+            preferences.put(prefs[i].getName(), prefs[i]);
         }
 
     }
@@ -167,7 +177,7 @@
         Map map = new java.util.HashMap();
         Iterator it = preferences.keySet().iterator();
         while (it.hasNext()) {
-            PortletPreference pref = (PortletPreference) it.next();
+            PortletPreference pref = (PortletPreference)preferences.get(it.next());
             map.put(pref.getName(), pref.getValues());
         }
         return Collections.unmodifiableMap(map);
@@ -184,16 +194,20 @@
                 "preference attribute called " + key + " may not be modified");
         }
 
-        PortletPreference preference = factory.getStoredPreference(window,
-                                                                   request,
-                                                                   key);
-        preferences.put(preference.getName(), preference);
+        // I think we should remove all preferences which are stored --
+        // NOT reset them to how they were stored before!
+        /*
+        PortletPreference[] preferences = factory.getStoredPreferences(window, request);
+        for(int i=0;i<preferences.length;i++) {
+            preferences.put(preference.getName(), preference);
+        }
+         */
 
     }
 
     public void store() throws java.io.IOException, ValidatorException {
         // not allowed when not called in action
-        if (!Constants.METHOD_ID.equals(methodId)) {
+        if (!Constants.METHOD_ACTION.equals(methodId)) {
             throw new java.lang.IllegalStateException(
                 "store is only allowed inside a processAction call");
         }
@@ -220,7 +234,12 @@
             (PortletPreference[]) preferences.values().toArray(
                 new PortletPreference[preferences.size()]);
 
-        factory.store(pref);
+        try {
+            factory.store(window, request, pref);
+        }
+        catch(PortletContainerException pe) {
+            LOG.error("Error storing preferences.", pe);
+        }
     }
     // --------------------------------------------------------------------------------------------
 

Modified: portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java
==============================================================================
--- portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java
(original)
+++ portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/core/impl/PortletRequestImpl.java
Sat Oct  9 19:43:07 2004
@@ -19,7 +19,6 @@
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
@@ -40,7 +39,6 @@
 import org.apache.pluto.core.InternalPortletRequest;
 import org.apache.pluto.core.InternalPortletWindow;
 import org.apache.pluto.core.PortletEntity;
-import org.apache.pluto.services.DynamicInformationProvider;
 import org.apache.pluto.services.PropertyManagerService;
 import org.apache.pluto.util.Enumerator;
 import org.apache.pluto.util.NamespaceMapper;
@@ -83,7 +81,6 @@
     /** Response content types. */
     private Vector contentTypes;
 
-    private DynamicInformationProvider provider;
     private NamespaceMapper mapper = new NamespaceMapperImpl();
 
     /**
@@ -102,9 +99,6 @@
         super(servletRequest);
         this.container = container;
         this.internalPortletWindow = internalPortletWindow;
-        this.provider =
-        container.getContainerServices().getDynamicInformationProvider(
-            servletRequest);
         this.portalContext =
         container.getContainerServices().getPortalContext();
 

Modified: portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/services/PortletPreferencesFactory.java
==============================================================================
--- portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/services/PortletPreferencesFactory.java
(original)
+++ portals/pluto/branches/pluto-1.1/container/src/java/org/apache/pluto/services/PortletPreferencesFactory.java
Sat Oct  9 19:43:07 2004
@@ -19,22 +19,21 @@
 
 package org.apache.pluto.services;
 
-import java.io.IOException;
-
 import javax.portlet.PortletRequest;
 
 import org.apache.pluto.PortletWindow;
+import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.core.PortletPreference;
 
 public interface PortletPreferencesFactory {
 
     PortletPreference[] getStoredPreferences(PortletWindow window,
-                                             PortletRequest req);
-
-    PortletPreference getStoredPreference(PortletWindow window,
-                                          PortletRequest req,
-                                          String preferenceName);
+                                             PortletRequest req)
+        throws PortletContainerException;
 
-    void store(PortletPreference[] preferences) throws IOException;
+    void store(PortletWindow window,
+               PortletRequest req,
+               PortletPreference[] preferences)
+        throws PortletContainerException;
 
 }

Mime
View raw message