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.util;
016    
017    import com.liferay.portal.kernel.exception.SystemException;
018    import com.liferay.portal.kernel.util.PropsKeys;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.kernel.util.ThemeFactory;
021    import com.liferay.portal.kernel.util.ThemeFactoryUtil;
022    import com.liferay.portal.model.Theme;
023    import com.liferay.portal.model.impl.ThemeImpl;
024    
025    /**
026     * @author Harrison Schueler
027     */
028    public class ThemeFactoryImpl implements ThemeFactory {
029    
030            public Theme getDefaultRegularTheme(long companyId) throws SystemException {
031                    return new ThemeImpl(
032                            ThemeFactoryUtil.getDefaultRegularThemeId(companyId),
033                            StringPool.BLANK);
034            }
035    
036            public String getDefaultRegularThemeId(long companyId)
037                    throws SystemException {
038    
039                    String defaultRegularThemeId = PrefsPropsUtil.getString(
040                            companyId, PropsKeys.DEFAULT_REGULAR_THEME_ID);
041    
042                    return PortalUtil.getJsSafePortletId(defaultRegularThemeId);
043            }
044    
045            public Theme getDefaultWapTheme(long companyId) throws SystemException {
046                    return new ThemeImpl(
047                            ThemeFactoryUtil.getDefaultWapThemeId(companyId), StringPool.BLANK);
048            }
049    
050            public String getDefaultWapThemeId(long companyId) throws SystemException {
051                    String defaultWapThemeId = PrefsPropsUtil.getString(
052                            companyId, PropsKeys.DEFAULT_WAP_THEME_ID);
053    
054                    return PortalUtil.getJsSafePortletId(defaultWapThemeId);
055            }
056    
057            public Theme getTheme() {
058                    return new ThemeImpl();
059            }
060    
061            public Theme getTheme(String themeId) {
062                    return new ThemeImpl(themeId);
063            }
064    
065            public Theme getTheme(String themeId, String name) {
066                    return new ThemeImpl(themeId, name);
067            }
068    
069    }