portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1089285 - in /portals/jetspeed-2/portal/trunk: components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/ components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/ jetspeed-a...
Date Wed, 06 Apr 2011 00:37:55 GMT
Author: woonsan
Date: Wed Apr  6 00:37:55 2011
New Revision: 1089285

URL: http://svn.apache.org/viewvc?rev=1089285&view=rev
Log:
JS2-1247: Adding #removeClone() to allow admin portlet to remove a clone

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java?rev=1089285&r1=1089284&r2=1089285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletregistry/PersistenceBrokerPortletRegistry.java
Wed Apr  6 00:37:55 2011
@@ -569,6 +569,20 @@ public class PersistenceBrokerPortletReg
         return count;
     }
 
+    public void removeClone(PortletDefinition clone)
+            throws RegistryException
+    {
+        if (!clone.isClone())
+        {
+            throw new IllegalArgumentException("The portlet is not a cloned one: " + clone.getUniqueName());
+        }
+        
+        PortletApplication pa = clone.getApplication();
+        getPersistenceBrokerTemplate().delete(clone);
+        pa.getClones().remove(clone);
+        this.updatePortletApplication(pa);
+    }
+    
     public void removeAllClones(PortletApplication pa)
             throws RegistryException
     {

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java?rev=1089285&r1=1089284&r2=1089285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/test/java/org/apache/jetspeed/components/portletregistry/TestPortletRegistryDAO.java
Wed Apr  6 00:37:55 2011
@@ -207,6 +207,11 @@ public class TestPortletRegistryDAO exte
             assertEquals("myClone portlet name is not what expected", myClone.getPortletName(),
"restorePortlet");
             assertEquals("expecting one clone ", 1,  testApp.getClones().size());
 
+            PortletDefinition myClone2 = portletRegistry.clonePortletDefinition(srcPortlet,
"restorePortlet2");
+            assertNotNull("myClone2 portlet is null", myClone2);
+            assertEquals("myClone2 portlet name is not what expected", myClone2.getPortletName(),
"restorePortlet2");
+            assertEquals("expecting two clones ", 2,  testApp.getClones().size());
+            
             portletRegistry.removeApplication(testApp);
             testApp = portletRegistry.getPortletApplication("cloneTest");
             assertNull("test app should be null", testApp);
@@ -215,14 +220,18 @@ public class TestPortletRegistryDAO exte
             PortletApplication recreated = portletRegistry.getPortletApplication("cloneTest");
             assertNotNull("recreated test app is null", recreated);
             int count = portletRegistry.restoreClones(recreated);
-            assertEquals("Expected to restore one clone", 1, count);
+            assertEquals("Expected to restore one clone", 2, count);
             PortletDefinition cpd = recreated.getClone("restorePortlet");
             assertEquals("Expected clone to be named 'restorePortlet' ", cpd.getPortletName(),
"restorePortlet");
+            PortletDefinition cpd2 = recreated.getClone("restorePortlet2");
+            assertEquals("Expected clone to be named 'restorePortlet2' ", cpd2.getPortletName(),
"restorePortlet2");
         }
         finally
         {
             PortletApplication cleanup = portletRegistry.getPortletApplication("cloneTest");
             assertNotNull("cleanup app is null", cleanup);
+            assertEquals("expecting one clone ", 2, cleanup.getClones().size());
+            portletRegistry.removeClone(cleanup.getClone("restorePortlet"));
             assertEquals("expecting one clone ", 1, cleanup.getClones().size());
             portletRegistry.removeAllClones(cleanup);
             assertEquals("expecting zero clones ", 0, cleanup.getClones().size());

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java?rev=1089285&r1=1089284&r2=1089285&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
(original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/components/portletregistry/PortletRegistry.java
Wed Apr  6 00:37:55 2011
@@ -190,6 +190,15 @@ public interface PortletRegistry
 
 
     /**
+     * Remove a clone from a given portlet definition
+     * 
+     * @param clone the portlet definition
+     * @throws RegistryException
+     */
+    void removeClone(PortletDefinition clone)
+            throws RegistryException;
+    
+    /**
      * Remove all clones from a given portlet application
      * 
      * @param pa the portlet application



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