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.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            @Override
039            public Group getGroup() throws PortalException, SystemException {
040                    return GroupLocalServiceUtil.getLayoutSetPrototypeGroup(
041                            getCompanyId(), getLayoutSetPrototypeId());
042            }
043    
044            @Override
045            public long getGroupId() throws PortalException, SystemException {
046                    Group group = getGroup();
047    
048                    return group.getGroupId();
049            }
050    
051            @Override
052            public LayoutSet getLayoutSet() throws PortalException, SystemException {
053                    return LayoutSetLocalServiceUtil.getLayoutSet(
054                            getGroup().getGroupId(), true);
055            }
056    
057            @Override
058            public UnicodeProperties getSettingsProperties() {
059                    if (_settingsProperties == null) {
060                            _settingsProperties = new UnicodeProperties(true);
061    
062                            try {
063                                    _settingsProperties.load(super.getSettings());
064                            }
065                            catch (IOException ioe) {
066                                    _log.error(ioe, ioe);
067                            }
068                    }
069    
070                    return _settingsProperties;
071            }
072    
073            @Override
074            public String getSettingsProperty(String key) {
075                    UnicodeProperties settingsProperties = getSettingsProperties();
076    
077                    return settingsProperties.getProperty(key);
078            }
079    
080            @Override
081            public void setSettings(String settings) {
082                    _settingsProperties = null;
083    
084                    super.setSettings(settings);
085            }
086    
087            @Override
088            public void setSettingsProperties(UnicodeProperties settingsProperties) {
089                    _settingsProperties = settingsProperties;
090    
091                    super.setSettings(settingsProperties.toString());
092            }
093    
094            private static Log _log = LogFactoryUtil.getLog(
095                    LayoutSetPrototypeImpl.class);
096    
097            private UnicodeProperties _settingsProperties;
098    
099    }