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