public Object call() throws Exception {
final IPortletEntity portletEntity = portletEntityRegistry.getPortletEntity(request, portletEntityId);
//Add a preference
final List<IPortletPreference> preferences = portletEntity.getPortletPreferences();
final IPortletPreference portletPreference = new PortletPreferenceImpl("pref", false, "value");
preferences.add(portletPreference);
//Store the entity
portletEntityRegistry.storePortletEntity(request, portletEntity);
return null;
}
});
this.execute(new Callable<Object>() {
@Override
public Object call() throws Exception {
//T1 - Verify it was converted from interim to persistent
final IPortletEntity portletEntity = portletEntityRegistry.getPortletEntity(request, portletEntityId);
assertEquals(PersistentPortletEntityWrapper.class, portletEntity.getClass());
final List<IPortletPreference> preferences = portletEntity.getPortletPreferences();
assertEquals(1, preferences.size());
//T2 - get the entity and add preferences
final IPortletEntityId localPortletEntityId = executeInThread("T2.1", new Callable<IPortletEntityId>() {
@Override
public IPortletEntityId call() throws Exception {
//T2 - Get entity
final IPortletEntity portletEntity = portletEntityRegistry.getPortletEntity(request, portletEntityId.getStringId());
assertEquals(portletEntity, portletEntity);
//T2 - add preference
final List<IPortletPreference> preferences = portletEntity.getPortletPreferences();
preferences.clear();
//T2 - Store the entity
portletEntityRegistry.storePortletEntity(request, portletEntity);
return portletEntity.getPortletEntityId();
}
});
//T2 - verify entity was made persistent
executeInThread("T2.2", new Callable<Object>() {
@Override
public Object call() throws Exception {
//T2 - Verify it was converted from persistent to interim
final IPortletEntity portletEntity = portletEntityRegistry.getPortletEntity(request, localPortletEntityId);
assertNotNull(portletEntity);
assertEquals(SessionPortletEntityImpl.class, portletEntity.getClass());
final List<IPortletPreference> preferences = portletEntity.getPortletPreferences();
assertEquals(0, preferences.size());
return null;
}
});
//T1 - add preference 2
final IPortletPreference portletPreference = new PortletPreferenceImpl("pref2", false, "value");
preferences.add(portletPreference);
//T1 - Store the entity
portletEntityRegistry.storePortletEntity(request, portletEntity);