protected PortletPreferences getPortletPreferences(long groupId) throws PortalException { long ownerId = groupId; int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP; long plid = 0; PortletPreferences preferences = null; try { com.liferay.portal.kernel.model.PortletPreferences portletPreferences = _portletPreferencesLocalService .getPortletPreferences(ownerId, ownerType, plid, ch.inofix.data.constants.PortletKeys.DATA_MANAGER); preferences = PortletPreferencesFactoryUtil .fromDefaultXML(portletPreferences.getPreferences()); } catch (NoSuchPortletPreferencesException e) { _log.warn(e.getMessage()); } return preferences; }
protected PortletPreferences getPreferences(long groupId) throws PortalException { long ownerId = groupId; int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP; long plid = 0; com.liferay.portal.kernel.model.PortletPreferences portletPreferences = _portletPreferencesLocalService .getPortletPreferences(ownerId, ownerType, plid, ch.inofix.data.constants.PortletKeys.DATA_MANAGER); PortletPreferences preferences = PortletPreferencesFactoryUtil .fromDefaultXML(portletPreferences.getPreferences()); return preferences; }
/** * Read settings from page Documents And Media portlet "Show Actions" portlet configuration.<br/> * But for Documents And Media admin portlet, it will always be true. */ private boolean _showAction() throws SettingsException { PortletDisplay portletDisplay = _themeDisplay.getPortletDisplay(); String portletName = portletDisplay.getPortletName(); if (portletName.equals(PortletKeys.DOCUMENT_LIBRARY_ADMIN)) { return true; } Settings settings = SettingsFactoryUtil.getSettings( new PortletInstanceSettingsLocator( _themeDisplay.getLayout(), portletDisplay.getId())); TypedSettings typedSettings = new TypedSettings(settings); return typedSettings.getBooleanValue("showActions"); }
public static PortletPreferences getPrivacyAdminSettings( long companyId, long groupId) { return PortletPreferencesLocalServiceUtil.getPreferences( companyId, groupId, PortletKeys.PREFS_OWNER_TYPE_GROUP, 0, PrivacyPortletKeys.PRIVACY_ADMIN); }
private static void removeAllPortlets(final long runasUser, final LayoutTypePortlet layoutTypePortlet, final Layout layout) { List<Portlet> portlets = null; try { portlets = layoutTypePortlet.getAllPortlets(); } catch (SystemException e1) { e1.printStackTrace(); } if (portlets != null) { for (Portlet portlet : portlets) { String portletId = portlet.getPortletId(); try { if (layoutTypePortlet.hasPortletId(portletId)) { LOG.debug("Removing portlet " + portletId); layoutTypePortlet.removePortletId(runasUser, portletId); String rootPortletId = PortletConstants.getRootPortletId(portletId); LOG.debug("Root portletId: " + rootPortletId); ResourceLocalServiceUtil.deleteResource(layout.getCompanyId(), rootPortletId, ResourceConstants.SCOPE_INDIVIDUAL, PortletPermissionUtil.getPrimaryKey(layout.getPlid(), portletId)); LayoutLocalServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), layout.getTypeSettings()); List<PortletPreferences> list = PortletPreferencesLocalServiceUtil .getPortletPreferences(PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid(), portletId); for (PortletPreferences p : list) { PortletPreferencesLocalServiceUtil.deletePortletPreferences(p); } } } catch (PortalException | SystemException e) { e.printStackTrace(); } } } }