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.portal.upgrade.v6_1_0;
016    
017    import com.liferay.counter.kernel.service.CounterLocalService;
018    import com.liferay.counter.kernel.service.CounterLocalServiceWrapper;
019    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
020    import com.liferay.portal.kernel.model.ResourcePermission;
021    import com.liferay.portal.kernel.upgrade.BaseUpgradeAdminPortlets;
022    import com.liferay.portal.spring.aop.ServiceWrapperProxyUtil;
023    
024    import java.io.Closeable;
025    
026    /**
027     * @author Juan Fern??ndez
028     */
029    public class UpgradeAdminPortlets extends BaseUpgradeAdminPortlets {
030    
031            @Override
032            protected void doUpgrade() throws Exception {
033                    try (Closeable closeable = ServiceWrapperProxyUtil.createProxy(
034                                    PortalBeanLocatorUtil.locate(
035                                            CounterLocalService.class.getName()),
036                                    Pre7CounterLocalServiceImpl.class)) {
037    
038                            updateAccessInControlPanelPermission("19", "162");
039                            updateAccessInControlPanelPermission("33", "161");
040                    }
041            }
042    
043            private static class Pre7CounterLocalServiceImpl
044                    extends CounterLocalServiceWrapper {
045    
046                    @Override
047                    public long increment(String name) {
048                            if (name.equals(ResourcePermission.class.getName())) {
049                                    name = "com.liferay.portal.model.ResourcePermission";
050                            }
051    
052                            return super.increment(name);
053                    }
054    
055                    private Pre7CounterLocalServiceImpl(
056                            CounterLocalService counterLocalService) {
057    
058                            super(counterLocalService);
059                    }
060    
061            }
062    
063    }