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