Author: scottbw
Date: Wed Dec 1 10:22:34 2010
New Revision: 1040932
URL: http://svn.apache.org/viewvc?rev=1040932&view=rev
Log:
Fix for WOOKIE-168. When a Widget is deleted using
WidgetFactory.destroy(widget) we also delete any associated Participants, as
these do not appear to be automatically removed by the PersistenceManager.
Modified:
incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java
Modified:
incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java?rev=1040932&r1=1040931&r2=1040932&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java
(original)
+++ incubator/wookie/trunk/src/org/apache/wookie/helpers/WidgetFactory.java Wed
Dec 1 10:22:34 2010
@@ -20,6 +20,7 @@ import org.apache.wookie.beans.IFeature;
import org.apache.wookie.beans.ILicense;
import org.apache.wookie.beans.IName;
import org.apache.wookie.beans.IParam;
+import org.apache.wookie.beans.IParticipant;
import org.apache.wookie.beans.IPreferenceDefault;
import org.apache.wookie.beans.IStartFile;
import org.apache.wookie.beans.IWidget;
@@ -247,6 +248,20 @@ public class WidgetFactory {
IWidgetInstance[] instances =
persistenceManager.findByValue(IWidgetInstance.class, "widget", widget);
for(IWidgetInstance instance : instances){
WidgetInstanceFactory.destroy(instance);
+ // Delete all participants associated with any instances
+ //
+ // Note that we don't call this within
WidgetInstanceFactory.destroy() as
+ // if called in a different context (to remove just one
instance) it would
+ // have the side effect of deleting participants from
other instances,
+ // not just the one being deleted.
+ //
+ // Note also that we have to use the instance as the
hook for removing participants as there is no
+ // specific query for getting participants for a widget.
+ //
+ IParticipant[] participants =
persistenceManager.findParticipants(instance);
+ for (IParticipant participant:participants){
+ persistenceManager.delete(participant);
+ }
}
// remove any AccessRequests