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            @Override
031            public Theme getDefaultRegularTheme(long companyId) throws SystemException {
032                    return new ThemeImpl(
033                            ThemeFactoryUtil.getDefaultRegularThemeId(companyId),
034                            StringPool.BLANK);
035            }
036    
037            @Override
038            public String getDefaultRegularThemeId(long companyId)
039                    throws SystemException {
040    
041                    String defaultRegularThemeId = PrefsPropsUtil.getString(
042                            companyId, PropsKeys.DEFAULT_REGULAR_THEME_ID);
043    
044                    return PortalUtil.getJsSafePortletId(defaultRegularThemeId);
045            }
046    
047            @Override
048            public Theme getDefaultWapTheme(long companyId) throws SystemException {
049                    return new ThemeImpl(
050                            ThemeFactoryUtil.getDefaultWapThemeId(companyId), StringPool.BLANK);
051            }
052    
053            @Override
054            public String getDefaultWapThemeId(long companyId) throws SystemException {
055                    String defaultWapThemeId = PrefsPropsUtil.getString(
056                            companyId, PropsKeys.DEFAULT_WAP_THEME_ID);
057    
058                    return PortalUtil.getJsSafePortletId(defaultWapThemeId);
059            }
060    
061            @Override
062            public Theme getTheme() {
063                    return new ThemeImpl();
064            }
065    
066            @Override
067            public Theme getTheme(String themeId) {
068                    return new ThemeImpl(themeId);
069            }
070    
071            @Override
072            public Theme getTheme(String themeId, String name) {
073                    return new ThemeImpl(themeId, name);
074            }
075    
076    }