001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }