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