001
014
015 package com.liferay.portal.kernel.settings;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.model.Group;
019 import com.liferay.portal.service.GroupLocalServiceUtil;
020
021
025 public class GroupServiceSettingsLocator implements SettingsLocator {
026
027 public GroupServiceSettingsLocator(long groupId, String settingsId) {
028 _groupId = groupId;
029 _settingsId = settingsId;
030 }
031
032 @Override
033 public Settings getSettings() throws SettingsException {
034 long companyId = getCompanyId(_groupId);
035
036 Settings portalPropertiesSettings =
037 _settingsLocatorHelper.getPortalPropertiesSettings();
038
039 Settings configurationBeanSettings =
040 _settingsLocatorHelper.getConfigurationBeanSettings(
041 _settingsId, portalPropertiesSettings);
042
043 Settings portalPreferencesSettings =
044 _settingsLocatorHelper.getPortalPreferencesSettings(
045 companyId, configurationBeanSettings);
046
047 Settings companyPortletPreferencesSettings =
048 _settingsLocatorHelper.getCompanyPortletPreferencesSettings(
049 companyId, _settingsId, portalPreferencesSettings);
050
051 return _settingsLocatorHelper.getGroupPortletPreferencesSettings(
052 _groupId, _settingsId, companyPortletPreferencesSettings);
053 }
054
055 @Override
056 public String getSettingsId() {
057 return _settingsId;
058 }
059
060 protected long getCompanyId(long groupId) throws SettingsException {
061 try {
062 Group group = GroupLocalServiceUtil.getGroup(groupId);
063
064 return group.getCompanyId();
065 }
066 catch (PortalException pe) {
067 throw new SettingsException(pe);
068 }
069 }
070
071 private final long _groupId;
072 private final String _settingsId;
073 private final SettingsLocatorHelper _settingsLocatorHelper =
074 SettingsLocatorHelperUtil.getSettingsLocatorHelper();
075
076 }