org.nocrala.tools.database.sentinel.ant.VerifyDatabaseAntTask Maven / Gradle / Ivy
package org.nocrala.tools.database.sentinel.ant;
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.nocrala.tools.database.sentinel.plugin.VerifyDatabaseOperation;
import org.nocrala.tools.database.sentinel.util.SUtil;
public class VerifyDatabaseAntTask extends Task {
private static final Logger log = LogManager.getLogger(VerifyDatabaseAntTask.class);
private String driverclass;
private String url;
private String username;
private String password;
private String catalog;
private String schema;
private String snapshotfile;
@Override
public void execute() {
log.debug("init");
validateParameters();
try {
new VerifyDatabaseOperation(this.driverclass, this.url, this.username, this.password, this.catalog, this.schema,
new File(this.snapshotfile)).execute(new AntFeedback(this));
} catch (Exception e) {
throw new BuildException(e.getMessage(), e.getCause());
}
}
private void validateParameters() {
if (SUtil.isEmpty(this.driverclass)) {
throw new BuildException("Parameter 'driverclass' must be specified.");
}
if (SUtil.isEmpty(this.url)) {
throw new BuildException("Parameter 'url' must be specified.");
}
if (SUtil.isEmpty(this.username)) {
throw new BuildException("Parameter 'username' must be specified.");
}
if (SUtil.isEmpty(this.snapshotfile)) {
throw new BuildException("Parameter 'snapshotfile' must be specified.");
}
}
// Setters
public void setDriverclass(final String driverclass) {
this.driverclass = driverclass;
}
public void setUrl(final String url) {
this.url = url;
}
public void setUsername(final String username) {
this.username = username;
}
public void setPassword(final String password) {
this.password = password;
}
public void setCatalog(final String catalog) {
this.catalog = catalog;
}
public void setSchema(final String schema) {
this.schema = schema;
}
public void setSnapshotfile(final String snapshotfile) {
this.snapshotfile = snapshotfile;
}
}