View Javadoc

1   package com.rsmart.kuali.tools.ant.tasks;
2   
3   import liquibase.Liquibase;
4   import liquibase.integration.ant.BaseLiquibaseTask;
5   import liquibase.util.StringUtils;
6   import org.apache.tools.ant.BuildException;
7   
8   import java.util.List;
9   
10  public class DropAllTask extends BaseLiquibaseTask {
11  
12      private String schemas;
13  
14      public String getSchemas() {
15          return schemas;
16      }
17  
18      public void setSchemas(String schemas) {
19          this.schemas = schemas;
20      }
21      
22      public void execute() throws BuildException {
23          Liquibase liquibase = null;
24          try {
25              liquibase = createLiquibase();
26              boolean retry = true;
27              while (retry) {
28                  try {
29                      if (StringUtils.trimToNull(schemas) != null) {
30                          List<String> schemas = StringUtils.splitAndTrim(this.schemas, ",");
31                          liquibase.dropAll(schemas.toArray(new String[schemas.size()]));
32                      } else {
33                          liquibase.dropAll();
34                      }
35                      retry = false;
36                  }
37                  catch (Exception e2) {
38                      log(e2.getMessage());
39                      if (e2.getMessage().indexOf("ORA-02443") < 0 && e2.getCause() != null && retry) {
40                          retry = (e2.getCause().getMessage().indexOf("ORA-02443") > -1);
41                      }
42                      
43                      if (!retry) {
44                          throw e2;
45                      }
46                      else {
47                          log("Got ORA-2443. Retrying...");
48                      }
49                  }
50              }       
51          } catch (Exception e) {
52              throw new BuildException(e);
53          } finally {
54              closeDatabase(liquibase);
55          }
56      }
57  }