Author: chris.laprun(a)jboss.com
Date: 2011-04-21 13:04:33 -0400 (Thu, 21 Apr 2011)
New Revision: 6319
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java
Log:
- GTNWSRP-223: Fixed improper persistence of PortletContexts tied to Registrations.
Modified:
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java
===================================================================
---
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java 2011-04-21
15:33:59 UTC (rev 6318)
+++
components/wsrp/trunk/jcr-impl/src/main/java/org/gatein/wsrp/registration/mapping/RegistrationMapping.java 2011-04-21
17:04:33 UTC (rev 6319)
@@ -117,6 +117,10 @@
throw new IllegalArgumentException("Cannot handle PortletContext
state: " + context.getState());
}
}
+ else
+ {
+ contextMapping.initFrom(id, null);
+ }
}
Map<QName, Object> properties = registration.getProperties();
@@ -149,7 +153,7 @@
for (PortletContextMapping pcm : pcms)
{
PortletContext pc = PortletContext.createPortletContext(pcm.getId(),
IOTools.safeGetBytes(pcm.getState()));
- reg.addPortletContext(pc);
+ reg.addPortletContext(pc, false); // no need to save since we're loading
from persistence :)
}
return reg;
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java 2011-04-21
15:33:59 UTC (rev 6318)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationImpl.java 2011-04-21
17:04:33 UTC (rev 6319)
@@ -27,7 +27,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.registration.Registration;
import org.gatein.registration.RegistrationException;
-import org.gatein.registration.RegistrationManager;
+import org.gatein.registration.RegistrationPersistenceManager;
import org.gatein.registration.RegistrationStatus;
import org.gatein.registration.spi.ConsumerSPI;
import org.gatein.registration.spi.RegistrationSPI;
@@ -53,16 +53,17 @@
private Map<QName, Object> properties;
private String registrationHandle;
private Set<PortletContext> portletContexts;
- private transient RegistrationManager manager;
+ private transient RegistrationPersistenceManager manager;
- RegistrationImpl(String key, ConsumerSPI consumer, RegistrationStatus status,
Map<QName, Object> properties)
+ RegistrationImpl(String key, ConsumerSPI consumer, RegistrationStatus status,
Map<QName, Object> properties, RegistrationPersistenceManager manager)
{
this.key = key;
this.consumer = consumer;
this.status = status;
this.properties = new HashMap<QName, Object>(properties);
portletContexts = new HashSet<PortletContext>();
+ this.manager = manager;
}
public String getPersistentKey()
@@ -87,20 +88,27 @@
public void addPortletContext(PortletContext portletContext) throws
RegistrationException
{
+ addPortletContext(portletContext, true);
+ }
+
+ public void addPortletContext(PortletContext portletContext, boolean needsSaving)
throws RegistrationException
+ {
portletContexts.add(portletContext);
- manager.getPersistenceManager().saveChangesTo(this);
+ if (needsSaving)
+ {
+ manager.saveChangesTo(this);
+ }
}
public void removePortletContext(PortletContext portletContext) throws
RegistrationException
{
- portletContexts.remove(portletContext);
- manager.getPersistenceManager().saveChangesTo(this);
+ removePortletContext(portletContext, true);
}
- public void setManager(RegistrationManager manager)
+ public void removePortletContext(PortletContext portletContext, boolean needsSaving)
throws RegistrationException
{
- ParameterValidation.throwIllegalArgExceptionIfNull(manager,
"RegistrationManager");
- this.manager = manager;
+ portletContexts.remove(portletContext);
+ manager.saveChangesTo(this);
}
public Map<QName, Object> getProperties()
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2011-04-21
15:33:59 UTC (rev 6318)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationManagerImpl.java 2011-04-21
17:04:33 UTC (rev 6319)
@@ -125,8 +125,6 @@
String handle =
policy.createRegistrationHandleFor(registration.getPersistentKey());
registration.setRegistrationHandle(handle);
- registration.setManager(this);
-
return registration;
}
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2011-04-21
15:33:59 UTC (rev 6318)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/impl/RegistrationPersistenceManagerImpl.java 2011-04-21
17:04:33 UTC (rev 6319)
@@ -108,7 +108,7 @@
public RegistrationSPI newRegistrationSPI(ConsumerSPI consumer, Map<QName,
Object> registrationProperties, String registrationKey)
{
- return new RegistrationImpl(registrationKey, consumer, RegistrationStatus.PENDING,
registrationProperties);
+ return new RegistrationImpl(registrationKey, consumer, RegistrationStatus.PENDING,
registrationProperties, this);
}
@Override
Modified:
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java
===================================================================
---
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java 2011-04-21
15:33:59 UTC (rev 6318)
+++
components/wsrp/trunk/producer/src/main/java/org/gatein/registration/spi/RegistrationSPI.java 2011-04-21
17:04:33 UTC (rev 6319)
@@ -38,7 +38,9 @@
void addPortletContext(PortletContext portletContext) throws RegistrationException;
+ void addPortletContext(PortletContext portletContext, boolean needsSaving) throws
RegistrationException;
+
void removePortletContext(PortletContext portletContext) throws
RegistrationException;
- void setManager(RegistrationManager manager);
+ void removePortletContext(PortletContext portletContext, boolean needsSaving) throws
RegistrationException;
}