// Store the preferences for the portlet, if any
PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getLayoutPortletSetup(
portalPageLayout, portletId);
Portlet portlet = PortletLocalServiceUtil.getPortletById(companyId, portletId);
PortletBag portletBag = PortletBagPool.get(portlet.getRootPortletId());
if (portletBag != null) {
portletPreferences.store();
}