1
19
20 package com.liferay.portal.upgrade.v4_3_0;
21
22 import com.liferay.counter.model.Counter;
23 import com.liferay.counter.service.CounterLocalServiceUtil;
24 import com.liferay.portal.kernel.log.Log;
25 import com.liferay.portal.kernel.log.LogFactoryUtil;
26 import com.liferay.portal.model.Permission;
27 import com.liferay.portal.model.Resource;
28 import com.liferay.portal.model.ResourceCode;
29 import com.liferay.portal.model.UserTracker;
30 import com.liferay.portal.upgrade.UpgradeException;
31 import com.liferay.portal.upgrade.UpgradeProcess;
32 import com.liferay.portal.upgrade.util.DefaultUpgradeTableImpl;
33 import com.liferay.portal.upgrade.util.UpgradeTable;
34
35 import java.sql.Types;
36
37 import java.util.List;
38
39
45 public class UpgradeCounter extends UpgradeProcess {
46
47 public void upgrade() throws UpgradeException {
48 _log.info("Upgrading");
49
50 try {
51 doUpgrade();
52 }
53 catch (Exception e) {
54 throw new UpgradeException(e);
55 }
56 }
57
58 protected void doUpgrade() throws Exception {
59
60
62 List<String> names = CounterLocalServiceUtil.getNames();
63
64 for (String name : names) {
65 if (name.startsWith("com.liferay.") &&
66 !name.equals(Counter.class.getName()) &&
67 !name.equals(Permission.class.getName()) &&
68 !name.equals(Resource.class.getName()) &&
69 !name.equals(ResourceCode.class.getName()) &&
70 !name.equals(UserTracker.class.getName())) {
71
72 CounterLocalServiceUtil.reset(name);
73 }
74 }
75
76 UpgradeTable upgradeTable = new DefaultUpgradeTableImpl(
77 _TABLE_COUNTER, _COLUMNS_COUNTER);
78
79 upgradeTable.setCreateSQL(_CREATE_COUNTER);
80
81 upgradeTable.updateTable();
82 }
83
84 private static final String _TABLE_COUNTER = "Counter";
85
86 private static final Object[][] _COLUMNS_COUNTER = {
87 {"name", new Integer(Types.VARCHAR)},
88 {"currentId", new Integer(Types.BIGINT)}
89 };
90
91 private static final String _CREATE_COUNTER =
92 "create table Counter (" +
93 "name VARCHAR(75) not null primary key," +
94 "currentId LONG" +
95 ")";
96
97 private static Log _log = LogFactoryUtil.getLog(UpgradeCounter.class);
98
99 }