001    /**
002     * Copyright (c) 2000-2013 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            @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    }