//Setup an interim entity in its place
final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId();
final String channelSubscribeId = portletEntity.getChannelSubscribeId();
final int userId = portletEntity.getUserId();
final IPortletEntity interimPortletEntity = this.createPortletEntity(portletDefinitionId, channelSubscribeId, userId);
if (this.logger.isTraceEnabled()) {
this.logger.trace("Persistent portlet entity " + portletEntityId + " no longer has preferences. Deleted it and created InterimPortletEntity " + interimPortletEntity.getPortletEntityId());
}
}
}
else {
//There are preferences on the interim entity, create an store it
if (preferences.size() > 0) {
final IPortletDefinitionId portletDefinitionId = portletEntity.getPortletDefinitionId();
final String channelSubscribeId = portletEntity.getChannelSubscribeId();
final int userId = portletEntity.getUserId();
final IPortletEntity persistantEntity = this.portletEntityDao.createPortletEntity(portletDefinitionId, channelSubscribeId, userId);
persistantEntity.setPortletPreferences(portletPreferences);
this.portletEntityDao.updatePortletEntity(persistantEntity);
//Remove the in-memory interim entity
this.removeInterimPortletEntity(portletEntityId);
//Setup the persistent ID mapping
this.setPersistentIdMapping(portletEntityId, persistantEntity.getPortletEntityId());
if (this.logger.isTraceEnabled()) {
this.logger.trace("InterimPortletEntity " + portletEntityId + " now has preferences. Deleted it and created persistent portlet entity " + persistantEntity.getPortletEntityId());
}
}
}
}