001    /**
002     * Copyright (c) 2000-2011 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.convert;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.service.RoleLocalServiceUtil;
020    import com.liferay.portal.util.PropsValues;
021    
022    /**
023     * @author Alexander Chow
024     */
025    public class ConvertPermissionTuner extends ConvertProcess {
026    
027            public String getDescription() {
028                    return "fine-tune-generated-roles";
029            }
030    
031            public String getPath() {
032                    return "/admin_server/edit_permissions";
033            }
034    
035            public boolean isEnabled() {
036                    boolean enabled = false;
037    
038                    try {
039                            if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM == 6) {
040                                    int count = RoleLocalServiceUtil.getSubtypeRolesCount(
041                                            "lfr-permission-algorithm-5");
042    
043                                    if (count > 0) {
044                                            enabled = true;
045                                    }
046                            }
047                    }
048                    catch (Exception e) {
049                            _log.error(e, e);
050                    }
051    
052                    return enabled;
053            }
054    
055            protected void doConvert() throws Exception {
056            }
057    
058            private static Log _log = LogFactoryUtil.getLog(
059                    ConvertPermissionTuner.class);
060    
061    }