001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.settings;
016    
017    /**
018     * @author Ivan Zaera
019     * @author Jorge Ferrer
020     */
021    public class CompanyServiceSettingsLocator implements SettingsLocator {
022    
023            public CompanyServiceSettingsLocator(long companyId, String settingsId) {
024                    _companyId = companyId;
025                    _settingsId = settingsId;
026            }
027    
028            @Override
029            public Settings getSettings() {
030                    Settings portalPropertiesSettings =
031                            _settingsLocatorHelper.getPortalPropertiesSettings();
032    
033                    Settings configurationBeanSettings =
034                            _settingsLocatorHelper.getConfigurationBeanSettings(
035                                    _settingsId, portalPropertiesSettings);
036    
037                    Settings portalPreferencesSettings =
038                            _settingsLocatorHelper.getPortalPreferencesSettings(
039                                    _companyId, configurationBeanSettings);
040    
041                    return _settingsLocatorHelper.getCompanyPortletPreferencesSettings(
042                            _companyId, _settingsId, portalPreferencesSettings);
043            }
044    
045            @Override
046            public String getSettingsId() {
047                    return _settingsId;
048            }
049    
050            private final long _companyId;
051            private final String _settingsId;
052            private final SettingsLocatorHelper _settingsLocatorHelper =
053                    SettingsLocatorHelperUtil.getSettingsLocatorHelper();
054    
055    }