001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.plugin.PluginPackage;
018    import com.liferay.portal.model.Plugin;
019    import com.liferay.portal.model.PluginSetting;
020    
021    import java.util.HashMap;
022    import java.util.Map;
023    
024    /**
025     * @author Jorge Ferrer
026     */
027    public abstract class PluginBaseImpl implements Plugin {
028    
029            @Override
030            public PluginPackage getPluginPackage() {
031                    return _pluginPackage;
032            }
033    
034            @Override
035            public void setPluginPackage(PluginPackage pluginPackage) {
036                    _pluginPackage = pluginPackage;
037            }
038    
039            @Override
040            public PluginSetting getDefaultPluginSetting() {
041                    return _defaultPluginSetting;
042            }
043    
044            @Override
045            public PluginSetting getDefaultPluginSetting(long companyId) {
046                    PluginSetting setting = _defaultPluginSettings.get(companyId);
047    
048                    if (setting == null) {
049                            setting = new PluginSettingImpl(_defaultPluginSetting);
050    
051                            setting.setCompanyId(companyId);
052    
053                            _defaultPluginSettings.put(companyId, setting);
054                    }
055    
056                    return setting;
057            }
058    
059            @Override
060            public void setDefaultPluginSetting(PluginSetting pluginSetting) {
061                    _defaultPluginSetting = pluginSetting;
062            }
063    
064            private PluginPackage _pluginPackage;
065            private PluginSetting _defaultPluginSetting;
066            private Map<Long, PluginSetting> _defaultPluginSettings =
067                    new HashMap<Long, PluginSetting>();
068    
069    }