001    /**
002     * Copyright (c) 2000-2013 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.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    }