1
14
15 package com.liferay.portal.verify;
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.log.Log;
20 import com.liferay.portal.kernel.log.LogFactoryUtil;
21
22 import java.io.IOException;
23
24 import java.sql.SQLException;
25
26 import javax.naming.NamingException;
27
28
40 public abstract class VerifyProcess {
41
42 public static final int ALWAYS = -1;
43
44 public static final int NEVER = 0;
45
46 public static final int ONCE = 1;
47
48 public void runSQL(String template) throws IOException, SQLException {
49 DB db = DBFactoryUtil.getDB();
50
51 db.runSQL(template);
52 }
53
54 public void runSQL(String[] templates) throws IOException, SQLException {
55 DB db = DBFactoryUtil.getDB();
56
57 db.runSQL(templates);
58 }
59
60 public void runSQLTemplate(String path)
61 throws IOException, NamingException, SQLException {
62
63 DB db = DBFactoryUtil.getDB();
64
65 db.runSQLTemplate(path);
66 }
67
68 public void runSQLTemplate(String path, boolean failOnError)
69 throws IOException, NamingException, SQLException {
70
71 DB db = DBFactoryUtil.getDB();
72
73 db.runSQLTemplate(path, failOnError);
74 }
75
76 public void verify() throws VerifyException {
77 try {
78 if (_log.isInfoEnabled()) {
79 _log.info("Verifying " + getClass().getName());
80 }
81
82 doVerify();
83 }
84 catch (Exception e) {
85 throw new VerifyException(e);
86 }
87 }
88
89 public void verify(VerifyProcess verifyProcess)
90 throws VerifyException {
91
92 verifyProcess.verify();
93 }
94
95 protected void doVerify() throws Exception {
96 }
97
98 private static Log _log = LogFactoryUtil.getLog(VerifyProcess.class);
99
100 }