001    /**
002     * Copyright (c) 2000-2011 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.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.log.Log;
020    import com.liferay.portal.kernel.log.LogFactoryUtil;
021    import com.liferay.portal.kernel.util.UnicodeProperties;
022    import com.liferay.portal.model.Group;
023    import com.liferay.portal.model.LayoutSet;
024    import com.liferay.portal.service.GroupLocalServiceUtil;
025    import com.liferay.portal.service.LayoutSetLocalServiceUtil;
026    
027    import java.io.IOException;
028    
029    /**
030     * @author Brian Wing Shun Chan
031     * @author Ryan Park
032     */
033    public class LayoutSetPrototypeImpl extends LayoutSetPrototypeBaseImpl {
034    
035            public LayoutSetPrototypeImpl() {
036            }
037    
038            public Group getGroup() throws PortalException, SystemException {
039                    return GroupLocalServiceUtil.getLayoutSetPrototypeGroup(
040                            getCompanyId(), getLayoutSetPrototypeId());
041            }
042    
043            public LayoutSet getLayoutSet() throws PortalException, SystemException {
044                    return LayoutSetLocalServiceUtil.getLayoutSet(
045                            getGroup().getGroupId(), true);
046            }
047    
048            public UnicodeProperties getSettingsProperties() {
049                    if (_settingsProperties == null) {
050                            _settingsProperties = new UnicodeProperties(true);
051    
052                            try {
053                                    _settingsProperties.load(super.getSettings());
054                            }
055                            catch (IOException ioe) {
056                                    _log.error(ioe, ioe);
057                            }
058                    }
059    
060                    return _settingsProperties;
061            }
062    
063            public String getSettingsProperty(String key) {
064                    UnicodeProperties settingsProperties = getSettingsProperties();
065    
066                    return settingsProperties.getProperty(key);
067            }
068    
069            @Override
070            public void setSettings(String settings) {
071                    _settingsProperties = null;
072    
073                    super.setSettings(settings);
074            }
075    
076            public void setSettingsProperties(
077                    UnicodeProperties settingsProperties) {
078    
079                    _settingsProperties = settingsProperties;
080    
081                    super.setSettings(settingsProperties.toString());
082            }
083    
084            private static Log _log = LogFactoryUtil.getLog(
085                    LayoutSetPrototypeImpl.class);
086    
087            private UnicodeProperties _settingsProperties;
088    
089    }