Author: julien(a)jboss.com
Date: 2007-11-08 21:14:14 -0500 (Thu, 08 Nov 2007)
New Revision: 8856
Modified:
branches/JBoss_Portal_Branch_2_6/core/build.xml
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
Log:
JBPORTAL-1773 : Unable to destroy instance customization
Modified: branches/JBoss_Portal_Branch_2_6/core/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-11-09 01:49:07 UTC (rev 8855)
+++ branches/JBoss_Portal_Branch_2_6/core/build.xml 2007-11-09 02:14:14 UTC (rev 8856)
@@ -565,11 +565,11 @@
<parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
<!--
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalNodeTestCase"
- outfile="TEST-PortalObjectContainerTestCase">
- <parameter name="CacheNaturalId"
value="true"/>
- <parameter name="Config"
value="transient-jboss-beans.xml"/>
- </zest>
+ <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalNodeTestCase"
+ outfile="TEST-PortalObjectContainerTestCase">
+ <parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="transient-jboss-beans.xml"/>
+ </zest>
-->
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
outfile="TEST-PortalObjectContainerTestCase">
@@ -577,11 +577,11 @@
<parameter name="Config"
value="persistent-jboss-beans.xml"/>
</zest>
<!--
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
- outfile="TEST-PortalObjectContainerTestCase">
- <parameter name="CacheNaturalId"
value="true"/>
- <parameter name="Config"
value="transient-jboss-beans.xml"/>
- </zest>
+ <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.portal.PortalObjectContainerTestCase"
+ outfile="TEST-PortalObjectContainerTestCase">
+ <parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="transient-jboss-beans.xml"/>
+ </zest>
-->
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
@@ -613,13 +613,13 @@
</zest>
<!--
- <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
-
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
- <parameter name="PersistLocally"
value="true"/>
- <parameter name="CloneOnCreate"
value="true"/>
- <parameter name="CacheNaturalId"
value="true"/>
- <parameter name="Config"
value="transient-jboss-beans.xml"/>
- </zest>
+ <zest todir="${test.reports}"
name="org.jboss.portal.test.core.model.instance.InstanceContainerTestCase"
+
outfile="TEST-PersistedLocally-ClonedOnCreate-InstanceContainerTestCase">
+ <parameter name="PersistLocally" value="true"/>
+ <parameter name="CloneOnCreate" value="true"/>
+ <parameter name="CacheNaturalId" value="true"/>
+ <parameter name="Config"
value="transient-jboss-beans.xml"/>
+ </zest>
-->
<zest todir="${test.reports}"
name="org.jboss.portal.test.core.state.ProducerTestCase"
outfile="TEST-ProducerTestCase-WithoutRegistration">
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java 2007-11-09
01:49:07 UTC (rev 8855)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/AbstractInstance.java 2007-11-09
02:14:14 UTC (rev 8856)
@@ -306,11 +306,15 @@
{
try
{
+ // Get what we need to destroy
PortletContext customizationPortletContext =
customization.getPortletContext();
List toDestroy = Collections.singletonList(customizationPortletContext);
PortletInvoker portletInvoker = getContainer().getPortletInvoker();
- //
+ // Destroy local customization first
+ getContainerContext().destroyInstanceCustomization(customization);
+
+ // Destroy the related customization
List failures = portletInvoker.destroyClones(toDestroy);
if (failures.size() > 0)
{
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java 2007-11-09
01:49:07 UTC (rev 8855)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/InstanceContainerContext.java 2007-11-09
02:14:14 UTC (rev 8856)
@@ -49,6 +49,8 @@
void destroyInstanceDefinition(AbstractInstanceDefinition instanceDef);
+ void destroyInstanceCustomization(AbstractInstanceCustomization customization);
+
AbstractInstanceCustomization getCustomization(AbstractInstanceDefinition instanceDef,
String customizationId);
AbstractInstanceCustomization newInstanceCustomization(AbstractInstanceDefinition def,
String id, PortletContext portletContext);
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java 2007-11-09
01:49:07 UTC (rev 8855)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/impl/model/instance/persistent/PersistentInstanceContainerContext.java 2007-11-09
02:14:14 UTC (rev 8856)
@@ -357,6 +357,23 @@
session.flush();
}
+
+ public void destroyInstanceCustomization(AbstractInstanceCustomization customization)
+ {
+ destroyInstanceCustomization((PersistentInstanceCustomization)customization);
+ }
+
+ private void destroyInstanceCustomization(PersistentInstanceCustomization
customization)
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ // Delete customization
+ session.delete(customization);
+
+ //
+ session.flush();
+ }
+
public boolean checkPermission(InstancePermission perm)
{
if (container.getPerformSecurityChecks())
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-11-09
01:49:07 UTC (rev 8855)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/test/core/model/instance/InstanceContainerTestCase.java 2007-11-09
02:14:14 UTC (rev 8856)
@@ -563,6 +563,36 @@
assertNotNull(userPortlet);
assertEquals("Foo",
userPortlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString());
TransactionAssert.commitTransaction();
+
+ // Erase state
+ TransactionAssert.beginTransaction();
+ instanceImpl =
(AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ instanceImpl.destroyCustomization("julien");
+ TransactionAssert.commitTransaction();
+
+ // Check state has been destroyed on consumer and producer
+ TransactionAssert.beginTransaction();
+ instanceImpl =
(AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ assertNotNull(instanceImpl);
+ userInstances = instanceImpl.getCustomizations();
+ assertNotNull(userInstances);
+ assertEquals(0, userInstances.size());
+ if (persistLocally)
+ {
+ try
+ {
+ instanceContainer.getPortletInvoker().getProperties(userPortletContext);
+ fail("Was expecting a NoSuchPortletException to be thrown");
+ }
+ catch (NoSuchPortletException expected)
+ {
+ }
+ }
+ else
+ {
+ instanceContainer.getPortletInvoker().getProperties(userPortletContext);
+ }
+ TransactionAssert.commitTransaction();
}
/** . */
@@ -586,8 +616,6 @@
assertNotNull(userInstances);
assertEquals(1, userInstances.size());
AbstractInstanceCustomization userInstance =
(AbstractInstanceCustomization)userInstances.iterator().next();
- System.out.println("userInstance.getPortletRef() = " +
userInstance.getPortletRef());
- System.out.println("userInstance.getState() = " +
userInstance.getState());
PortletContext userPortletContext = userInstance.getPortletContext();
assertNotNull(userPortletContext);
PropertyMap userProps =
instanceContainer.getPortletInvoker().getProperties(userPortletContext);
@@ -600,6 +628,36 @@
assertNotNull(userPortlet);
assertEquals("Foo",
userPortlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString());
TransactionAssert.commitTransaction();
+
+ // Erase state
+ TransactionAssert.beginTransaction();
+ instanceImpl =
(AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ instanceImpl.destroyCustomization("julien");
+ TransactionAssert.commitTransaction();
+
+ // Check state has been destroyed on consumer and producer
+ TransactionAssert.beginTransaction();
+ instanceImpl =
(AbstractInstanceDefinition)instanceContainer.getDefinition("MyInstance");
+ assertNotNull(instanceImpl);
+ userInstances = instanceImpl.getCustomizations();
+ assertNotNull(userInstances);
+ assertEquals(0, userInstances.size());
+ if (persistLocally)
+ {
+ try
+ {
+ instanceContainer.getPortletInvoker().getProperties(userPortletContext);
+ fail("Was expecting a NoSuchPortletException to be thrown");
+ }
+ catch (NoSuchPortletException expected)
+ {
+ }
+ }
+ else
+ {
+ instanceContainer.getPortletInvoker().getProperties(userPortletContext);
+ }
+ TransactionAssert.commitTransaction();
}
/** . */
@@ -891,6 +949,9 @@
TransactionAssert.commitTransaction();
}
+
+
+
//
//// /**Tests the authorization of portal objects */
//// public void testInstanceAuthorization() throws Exception
Show replies by date