001
014
015 package com.liferay.portal.verify;
016
017 import com.liferay.portal.kernel.dao.db.DB;
018 import com.liferay.portal.kernel.dao.db.DBFactoryUtil;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021
022 import java.io.IOException;
023
024 import java.sql.SQLException;
025
026 import javax.naming.NamingException;
027
028
037 public abstract class VerifyProcess {
038
039 public static final int ALWAYS = -1;
040
041 public static final int NEVER = 0;
042
043 public static final int ONCE = 1;
044
045 public void runSQL(String template) throws IOException, SQLException {
046 DB db = DBFactoryUtil.getDB();
047
048 db.runSQL(template);
049 }
050
051 public void runSQL(String[] templates) throws IOException, SQLException {
052 DB db = DBFactoryUtil.getDB();
053
054 db.runSQL(templates);
055 }
056
057 public void runSQLTemplate(String path)
058 throws IOException, NamingException, SQLException {
059
060 DB db = DBFactoryUtil.getDB();
061
062 db.runSQLTemplate(path);
063 }
064
065 public void runSQLTemplate(String path, boolean failOnError)
066 throws IOException, NamingException, SQLException {
067
068 DB db = DBFactoryUtil.getDB();
069
070 db.runSQLTemplate(path, failOnError);
071 }
072
073 public void verify() throws VerifyException {
074 try {
075 if (_log.isInfoEnabled()) {
076 _log.info("Verifying " + getClass().getName());
077 }
078
079 doVerify();
080 }
081 catch (Exception e) {
082 throw new VerifyException(e);
083 }
084 }
085
086 public void verify(VerifyProcess verifyProcess)
087 throws VerifyException {
088
089 verifyProcess.verify();
090 }
091
092 protected void doVerify() throws Exception {
093 }
094
095 private static Log _log = LogFactoryUtil.getLog(VerifyProcess.class);
096
097 }