001    /**
002     * Copyright (c) 2000-2011 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            @Override
028            public String getDescription() {
029                    return "fine-tune-generated-roles";
030            }
031    
032            @Override
033            public String getPath() {
034                    return "/admin_server/edit_permissions";
035            }
036    
037            @Override
038            public boolean isEnabled() {
039                    boolean enabled = false;
040    
041                    try {
042                            if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM == 6) {
043                                    int count = RoleLocalServiceUtil.getSubtypeRolesCount(
044                                            "lfr-permission-algorithm-5");
045    
046                                    if (count > 0) {
047                                            enabled = true;
048                                    }
049                            }
050                    }
051                    catch (Exception e) {
052                            _log.error(e, e);
053                    }
054    
055                    return enabled;
056            }
057    
058            @Override
059            protected void doConvert() throws Exception {
060            }
061    
062            private static Log _log = LogFactoryUtil.getLog(
063                    ConvertPermissionTuner.class);
064    
065    }