1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.verify;
16  
17  import com.liferay.counter.service.CounterLocalServiceUtil;
18  import com.liferay.portal.model.Permission;
19  import com.liferay.portal.model.Resource;
20  import com.liferay.portal.service.PermissionLocalServiceUtil;
21  import com.liferay.portal.service.ResourceLocalServiceUtil;
22  
23  /**
24   * <a href="VerifyCounter.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Alexander Chow
27   * @author Brian Wing Shun Chan
28   */
29  public class VerifyCounter extends VerifyProcess {
30  
31      protected void doVerify() throws Exception {
32  
33          // Resource
34  
35          long latestResourceId = ResourceLocalServiceUtil.getLatestResourceId();
36  
37          long counterResourceId = CounterLocalServiceUtil.increment(
38              Resource.class.getName());
39  
40          if (latestResourceId > counterResourceId - 1) {
41              CounterLocalServiceUtil.reset(
42                  Resource.class.getName(), latestResourceId);
43          }
44  
45          // Permission
46  
47          long latestPermissionId =
48              PermissionLocalServiceUtil.getLatestPermissionId();
49  
50          long counterPermissionId = CounterLocalServiceUtil.increment(
51              Permission.class.getName());
52  
53          if (latestPermissionId > counterPermissionId - 1) {
54              CounterLocalServiceUtil.reset(
55                  Permission.class.getName(), latestPermissionId);
56          }
57      }
58  
59  }