All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nocrala.tools.database.sentinel.ant.ShowDatabaseAntTask Maven / Gradle / Ivy

There is a newer version: 1.1.9
Show newest version
package org.nocrala.tools.database.sentinel.ant;

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.ShowDatabaseOperation;
import org.nocrala.tools.database.sentinel.util.SUtil;

public class ShowDatabaseAntTask extends Task {

  private static final Logger log = LogManager.getLogger(ShowDatabaseAntTask.class);

  private String driverclass;
  private String url;
  private String username;
  private String password;
  private String catalog;
  private String schema;

  @Override
  public void execute() {
    log.debug("init");
    validateParameters();
    try {
      new ShowDatabaseOperation(this.driverclass, this.url, this.username, this.password, this.catalog, this.schema)
          .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.");
    }
  }

  // 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;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy