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