portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r709788 - in /portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade: components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/ components/jetspeed-registry/src/main/java/org/apache/jetspeed/compone...
Date Sat, 01 Nov 2008 22:13:34 GMT
Author: taylor
Date: Sat Nov  1 15:13:32 2008
New Revision: 709788

URL: http://svn.apache.org/viewvc?rev=709788&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-871
Implement default (portlet) preferences loading upon registration. I hope this is a lot easier
to understand than the way the old prefs got loaded

We are actually getting rendered content on 2 portlets: the weather portlet, and iframes!
Still seeing tag library problems with JSPs (have not had time to look into that)
One thing needs patching in Pluto to get this to work:

PortletRequestImpl.java:

   public PortletSession getPortletSession(boolean create) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Retreiving portlet session (create=" + create + ")");
        }
        //
        // It is critical that we don't retrieve the portlet session until the
        //   cross context dispatch has been completed.  If we do then we risk
        //   having a cached version which is invalid for the context within
        //   which it exists.
        //
//DST:        if (portletContext == null) {
//            throw new IllegalStateException(
//                    EXCEPTIONS.getString("error.session.illegalState"));
//        }

we no longer are tracking contexts, so we need to decide if we want to do that or not
also see JetspeedPortletContainer.java, the renderRequest.init() call that is commented out


Added:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferenceImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferencesImpl.java
Modified:
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletDefinition.java
    portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedContainerServlet.java

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/DatabasePreference.java
Sat Nov  1 15:13:32 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jetspeed.components.portletpreferences;
 
+import java.util.ArrayList;
 import java.util.Collection;
 
 /**
@@ -118,6 +119,10 @@
 
     public Collection<DatabasePreferenceValue> getPreferenceValues()
     {
+        if (values == null)
+        {
+            values = new ArrayList<DatabasePreferenceValue>();
+        }
         return values;
     }
 

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
Sat Nov  1 15:13:32 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jetspeed.components.portletpreferences;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -33,6 +34,7 @@
 import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.container.PortletWindow;
 import org.apache.jetspeed.factory.PortletFactory;
+import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.Preference;
 import org.apache.jetspeed.om.portlet.Preferences;
 import org.apache.jetspeed.om.preference.FragmentPreference;
@@ -113,42 +115,15 @@
             throws PortletContainerException
     {
         PortletWindow window = (PortletWindow)pw;
-        String appName = window.getPortletEntity().getPortletDefinition().getApplication().getName();
-        String portletName = window.getPortletEntity().getPortletDefinition().getPortletName();
       
+        org.apache.jetspeed.om.portlet.PortletDefinition pd = window.getPortletEntity().getPortletDefinition();
         String entityId = window.getPortletEntity().getId();
-        String defaultsCacheKey = getPorletPreferenceKey(appName, portletName);
-        JetspeedPreferencesMap defaultsMap;         
-        // first search in cache        
-        CacheElement cachedDefaults = preferenceCache.get(defaultsCacheKey);        
-        if (cachedDefaults != null)
-        {
-            defaultsMap = (JetspeedPreferencesMap)cachedDefaults.getContent();
-        }            
-        else
-        {
-            // not found in cache, lookup in database
-            JetspeedPreferencesMap map = new JetspeedPreferencesMap(); 
-            Criteria c = new Criteria();
-            c.addEqualTo("dtype", DISCRIMINATOR_PORTLET);
-            c.addEqualTo("applicationName", appName);
-            c.addEqualTo("portletName", portletName);                
-            QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c);
-            Iterator<DatabasePreference> preferences = getPersistenceBrokerTemplate().getIteratorByQuery(query);
-            while (preferences.hasNext())
-            {
-                DatabasePreference preference = preferences.next();            
-                JetspeedPreferenceImpl value = new JetspeedPreferenceImpl(preference.getName(),
preference.getValues());
-                value.setReadOnly(preference.isReadOnly());
-                map.put(preference.getName(), value);
-            }
-            preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map));
-            defaultsMap = map;
-        }
-        
+        Map<String, InternalPortletPreference> defaultsMap = this.getDefaultPreferences(pd);
         // retrieve entity preferences
         if (useEntityPreferences)
         {
             JetspeedPreferencesMap entityMap = null;
+            String appName = pd.getApplication().getName();
+            String portletName = pd.getPortletName();
             String entityCacheKey = this.getEntityPreferenceKey(appName, portletName, entityId);
             CacheElement cachedEntity = preferenceCache.get(entityCacheKey);        
             if (cachedEntity != null)
@@ -442,7 +417,9 @@
     
     public void storeDefaults(org.apache.jetspeed.om.portlet.PortletDefinition pd)
     {
-        Preferences preferences = pd.getPortletPreferences();
+        Preferences preferences = pd.getDescriptorPreferences();
+        String defaultsCacheKey = getPorletPreferenceKey(pd.getApplication().getName(), pd.getPortletName());
           
+        JetspeedPreferencesMap map = new JetspeedPreferencesMap(); 
         for (Preference preference : preferences.getPortletPreferences())
         {
             DatabasePreference dbPref = new DatabasePreference();
@@ -459,17 +436,23 @@
                 DatabasePreferenceValue dbValue = new DatabasePreferenceValue();
                 dbValue.setIndex(index);
                 dbValue.setValue(value);
+                dbPref.getPreferenceValues().add(dbValue);
                 index++;
-            }
+                
+            }                       
+            JetspeedPreferenceImpl cached = new JetspeedPreferenceImpl(dbPref.getName(),
dbPref.getValues());
+            cached.setReadOnly(dbPref.isReadOnly());
+            map.put(preference.getName(), cached);
             getPersistenceBrokerTemplate().store(dbPref);
-            
         }
+        preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map));      
             
     }
 
     public  Map<String, InternalPortletPreference>  retrieveEntityPreferences(PortletWindow
window, PortletRequest request)
     {
         // TODO: 2.2 implement - need to better look at use cases for edit defaults mode
-        return new JetspeedPreferencesMap(); 
+        // we are currently not storing entity preferences in the database. 
+        throw new UnsupportedOperationException();
     }
     
     public void storeEntityPreferences(PortletWindow pw, PortletRequest request,
@@ -477,6 +460,69 @@
             throws PortletContainerException
     {
         // TODO: 2.2 implement - need to better look at use cases for edit defaults mode
+        // we are currently not storing entity preferences in the database. 
+        throw new UnsupportedOperationException();
+    }
+
+
+    public void removeDefaults(org.apache.jetspeed.om.portlet.PortletDefinition pd)
+    {
+        Criteria c = new Criteria();
+        c.addEqualTo("dtype", DISCRIMINATOR_PORTLET);
+        c.addEqualTo("applicationName", pd.getApplication().getName());
+        c.addEqualTo("portletName", pd.getPortletName());                
+        QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c);
+        getPersistenceBrokerTemplate().deleteByQuery(query);
+        String defaultsCacheKey = getPorletPreferenceKey(pd.getApplication().getName(), pd.getPortletName());
           
+        preferenceCache.remove(defaultsCacheKey);
     }
 
+
+    public void removeDefaults(PortletApplication app)
+    {
+        Criteria c = new Criteria();
+        c.addEqualTo("dtype", DISCRIMINATOR_PORTLET);
+        c.addEqualTo("applicationName", app.getName());
+        QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c);
+        getPersistenceBrokerTemplate().deleteByQuery(query);
+        for (PortletDefinition pd : app.getPortlets())
+        {
+            String defaultsCacheKey = getPorletPreferenceKey(pd.getApplication().getName(),
pd.getPortletName());            
+            preferenceCache.remove(defaultsCacheKey);            
+        }
+    }
+
+    public Map<String, InternalPortletPreference> getDefaultPreferences(org.apache.jetspeed.om.portlet.PortletDefinition
pd)
+    {
+        String appName = pd.getApplication().getName();
+        String portletName = pd.getPortletName();        
+        String defaultsCacheKey = getPorletPreferenceKey(appName, portletName);
+        JetspeedPreferencesMap defaultsMap;         
+        // first search in cache        
+        CacheElement cachedDefaults = preferenceCache.get(defaultsCacheKey);        
+        if (cachedDefaults != null)
+        {
+            defaultsMap = (JetspeedPreferencesMap)cachedDefaults.getContent();
+        }            
+        else
+        {
+            // not found in cache, lookup in database
+            JetspeedPreferencesMap map = new JetspeedPreferencesMap(); 
+            Criteria c = new Criteria();
+            c.addEqualTo("dtype", DISCRIMINATOR_PORTLET);
+            c.addEqualTo("applicationName", appName);
+            c.addEqualTo("portletName", portletName);                
+            QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c);
+            Collection<DatabasePreference> preferences = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+            for (DatabasePreference preference : preferences)
+            {
+                JetspeedPreferenceImpl value = new JetspeedPreferenceImpl(preference.getName(),
preference.getValues());
+                value.setReadOnly(preference.isReadOnly());
+                map.put(preference.getName(), value);
+            }
+            preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map));
+            defaultsMap = map;
+        }
+        return defaultsMap;
+    }
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
Sat Nov  1 15:13:32 2008
@@ -18,14 +18,13 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.jetspeed.cache.JetspeedCache;
 import org.apache.jetspeed.cache.JetspeedCacheEventListener;
 import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
+import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
 import org.apache.jetspeed.om.common.Support;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
@@ -33,7 +32,6 @@
 import org.apache.jetspeed.om.portlet.impl.PortletDefinitionImpl;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.QueryFactory;
-import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 import org.springframework.dao.DataAccessException;
 
 /**
@@ -62,13 +60,13 @@
     private JetspeedCache portletOidCache = null;
     private JetspeedCache applicationNameCache = null;
     private JetspeedCache portletNameCache = null;
-    private Map nameCache = new HashMap(); // work in progress (switch to JetspeedCache)
     private List<RegistryEventListener> listeners = new ArrayList<RegistryEventListener>();
+    private PortletPreferencesProvider preferenceService;
     
     // for testing purposes only: no need for the portletFactory then
-    public PersistenceBrokerPortletRegistry(String repositoryPath)
+    public PersistenceBrokerPortletRegistry(String repositoryPath, PortletPreferencesProvider
preferenceService)
     {
-        this(repositoryPath, null, null, null, null);
+        this(repositoryPath, null, null, null, null, preferenceService);
     }
     
     /**
@@ -76,7 +74,7 @@
      */
     public PersistenceBrokerPortletRegistry(String repositoryPath,
             JetspeedCache applicationOidCache, JetspeedCache portletOidCache, 
-            JetspeedCache applicationNameCache, JetspeedCache portletNameCache)
+            JetspeedCache applicationNameCache, JetspeedCache portletNameCache, PortletPreferencesProvider
preferenceService)
     {
         super(repositoryPath);
         this.applicationOidCache = applicationOidCache;
@@ -88,12 +86,13 @@
         RegistryPortletCache.cacheInit(this, portletOidCache, portletNameCache, listeners);
         this.applicationNameCache.addEventListener(this, false);
         this.portletNameCache.addEventListener(this, false);        
+        this.preferenceService = preferenceService;
     }
     
-    public Collection getAllPortletDefinitions()
+    public Collection<PortletDefinition> getAllPortletDefinitions()
     {
         Criteria c = new Criteria();
-        Collection list = getPersistenceBrokerTemplate().getCollectionByQuery(
+        Collection<PortletDefinition> list = getPersistenceBrokerTemplate().getCollectionByQuery(
                 QueryFactory.newQuery(PortletDefinitionImpl.class, c));
         postLoadColl(list);
         return list;
@@ -109,10 +108,10 @@
         return app;
     }
 
-    public Collection getPortletApplications()
+    public Collection<PortletApplication> getPortletApplications()
     {
         Criteria c = new Criteria();
-        Collection list = getPersistenceBrokerTemplate().getCollectionByQuery(
+        Collection<PortletApplication> list = getPersistenceBrokerTemplate().getCollectionByQuery(
                 QueryFactory.newQuery(PortletApplicationDefinitionImpl.class, c));
         postLoadColl(list);
         return list;
@@ -124,11 +123,10 @@
         String portletName = PortletRegistryHelper.parsePortletName(name);
 
         Criteria c = new Criteria();
-    // TODO: 2.2 something failing here    c.addEqualTo("app.name", appName);
+// TODO: 2.2 Fix me        c.addEqualTo("app.name", appName);
         c.addEqualTo("name", portletName);
-
         PortletDefinition def = (PortletDefinition) getPersistenceBrokerTemplate().getObjectByQuery(
-                QueryFactory.newQuery(PortletDefinitionImpl.class, c));
+        QueryFactory.newQuery(PortletDefinitionImpl.class, c));
         if (def != null && def.getApplication() == null)
         {
             final String msg = "getPortletDefinitionByIdentifier() returned a PortletDefinition
that has no parent PortletApplication.";
@@ -149,19 +147,19 @@
         return getPortletDefinitionByUniqueName(app.getName() + "::" + portletName) != null;
     }
 
-    public void registerPortletApplication( PortletApplicationDefinition newApp ) throws
RegistryException
+    public void registerPortletApplication(PortletApplication newApp) throws RegistryException
     {
         getPersistenceBrokerTemplate().store(newApp);
+        this.preferenceService.storeDefaults(newApp);
     }
 
-    public void removeApplication( PortletApplicationDefinition app ) throws RegistryException
+    public void removeApplication(PortletApplication app) throws RegistryException
     {
         getPersistenceBrokerTemplate().delete(app);
-        
-        // TODO: remove PortletPreferences and then what scope: everything (default, global
and entity prefs) or only default (portlet scope)?
+        this.preferenceService.removeDefaults(app);
     }
 
-    public void updatePortletApplication( PortletApplicationDefinition app ) throws RegistryException
+    public void updatePortletApplication(PortletApplication app) throws RegistryException
     {
         getPersistenceBrokerTemplate().store(app);
 

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/descriptor/JetspeedDescriptorServiceImpl.java
Sat Nov  1 15:13:32 2008
@@ -46,6 +46,7 @@
 import org.apache.jetspeed.om.portlet.Listener;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.Preference;
 import org.apache.jetspeed.om.portlet.PublicRenderParameter;
 import org.apache.jetspeed.om.portlet.SecurityConstraint;
 import org.apache.jetspeed.om.portlet.SecurityRole;
@@ -460,6 +461,17 @@
         jpd.setExpirationCache(pd.getExpirationCache());
         jpd.setPortletClass(pd.getPortletClass());
         jpd.setResourceBundle(pd.getResourceBundle());
+        jpd.getDescriptorPreferences().setPreferencesValidator(pd.getPortletPreferences().getPreferencesValidator());
+        for (org.apache.pluto.om.portlet.Preference preference : pd.getPortletPreferences().getPortletPreferences())
+        {
+            Preference jpref = jpd.getDescriptorPreferences().addPreference(preference.getName());
+            jpref.setReadOnly(preference.isReadOnly());
+            for (String value : preference.getValues())
+            {
+                jpref.addValue(value);
+            }
+            
+        }        
         for (org.apache.pluto.om.portlet.ContainerRuntimeOption cro : pd.getContainerRuntimeOptions())
         {
             ContainerRuntimeOption jcro = jpd.addContainerRuntimeOption(cro.getName());

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
Sat Nov  1 15:13:32 2008
@@ -41,10 +41,12 @@
 import org.apache.jetspeed.om.portlet.EventDefinitionReference;
 import org.apache.jetspeed.om.portlet.GenericMetadata;
 import org.apache.jetspeed.om.portlet.InitParam;
+import org.apache.jetspeed.om.portlet.Language;
 import org.apache.jetspeed.om.portlet.LocalizedField;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.om.portlet.PortletInfo;
+import org.apache.jetspeed.om.portlet.Preference;
 import org.apache.jetspeed.om.portlet.Preferences;
 import org.apache.jetspeed.om.portlet.SecurityRoleRef;
 import org.apache.jetspeed.om.portlet.Supports;
@@ -53,7 +55,7 @@
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerAware;
 import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.jetspeed.om.portlet.Language;
+import org.apache.pluto.internal.InternalPortletPreference;
 
 /**
  * 
@@ -95,7 +97,8 @@
     private List<Language> languages;
     private List<ContainerRuntimeOption> containerRuntimeOptions;    
     private List<String> supportedPublicRenderParameters;
-
+    private Preferences descriptorPreferences = new PreferencesImpl();    
+    
     private transient Map<Locale,InlinePortletResourceBundle> resourceBundles = new
HashMap<Locale, InlinePortletResourceBundle>();
     
     protected List portletEntities;
@@ -180,12 +183,33 @@
         this.portletClass = portletClass;
     }
 
+    public void setDescriptorPreferences(Preferences descriptorPreferences)
+    {
+        this.descriptorPreferences = descriptorPreferences;
+    }
+    
+    public Preferences getDescriptorPreferences()
+    {
+        return this.descriptorPreferences;
+    }
+
     public Preferences getPortletPreferences()
     {
-        // TODO Auto-generated method stub
+        if (this.portletPreferencesProvider == null)
+        {
+            
+        }
+        Map<String, InternalPortletPreference> prefMap = this.portletPreferencesProvider.getDefaultPreferences(this);
+        // TODO: 2.2 either write a new class or reuse Pluto's PortletPreferencesImpl.java
         return null;
     }
 
+    public Preference addDescriptorPreference(String name)
+    {
+        return descriptorPreferences.addPreference(name);
+    }       
+    
+    
     public ResourceBundle getResourceBundle(Locale locale)
     {
         InlinePortletResourceBundle bundle = resourceBundles.get(locale);
@@ -826,5 +850,6 @@
         edr.setName(name);
         supportedPublishingEvents.add(edr);
         return edr;
-    }       
+    }
+
 }

Added: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferenceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferenceImpl.java?rev=709788&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferenceImpl.java
(added)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferenceImpl.java
Sat Nov  1 15:13:32 2008
@@ -0,0 +1,61 @@
+/*
+ * 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.jetspeed.om.portlet.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.jetspeed.om.portlet.Preference;
+
+
+public class PreferenceImpl implements Preference
+{
+    private String name;
+    private List<String> values = new LinkedList<String>();
+    private boolean readOnly;
+
+    public PreferenceImpl(String name)
+    {
+        this.name = name;
+    }
+    
+    public void addValue(String value)
+    {
+        values.add(value);
+    }
+
+    public String getName()
+    {
+        return this.name;
+    }
+
+    public List<String> getValues()
+    {
+        return this.values;
+    }
+
+    public boolean isReadOnly()
+    {
+        return this.readOnly;
+    }
+
+    public void setReadOnly(boolean readOnly)
+    {
+        this.readOnly = readOnly;
+    }
+
+}

Added: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferencesImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferencesImpl.java?rev=709788&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferencesImpl.java
(added)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PreferencesImpl.java
Sat Nov  1 15:13:32 2008
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed 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.jetspeed.om.portlet.impl;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.jetspeed.om.portlet.Preference;
+import org.apache.jetspeed.om.portlet.Preferences;
+
+
+public class PreferencesImpl implements Preferences
+{
+    List<Preference> preferences = new LinkedList<Preference>();
+    String preferencesValidator;
+    
+    public Preference addPreference(String name)
+    {
+        Preference preference = new PreferenceImpl(name);
+        preferences.add(preference);
+        return preference;
+    }
+
+    public Preference getPortletPreference(String name)
+    {
+        for (Preference p : preferences)
+        {
+            if (p.getName().equals(name))
+                return p;
+        }
+        return null;
+    }
+
+    public List<Preference> getPortletPreferences()
+    {
+        return preferences;
+    }
+
+    public String getPreferencesValidator()
+    {
+        return this.preferencesValidator;
+    }
+
+    public void setPreferencesValidator(String validator)
+    {
+        this.preferencesValidator = validator;
+    }
+
+}

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/window/impl/PortletWindowImpl.java
Sat Nov  1 15:13:32 2008
@@ -21,6 +21,7 @@
 import javax.portlet.PortletMode;
 import javax.portlet.WindowState;
 
+import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.container.PortletEntity;
 import org.apache.jetspeed.container.PortletWindow;
 import org.apache.jetspeed.container.PortletWindowID;
@@ -121,7 +122,8 @@
 
     public PortletMode getPortletMode()
     {
-        return portletMode;
+        // TODO: 2.2 this works, but we might want to better wire things in
+        return Jetspeed.getCurrentRequestContext().getPortalURL().getNavigationalState().getMode(this);
     }
 
     public void setPortletMode(PortletMode portletMode)
@@ -131,7 +133,8 @@
 
     public WindowState getWindowState()
     {
-        return windowState;
+        // TODO: 2.2 this works, but we might want to better wire things in
+        return Jetspeed.getCurrentRequestContext().getPortalURL().getNavigationalState().getState(this);
     }
 
     public void setWindowState(WindowState windowState)

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
Sat Nov  1 15:13:32 2008
@@ -16,8 +16,11 @@
  */
 package org.apache.jetspeed.components.portletpreferences;
 
+import java.util.Map;
+
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.pluto.internal.InternalPortletPreference;
 
 
 /**
@@ -31,6 +34,7 @@
     public void preloadAllEntities();    
     public void storeDefaults(PortletDefinition pd);
     public void storeDefaults(PortletApplication app);
-    
-
+    public void removeDefaults(PortletDefinition pd);
+    public void removeDefaults(PortletApplication app);
+    public Map<String, InternalPortletPreference> getDefaultPreferences(PortletDefinition
pd);
 }

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
Sat Nov  1 15:13:32 2008
@@ -20,7 +20,6 @@
 
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
-import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 
 /**
  * <p>
@@ -93,16 +92,16 @@
      * within the Portal.          
      * @param newApp
      */
-    void registerPortletApplication( PortletApplicationDefinition newApp ) throws RegistryException;
+    void registerPortletApplication( PortletApplication newApp ) throws RegistryException;
 
-    void removeApplication( PortletApplicationDefinition app ) throws RegistryException;
+    void removeApplication( PortletApplication app ) throws RegistryException;
 
     /**
      * Makes any changes to the <code>PortletApplicationDefinition</code>
      * persistent.
      * @param app
      */
-    void updatePortletApplication( PortletApplicationDefinition app ) throws RegistryException;
+    void updatePortletApplication( PortletApplication app ) throws RegistryException;
     
     /**
      * 

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletDefinition.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletDefinition.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletDefinition.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-api/src/main/java/org/apache/jetspeed/om/portlet/PortletDefinition.java
Sat Nov  1 15:13:32 2008
@@ -41,7 +41,8 @@
     PortletInfo getPortletInfo();
 
     Preferences getPortletPreferences();
-
+    Preferences getDescriptorPreferences();
+    Preference addDescriptorPreference(String name);
     List<EventDefinitionReference> getSupportedProcessingEvents();
     EventDefinitionReference addSupportedProcessingEvent(QName qname);
     EventDefinitionReference addSupportedProcessingEvent(String name);

Modified: portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedContainerServlet.java?rev=709788&r1=709787&r2=709788&view=diff
==============================================================================
--- portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
(original)
+++ portals/jetspeed-2/portal/branches/JS2-871-pluto-2.0-upgrade/jetspeed-commons/src/main/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
Sat Nov  1 15:13:32 2008
@@ -252,9 +252,9 @@
             {
                 ActionRequest actionRequest = (ActionRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                 ActionResponse actionResponse = (ActionResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
+                // TODO: 2.2 actionRequest.init(, request);                
                 // inject the current request into the actionRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                 ((HttpServletRequestWrapper)((HttpServletRequestWrapper)actionRequest).getRequest()).setRequest(request);
-
                 portlet.processAction(actionRequest, actionResponse);
             }
             else if (method == ContainerConstants.METHOD_RENDER)
@@ -271,7 +271,9 @@
                 {
                     renderRequest = (RenderRequest) request.getAttribute(ContainerConstants.PORTLET_REQUEST);
                     renderResponse = (RenderResponse) request.getAttribute(ContainerConstants.PORTLET_RESPONSE);
-                }                
+
+                }
+                // TODO: 2.2 renderRequest.init(, request);               
                 // inject the current request into the renderRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                 ((HttpServletRequestWrapper)((HttpServletRequestWrapper)renderRequest).getRequest()).setRequest(request);
                 portlet.render(renderRequest, renderResponse);



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message