ChannelDefinition channelDefinition = ChannelRegistryStoreFactory.getChannelRegistryStoreImpl().getChannelDefinition(Integer.parseInt(sd.getChannelPublishId()));
portletDefinition.setChannelDefinition(channelDefinition);
portletDefinition.loadPreferences();
// Create the PortletApplicationEntity
final PortletApplicationEntityImpl portAppEnt = new PortletApplicationEntityImpl();
portAppEnt.setId(portletDefinition.getId().toString());
portAppEnt.setPortletApplicationDefinition(portletDefinition.getPortletApplicationDefinition());
// Create the PortletEntity
PortletEntityImpl portletEntity = new PortletEntityImpl();
portletEntity.setId(sd.getChannelPublishId());
portletEntity.setPortletDefinition(portletDefinition);