001
014
015 package com.liferay.portal.upgrade.v4_3_0;
016
017 import com.liferay.counter.model.Counter;
018 import com.liferay.counter.service.CounterLocalServiceUtil;
019 import com.liferay.portal.kernel.upgrade.UpgradeProcess;
020 import com.liferay.portal.kernel.upgrade.util.UpgradeTable;
021 import com.liferay.portal.kernel.upgrade.util.UpgradeTableFactoryUtil;
022 import com.liferay.portal.model.Permission;
023 import com.liferay.portal.model.Resource;
024 import com.liferay.portal.model.ResourceCode;
025 import com.liferay.portal.model.UserTracker;
026
027 import java.sql.Types;
028
029 import java.util.List;
030
031
034 public class UpgradeCounter extends UpgradeProcess {
035
036 protected void doUpgrade() throws Exception {
037
038
039
040 List<String> names = CounterLocalServiceUtil.getNames();
041
042 for (String name : names) {
043 if (name.startsWith("com.liferay.") &&
044 !name.equals(Counter.class.getName()) &&
045 !name.equals(Permission.class.getName()) &&
046 !name.equals(Resource.class.getName()) &&
047 !name.equals(ResourceCode.class.getName()) &&
048 !name.equals(UserTracker.class.getName())) {
049
050 CounterLocalServiceUtil.reset(name);
051 }
052 }
053
054 UpgradeTable upgradeTable = UpgradeTableFactoryUtil.getUpgradeTable(
055 _TABLE_COUNTER, _COLUMNS_COUNTER);
056
057 upgradeTable.setCreateSQL(_CREATE_COUNTER);
058
059 upgradeTable.updateTable();
060 }
061
062 private static final String _TABLE_COUNTER = "Counter";
063
064 private static final Object[][] _COLUMNS_COUNTER = {
065 {"name", new Integer(Types.VARCHAR)},
066 {"currentId", new Integer(Types.BIGINT)}
067 };
068
069 private static final String _CREATE_COUNTER =
070 "create table Counter (" +
071 "name VARCHAR(75) not null primary key," +
072 "currentId LONG" +
073 ")";
074
075 }