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                    _configurationPid = settingsId;
028            }
029    
030            public CompanyServiceSettingsLocator(
031                    long companyId, String settingsId, String configurationPid) {
032    
033                    _companyId = companyId;
034                    _settingsId = settingsId;
035                    _configurationPid = configurationPid;
036            }
037    
038            @Override
039            public Settings getSettings() {
040                    Settings portalPropertiesSettings =
041                            _settingsLocatorHelper.getPortalPropertiesSettings();
042    
043                    Settings configurationBeanSettings =
044                            _settingsLocatorHelper.getConfigurationBeanSettings(
045                                    _configurationPid, portalPropertiesSettings);
046    
047                    Settings portalPreferencesSettings =
048                            _settingsLocatorHelper.getPortalPreferencesSettings(
049                                    _companyId, configurationBeanSettings);
050    
051                    return _settingsLocatorHelper.getCompanyPortletPreferencesSettings(
052                            _companyId, _settingsId, portalPreferencesSettings);
053            }
054    
055            @Override
056            public String getSettingsId() {
057                    return _settingsId;
058            }
059    
060            private final long _companyId;
061            private final String _configurationPid;
062            private final String _settingsId;
063            private final SettingsLocatorHelper _settingsLocatorHelper =
064                    SettingsLocatorHelperUtil.getSettingsLocatorHelper();
065    
066    }