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

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

There is a newer version: 1.1.9
Show newest version
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.TakeSnapshotOperation;
import org.nocrala.tools.database.sentinel.util.SUtil;

public class TakeSnapshotAntTask extends Task {

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

  private String alias;
  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 TakeSnapshotOperation(this.alias, 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.alias)) {
      throw new BuildException("Parameter 'alias' must be specified.");
    }
    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 setAlias(final String alias) {
    this.alias = alias;
  }

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy