1
14
15 package com.liferay.portal.upgrade.v4_3_0;
16
17 import com.liferay.counter.model.Counter;
18 import com.liferay.counter.service.CounterLocalServiceUtil;
19 import com.liferay.portal.kernel.upgrade.UpgradeProcess;
20 import com.liferay.portal.kernel.upgrade.util.UpgradeTable;
21 import com.liferay.portal.kernel.upgrade.util.UpgradeTableFactoryUtil;
22 import com.liferay.portal.model.Permission;
23 import com.liferay.portal.model.Resource;
24 import com.liferay.portal.model.ResourceCode;
25 import com.liferay.portal.model.UserTracker;
26
27 import java.sql.Types;
28
29 import java.util.List;
30
31
36 public class UpgradeCounter extends UpgradeProcess {
37
38 protected void doUpgrade() throws Exception {
39
40
42 List<String> names = CounterLocalServiceUtil.getNames();
43
44 for (String name : names) {
45 if (name.startsWith("com.liferay.") &&
46 !name.equals(Counter.class.getName()) &&
47 !name.equals(Permission.class.getName()) &&
48 !name.equals(Resource.class.getName()) &&
49 !name.equals(ResourceCode.class.getName()) &&
50 !name.equals(UserTracker.class.getName())) {
51
52 CounterLocalServiceUtil.reset(name);
53 }
54 }
55
56 UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
57 _TABLE_COUNTER, _COLUMNS_COUNTER);
58
59 upgradeTable.setCreateSQL(_CREATE_COUNTER);
60
61 upgradeTable.updateTable();
62 }
63
64 private static final String _TABLE_COUNTER = "Counter";
65
66 private static final Object[][] _COLUMNS_COUNTER = {
67 {"name", new Integer(Types.VARCHAR)},
68 {"currentId", new Integer(Types.BIGINT)}
69 };
70
71 private static final String _CREATE_COUNTER =
72 "create table Counter (" +
73 "name VARCHAR(75) not null primary key," +
74 "currentId LONG" +
75 ")";
76
77 }