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.verify;
016    
017    import com.liferay.counter.service.CounterLocalServiceUtil;
018    import com.liferay.portal.model.Permission;
019    import com.liferay.portal.model.Resource;
020    import com.liferay.portal.service.PermissionLocalServiceUtil;
021    import com.liferay.portal.service.ResourceLocalServiceUtil;
022    
023    /**
024     * @author Alexander Chow
025     * @author Brian Wing Shun Chan
026     */
027    public class VerifyCounter extends VerifyProcess {
028    
029            protected void doVerify() throws Exception {
030    
031                    // Resource
032    
033                    long latestResourceId = ResourceLocalServiceUtil.getLatestResourceId();
034    
035                    long counterResourceId = CounterLocalServiceUtil.increment(
036                            Resource.class.getName());
037    
038                    if (latestResourceId > counterResourceId - 1) {
039                            CounterLocalServiceUtil.reset(
040                                    Resource.class.getName(), latestResourceId);
041                    }
042    
043                    // Permission
044    
045                    long latestPermissionId =
046                            PermissionLocalServiceUtil.getLatestPermissionId();
047    
048                    long counterPermissionId = CounterLocalServiceUtil.increment(
049                            Permission.class.getName());
050    
051                    if (latestPermissionId > counterPermissionId - 1) {
052                            CounterLocalServiceUtil.reset(
053                                    Permission.class.getName(), latestPermissionId);
054                    }
055            }
056    
057    }