portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r771259 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/ jetspeed-api/src/main/java/org/apache/jetspeed/ jetspeed-api/src/main/java/org/apache/jetspeed/comp...
Date Mon, 04 May 2009 10:03:51 GMT
Author: woonsan
Date: Mon May  4 10:03:50 2009
New Revision: 771259

URL: http://svn.apache.org/viewvc?rev=771259&view=rev
Log:
JS2-946: Adding two methods to allow j2-admin portlet to store/remove one default preference
item.
To minimize changes, the methods are added only in the PortletPreferencesProvider.

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java?rev=771259&r1=771258&r2=771259&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
Mon May  4 10:03:50 2009
@@ -514,6 +514,57 @@
         preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map));      
             
     }
 
+    public void storeDefaults(org.apache.jetspeed.om.portlet.PortletDefinition pd, Preference
preference)
+    {
+        String appName = pd.getApplication().getName();
+        String portletName = pd.getPortletName();
+        String preferenceName = preference.getName();
+        
+        Criteria c = new Criteria();
+        c.addEqualTo("dtype", DISCRIMINATOR_PORTLET);
+        c.addEqualTo("applicationName", appName);
+        c.addEqualTo("portletName", portletName);
+        c.addEqualTo("entityId", EMPTY_VALUE);
+        c.addEqualTo("userName", EMPTY_VALUE);
+        c.addEqualTo("name", preferenceName);
+        QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c);
+        DatabasePreference dbPref = (DatabasePreference) getPersistenceBrokerTemplate().getObjectByQuery(query);
+        
+        if (dbPref == null)
+        {
+            dbPref = new DatabasePreference();
+            dbPref.setDtype(DISCRIMINATOR_PORTLET);
+            dbPref.setApplicationName(appName);
+            dbPref.setPortletName(portletName);
+            dbPref.setEntityId(EMPTY_VALUE);
+            dbPref.setUserName(EMPTY_VALUE);
+            dbPref.setName(preferenceName);
+        }
+        
+        dbPref.setReadOnly(preference.isReadOnly());
+
+        dbPref.getPreferenceValues().clear();
+        short index = 0;
+        for (String value : preference.getValues())
+        {
+            DatabasePreferenceValue dbValue = new DatabasePreferenceValue();
+            dbValue.setIndex(index);
+            dbValue.setValue(value);
+            dbPref.getPreferenceValues().add(dbValue);
+            index++;
+        }
+
+        getPersistenceBrokerTemplate().store(dbPref);
+
+        JetspeedPreferenceImpl cached = new JetspeedPreferenceImpl(preferenceName, dbPref.getValues());
+        cached.setReadOnly(dbPref.isReadOnly());
+        String defaultsCacheKey = getPorletPreferenceKey(appName, portletName);
+        CacheElement cacheElement = preferenceCache.get(defaultsCacheKey);
+        JetspeedPreferencesMap map = (cacheElement != null ? (JetspeedPreferencesMap) cacheElement.getContent()
: new JetspeedPreferencesMap());
+        map.put(preferenceName, cached);
+        preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map));
+    }
+    
     /**
      * Jetspeed: PortletPreferencesProvider
      */        
@@ -600,6 +651,22 @@
         preferenceCache.remove(defaultsCacheKey);
     }
 
+    public void removeDefaults(org.apache.jetspeed.om.portlet.PortletDefinition pd, String
preferenceName)
+    {
+        Criteria c = new Criteria();
+        c.addEqualTo("dtype", DISCRIMINATOR_PORTLET);
+        c.addEqualTo("applicationName", pd.getApplication().getName());
+        c.addEqualTo("portletName", pd.getPortletName());
+        c.addEqualTo("name", preferenceName);
+        QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c);
+        getPersistenceBrokerTemplate().deleteByQuery(query);
+        
+        String defaultsCacheKey = getPorletPreferenceKey(pd.getApplication().getName(), pd.getPortletName());
+        JetspeedPreferencesMap map = (JetspeedPreferencesMap) preferenceCache.get(defaultsCacheKey).getContent();
+        map.remove(preferenceName);
+        preferenceCache.put(preferenceCache.createElement(defaultsCacheKey, map));
+    }
+    
     /**
      * Jetspeed: PortletPreferencesProvider
      */    

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java?rev=771259&r1=771258&r2=771259&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/CommonPortletServices.java
Mon May  4 10:03:50 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.jetspeed;
 
+
 /**
  * CPS: Common Portlet Services provided by Jetspeed available to portlet applications  
  *
@@ -34,6 +35,7 @@
     public final static String CPS_SSO_COMPONENT = "cps:SSO";    
     public final static String CPS_APPLICATION_SERVER_MANAGER_COMPONENT = "cps:ApplicationServerManager";
     public final static String CPS_PORTLET_FACTORY_COMPONENT = "cps:PortletFactory";    
+    public final static String CPS_PORTLET_PREFERENCES_PROVIDER = "cps:PortletPreferencesProvider";
     public final static String CPS_DEPLOYMENT_MANAGER_COMPONENT = "cps:DeploymentManager";
   
     public final static String CPS_ENTITY_ACCESS_COMPONENT = "cps:EntityAccessor";
     public final static String CPS_WINDOW_ACCESS_COMPONENT = "cps:WindowAccessor";

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java?rev=771259&r1=771258&r2=771259&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesProvider.java
Mon May  4 10:03:50 2009
@@ -23,6 +23,7 @@
 import org.apache.jetspeed.om.page.ContentPage;
 import org.apache.jetspeed.om.portlet.PortletApplication;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.Preference;
 import org.apache.pluto.container.PortletPreference;
 import org.apache.pluto.container.PortletPreferencesService;
 
@@ -48,12 +49,18 @@
     public void preloadUserPreferences();
     
     /**
-     * Store the default preferences for a given portlet definition
+     * Store the default preferences by descriptor preferences for a given portlet definition
      * @param pd
      */
     public void storeDefaults(PortletDefinition pd);
     
     /**
+     * Store the default preferences by input preference for a given portlet definition
+     * @param pd
+     */
+    public void storeDefaults(PortletDefinition pd, Preference preference);
+    
+    /**
      * Store the default preferences for all portlets in the given portlet application
      * @param app
      */
@@ -66,6 +73,12 @@
     public void removeDefaults(PortletDefinition pd);
     
     /**
+     * Remove default preferences by preference name for a given portlet definition
+     * @param pd
+     */
+    public void removeDefaults(PortletDefinition pd, String preferenceName);
+    
+    /**
      * Remove all default preferences for all portlet definitions in a given portlet application
      * @param app
      */

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml?rev=771259&r1=771258&r2=771259&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/jetspeed-services.xml
Mon May  4 10:03:50 2009
@@ -63,6 +63,9 @@
         <entry key="DeploymentManager">
           <ref bean="deploymentManager" />
         </entry>
+        <entry key="PortletPreferencesProvider">
+          <ref bean="org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider"
/>
+        </entry>
         <entry key='IdGenerator'>
           <ref bean='IdGenerator' />
         </entry>



---------------------------------------------------------------------
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