1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }