1
14
15 package com.liferay.portal.kernel.upgrade;
16
17 import com.liferay.portal.kernel.dao.db.DB;
18 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
19 import com.liferay.portal.kernel.exception.SystemException;
20 import com.liferay.portal.kernel.log.Log;
21 import com.liferay.portal.kernel.log.LogFactoryUtil;
22
23 import java.io.IOException;
24
25 import java.sql.SQLException;
26
27 import javax.naming.NamingException;
28
29
35 public abstract class UpgradeProcess {
36
37 public UpgradeProcess() {
38 }
39
40 public int getThreshold() {
41
42
46 return 0;
47 }
48
49 public long increment() throws SystemException {
50 DB db = DBFactoryUtil.getDB();
51
52 return db.increment();
53 }
54
55 public boolean isSupportsAlterColumnName() {
56 DB db = DBFactoryUtil.getDB();
57
58 return db.isSupportsAlterColumnName();
59 }
60
61 public boolean isSupportsAlterColumnType() {
62 DB db = DBFactoryUtil.getDB();
63
64 return db.isSupportsAlterColumnType();
65 }
66
67 public boolean isSupportsStringCaseSensitiveQuery() {
68 DB db = DBFactoryUtil.getDB();
69
70 return db.isSupportsStringCaseSensitiveQuery();
71 }
72
73 public boolean isSupportsUpdateWithInnerJoin() {
74 DB db = DBFactoryUtil.getDB();
75
76 return db.isSupportsUpdateWithInnerJoin();
77 }
78
79 public void runSQL(String template) throws IOException, SQLException {
80 DB db = DBFactoryUtil.getDB();
81
82 db.runSQL(template);
83 }
84
85 public void runSQL(String[] templates) throws IOException, SQLException {
86 DB db = DBFactoryUtil.getDB();
87
88 db.runSQL(templates);
89 }
90
91 public void runSQLTemplate(String path)
92 throws IOException, NamingException, SQLException {
93
94 DB db = DBFactoryUtil.getDB();
95
96 db.runSQLTemplate(path);
97 }
98
99 public void runSQLTemplate(String path, boolean failOnError)
100 throws IOException, NamingException, SQLException {
101
102 DB db = DBFactoryUtil.getDB();
103
104 db.runSQLTemplate(path, failOnError);
105 }
106
107 public void upgrade() throws UpgradeException {
108 try {
109 if (_log.isInfoEnabled()) {
110 _log.info("Upgrading " + getClass().getName());
111 }
112
113 doUpgrade();
114 }
115 catch (Exception e) {
116 throw new UpgradeException(e);
117 }
118 }
119
120 public void upgrade(Class<?> upgradeProcessClass)
121 throws UpgradeException {
122
123 UpgradeProcess upgradeProcess = null;
124
125 try {
126 upgradeProcess = (UpgradeProcess)upgradeProcessClass.newInstance();
127 }
128 catch (Exception e) {
129 throw new UpgradeException(e);
130 }
131
132 upgradeProcess.upgrade();
133 }
134
135 public void upgrade(UpgradeProcess upgradeProcess)
136 throws UpgradeException {
137
138 upgradeProcess.upgrade();
139 }
140
141 protected void doUpgrade() throws Exception {
142 }
143
144 private static Log _log = LogFactoryUtil.getLog(UpgradeProcess.class);
145
146 }