1
22
23 package com.liferay.portal.upgrade;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.util.InstancePool;
28 import com.liferay.portal.tools.sql.DBUtil;
29
30 import java.io.IOException;
31
32 import java.sql.SQLException;
33
34 import javax.naming.NamingException;
35
36
42 public abstract class UpgradeProcess {
43
44 public UpgradeProcess() {
45 }
46
47 public int getThreshold() {
48
49
53 return 0;
54 }
55
56 public boolean isSupportsAlterColumnName() {
57 return DBUtil.getInstance().isSupportsAlterColumnName();
58 }
59
60 public boolean isSupportsAlterColumnType() {
61 return DBUtil.getInstance().isSupportsAlterColumnType();
62 }
63
64 public boolean isSupportsStringCaseSensitiveQuery() {
65 return DBUtil.getInstance().isSupportsStringCaseSensitiveQuery();
66 }
67
68 public boolean isSupportsUpdateWithInnerJoin() {
69 return DBUtil.getInstance().isSupportsUpdateWithInnerJoin();
70 }
71
72 public void runSQL(String template) throws IOException, SQLException {
73 DBUtil.getInstance().runSQL(template);
74 }
75
76 public void runSQL(String[] templates) throws IOException, SQLException {
77 DBUtil.getInstance().runSQL(templates);
78 }
79
80 public void runSQLTemplate(String path)
81 throws IOException, NamingException, SQLException {
82
83 DBUtil.getInstance().runSQLTemplate(path);
84 }
85
86 public void runSQLTemplate(String path, boolean failOnError)
87 throws IOException, NamingException, SQLException {
88
89 DBUtil.getInstance().runSQLTemplate(path, failOnError);
90 }
91
92 public void upgrade() throws UpgradeException {
93 try {
94 if (_log.isInfoEnabled()) {
95 _log.info("Upgrading " + getClass().getName());
96 }
97
98 doUpgrade();
99 }
100 catch (Exception e) {
101 throw new UpgradeException(e);
102 }
103 }
104
105 public void upgrade(Class<?> upgradeProcessClass)
106 throws UpgradeException {
107
108 UpgradeProcess upgradeProcess = (UpgradeProcess)InstancePool.get(
109 upgradeProcessClass.getName());
110
111 upgradeProcess.upgrade();
112 }
113
114 public void upgrade(UpgradeProcess upgradeProcess)
115 throws UpgradeException {
116
117 upgradeProcess.upgrade();
118 }
119
120 protected void doUpgrade() throws Exception {
121 }
122
123 private static Log _log = LogFactoryUtil.getLog(UpgradeProcess.class);
124
125 }