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.portlet.rolesadmin.util;
016    
017    import com.liferay.portal.kernel.security.pacl.DoPrivileged;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.Role;
020    import com.liferay.portal.model.RoleConstants;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    @DoPrivileged
026    public class RolesAdminImpl implements RolesAdmin {
027    
028            /**
029             * @deprecated As of 7.0.0, with no direct replacement
030             */
031            @Deprecated
032            @Override
033            public String getCssClassName(Role role) {
034                    String cssClassName = StringPool.BLANK;
035    
036                    String roleName = role.getName();
037                    int roleType = role.getType();
038    
039                    if (roleName.equals(RoleConstants.GUEST)) {
040                            cssClassName = "lfr-role-guest";
041                    }
042                    else if (roleType == RoleConstants.TYPE_ORGANIZATION) {
043                            cssClassName = "lfr-role-organization";
044                    }
045                    else if (roleType == RoleConstants.TYPE_REGULAR) {
046                            cssClassName = "lfr-role-regular";
047                    }
048                    else if (roleType == RoleConstants.TYPE_SITE) {
049                            cssClassName = "lfr-role-site";
050                    }
051                    else if (role.isTeam()) {
052                            cssClassName = "lfr-role-team";
053                    }
054    
055                    return "lfr-role " + cssClassName;
056            }
057    
058            @Override
059            public String getIconCssClass(Role role) {
060                    String iconCssClass = StringPool.BLANK;
061    
062                    String roleName = role.getName();
063                    int roleType = role.getType();
064    
065                    if (roleName.equals(RoleConstants.GUEST)) {
066                            iconCssClass = "icon-user guest";
067                    }
068                    else if (roleType == RoleConstants.TYPE_ORGANIZATION) {
069                            iconCssClass = "icon-globe";
070                    }
071                    else if (roleType == RoleConstants.TYPE_REGULAR) {
072                            iconCssClass = "icon-user";
073                    }
074                    else if (roleType == RoleConstants.TYPE_SITE) {
075                            iconCssClass = "icon-globe";
076                    }
077                    else if (role.isTeam()) {
078                            iconCssClass = "icon-group";
079                    }
080    
081                    return iconCssClass;
082            }
083    
084    }