|  1 |     | 
   package org.apache.torque.mojo;  | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
     | 
  |  17 |     | 
     | 
  |  18 |     | 
     | 
  |  19 |     | 
     | 
  |  20 |     | 
     | 
  |  21 |     | 
     | 
  |  22 |     | 
   import java.io.File;  | 
  |  23 |     | 
   import java.lang.reflect.InvocationTargetException;  | 
  |  24 |     | 
   import java.sql.Connection;  | 
  |  25 |     | 
   import java.sql.SQLException;  | 
  |  26 |     | 
   import java.util.Collection;  | 
  |  27 |     | 
   import java.util.Map;  | 
  |  28 |     | 
   import java.util.Properties;  | 
  |  29 |     | 
   import java.util.Vector;  | 
  |  30 |     | 
     | 
  |  31 |     | 
   import org.apache.commons.beanutils.BeanUtils;  | 
  |  32 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  33 |     | 
   import org.apache.maven.plugin.MojoExecutionException;  | 
  |  34 |     | 
   import org.apache.maven.settings.Server;  | 
  |  35 |     | 
   import org.apache.maven.shared.filtering.MavenFileFilter;  | 
  |  36 |     | 
   import org.apache.torque.engine.platform.Platform;  | 
  |  37 |     | 
   import org.apache.torque.engine.platform.PlatformFactory;  | 
  |  38 |     | 
   import org.apache.torque.util.JdbcConfigurer;  | 
  |  39 |     | 
   import org.apache.torque.util.MojoDatabaseListener;  | 
  |  40 |     | 
   import org.kuali.core.db.torque.PropertyHandlingException;  | 
  |  41 |     | 
   import org.kuali.core.db.torque.Utils;  | 
  |  42 |     | 
   import org.kuali.db.ConnectionHandler;  | 
  |  43 |     | 
   import org.kuali.db.Credentials;  | 
  |  44 |     | 
   import org.kuali.db.JDBCUtils;  | 
  |  45 |     | 
   import org.kuali.db.SQLExecutor;  | 
  |  46 |     | 
   import org.kuali.db.Transaction;  | 
  |  47 |     | 
     | 
  |  48 |     | 
   import static org.apache.commons.lang.StringUtils.*;  | 
  |  49 |     | 
     | 
  |  50 |     | 
     | 
  |  51 |     | 
     | 
  |  52 |     | 
     | 
  |  53 |    0 |    public abstract class AbstractSQLExecutorMojo extends BaseMojo { | 
  |  54 |    0 |            Utils utils = new Utils();  | 
  |  55 |     | 
           JDBCUtils jdbcUtils;  | 
  |  56 |     | 
           ConnectionHandler connectionHandler;  | 
  |  57 |     | 
           Platform platform;  | 
  |  58 |     | 
     | 
  |  59 |     | 
           public static final String DRIVER_INFO_PROPERTIES_USER = "user";  | 
  |  60 |     | 
           public static final String DRIVER_INFO_PROPERTIES_PASSWORD = "password";  | 
  |  61 |     | 
     | 
  |  62 |     | 
             | 
  |  63 |     | 
     | 
  |  64 |     | 
     | 
  |  65 |     | 
           public static final String FILE_SORTING_ASC = "ascending";  | 
  |  66 |     | 
     | 
  |  67 |     | 
             | 
  |  68 |     | 
     | 
  |  69 |     | 
     | 
  |  70 |     | 
           public static final String FILE_SORTING_DSC = "descending";  | 
  |  71 |     | 
     | 
  |  72 |     | 
             | 
  |  73 |     | 
     | 
  |  74 |     | 
             | 
  |  75 |     | 
     | 
  |  76 |     | 
     | 
  |  77 |     | 
     | 
  |  78 |     | 
     | 
  |  79 |     | 
     | 
  |  80 |     | 
     | 
  |  81 |     | 
           String targetDatabase;  | 
  |  82 |     | 
     | 
  |  83 |     | 
             | 
  |  84 |     | 
     | 
  |  85 |     | 
     | 
  |  86 |     | 
     | 
  |  87 |     | 
     | 
  |  88 |     | 
     | 
  |  89 |     | 
           String username;  | 
  |  90 |     | 
     | 
  |  91 |     | 
             | 
  |  92 |     | 
     | 
  |  93 |     | 
     | 
  |  94 |     | 
     | 
  |  95 |     | 
     | 
  |  96 |     | 
     | 
  |  97 |     | 
           String password;  | 
  |  98 |     | 
     | 
  |  99 |     | 
             | 
  |  100 |     | 
     | 
  |  101 |     | 
     | 
  |  102 |     | 
     | 
  |  103 |     | 
     | 
  |  104 |     | 
           boolean enableAnonymousPassword;  | 
  |  105 |     | 
     | 
  |  106 |     | 
             | 
  |  107 |     | 
     | 
  |  108 |     | 
     | 
  |  109 |     | 
     | 
  |  110 |     | 
     | 
  |  111 |     | 
           boolean enableAnonymousUsername;  | 
  |  112 |     | 
     | 
  |  113 |     | 
             | 
  |  114 |     | 
     | 
  |  115 |     | 
     | 
  |  116 |     | 
     | 
  |  117 |     | 
     | 
  |  118 |     | 
           String driverProperties;  | 
  |  119 |     | 
     | 
  |  120 |     | 
             | 
  |  121 |     | 
     | 
  |  122 |     | 
     | 
  |  123 |     | 
     | 
  |  124 |     | 
     | 
  |  125 |     | 
           boolean showPassword;  | 
  |  126 |     | 
     | 
  |  127 |     | 
             | 
  |  128 |     | 
     | 
  |  129 |     | 
     | 
  |  130 |     | 
     | 
  |  131 |     | 
     | 
  |  132 |     | 
           String settingsKey;  | 
  |  133 |     | 
     | 
  |  134 |     | 
             | 
  |  135 |     | 
     | 
  |  136 |     | 
     | 
  |  137 |     | 
     | 
  |  138 |     | 
     | 
  |  139 |     | 
     | 
  |  140 |     | 
           boolean skipOnConnectionError;  | 
  |  141 |     | 
     | 
  |  142 |     | 
             | 
  |  143 |     | 
     | 
  |  144 |     | 
     | 
  |  145 |     | 
     | 
  |  146 |     | 
     | 
  |  147 |    0 |            String sqlCommand = "";  | 
  |  148 |     | 
     | 
  |  149 |     | 
             | 
  |  150 |     | 
     | 
  |  151 |     | 
     | 
  |  152 |     | 
     | 
  |  153 |     | 
     | 
  |  154 |     | 
           File[] srcFiles;  | 
  |  155 |     | 
     | 
  |  156 |     | 
             | 
  |  157 |     | 
             | 
  |  158 |     | 
     | 
  |  159 |     | 
     | 
  |  160 |     | 
     | 
  |  161 |     | 
     | 
  |  162 |     | 
           String url;  | 
  |  163 |     | 
     | 
  |  164 |     | 
             | 
  |  165 |     | 
     | 
  |  166 |     | 
     | 
  |  167 |     | 
     | 
  |  168 |     | 
     | 
  |  169 |     | 
     | 
  |  170 |     | 
     | 
  |  171 |     | 
     | 
  |  172 |     | 
           String driver;  | 
  |  173 |     | 
     | 
  |  174 |     | 
             | 
  |  175 |     | 
             | 
  |  176 |     | 
     | 
  |  177 |     | 
     | 
  |  178 |     | 
     | 
  |  179 |     | 
     | 
  |  180 |     | 
           boolean autocommit;  | 
  |  181 |     | 
     | 
  |  182 |     | 
             | 
  |  183 |     | 
     | 
  |  184 |     | 
     | 
  |  185 |     | 
     | 
  |  186 |     | 
     | 
  |  187 |    0 |            String onError = SQLExecutor.ON_ERROR_ABORT;  | 
  |  188 |     | 
     | 
  |  189 |     | 
             | 
  |  190 |     | 
     | 
  |  191 |     | 
             | 
  |  192 |     | 
     | 
  |  193 |     | 
     | 
  |  194 |     | 
     | 
  |  195 |     | 
     | 
  |  196 |    0 |            String delimiter = "/";  | 
  |  197 |     | 
     | 
  |  198 |     | 
             | 
  |  199 |     | 
     | 
  |  200 |     | 
     | 
  |  201 |     | 
     | 
  |  202 |     | 
     | 
  |  203 |     | 
     | 
  |  204 |     | 
     | 
  |  205 |     | 
     | 
  |  206 |     | 
     | 
  |  207 |    0 |            String delimiterType = DelimiterType.ROW;  | 
  |  208 |     | 
     | 
  |  209 |     | 
             | 
  |  210 |     | 
     | 
  |  211 |     | 
     | 
  |  212 |     | 
     | 
  |  213 |     | 
     | 
  |  214 |    0 |            boolean keepFormat = true;  | 
  |  215 |     | 
     | 
  |  216 |     | 
             | 
  |  217 |     | 
     | 
  |  218 |     | 
     | 
  |  219 |     | 
     | 
  |  220 |     | 
     | 
  |  221 |    0 |            boolean showheaders = true;  | 
  |  222 |     | 
     | 
  |  223 |     | 
             | 
  |  224 |     | 
     | 
  |  225 |     | 
     | 
  |  226 |     | 
     | 
  |  227 |     | 
     | 
  |  228 |    0 |            boolean append = false;  | 
  |  229 |     | 
     | 
  |  230 |     | 
             | 
  |  231 |     | 
     | 
  |  232 |     | 
     | 
  |  233 |     | 
     | 
  |  234 |     | 
     | 
  |  235 |     | 
     | 
  |  236 |    0 |            boolean escapeProcessing = true;  | 
  |  237 |     | 
     | 
  |  238 |     | 
             | 
  |  239 |     | 
     | 
  |  240 |     | 
             | 
  |  241 |     | 
     | 
  |  242 |     | 
     | 
  |  243 |    0 |            int successfulStatements = 0;  | 
  |  244 |     | 
     | 
  |  245 |     | 
             | 
  |  246 |     | 
     | 
  |  247 |     | 
     | 
  |  248 |    0 |            int totalStatements = 0;  | 
  |  249 |     | 
     | 
  |  250 |     | 
             | 
  |  251 |     | 
     | 
  |  252 |     | 
     | 
  |  253 |    0 |            Connection conn = null;  | 
  |  254 |     | 
     | 
  |  255 |     | 
             | 
  |  256 |     | 
     | 
  |  257 |     | 
     | 
  |  258 |    0 |            Vector<Transaction> transactions = new Vector<Transaction>();  | 
  |  259 |     | 
     | 
  |  260 |     | 
             | 
  |  261 |     | 
     | 
  |  262 |     | 
     | 
  |  263 |     | 
           MavenFileFilter fileFilter;  | 
  |  264 |     | 
     | 
  |  265 |     | 
             | 
  |  266 |     | 
     | 
  |  267 |     | 
     | 
  |  268 |     | 
           Credentials credentials;  | 
  |  269 |     | 
     | 
  |  270 |     | 
           protected void configureTransactions() throws MojoExecutionException { | 
  |  271 |     | 
                     | 
  |  272 |    0 |            }  | 
  |  273 |     | 
     | 
  |  274 |     | 
           protected Properties getContextProperties() { | 
  |  275 |    0 |                    Properties properties = new Properties();  | 
  |  276 |    0 |                    Map<String, String> environment = System.getenv();  | 
  |  277 |    0 |                    for (String key : environment.keySet()) { | 
  |  278 |    0 |                            properties.put("env." + key, environment.get(key)); | 
  |  279 |     | 
                   }  | 
  |  280 |    0 |                    properties.putAll(getProject().getProperties());  | 
  |  281 |    0 |                    properties.putAll(System.getProperties());  | 
  |  282 |    0 |                    return properties;  | 
  |  283 |     | 
           }  | 
  |  284 |     | 
     | 
  |  285 |     | 
           protected Credentials getNewCredentials() { | 
  |  286 |    0 |                    Credentials credentials = new Credentials();  | 
  |  287 |    0 |                    credentials.setUsername(getUsername());  | 
  |  288 |    0 |                    credentials.setPassword(getPassword());  | 
  |  289 |    0 |                    return credentials;  | 
  |  290 |     | 
           }  | 
  |  291 |     | 
     | 
  |  292 |     | 
           protected ConnectionHandler getNewConnectionHandler() throws MojoExecutionException { | 
  |  293 |    0 |                    ConnectionHandler connectionHandler = new ConnectionHandler();  | 
  |  294 |     | 
                   try { | 
  |  295 |    0 |                            BeanUtils.copyProperties(connectionHandler, this);  | 
  |  296 |    0 |                            return connectionHandler;  | 
  |  297 |    0 |                    } catch (Exception e) { | 
  |  298 |    0 |                            throw new MojoExecutionException("Error establishing connection", e); | 
  |  299 |     | 
                   }  | 
  |  300 |     | 
           }  | 
  |  301 |     | 
     | 
  |  302 |     | 
             | 
  |  303 |     | 
     | 
  |  304 |     | 
     | 
  |  305 |     | 
     | 
  |  306 |     | 
     | 
  |  307 |     | 
           public void executeMojo() throws MojoExecutionException { | 
  |  308 |    0 |                    jdbcUtils = new JDBCUtils();  | 
  |  309 |    0 |                    updateConfiguration();  | 
  |  310 |    0 |                    Credentials credentials = getNewCredentials();  | 
  |  311 |    0 |                    updateCredentials(credentials);  | 
  |  312 |    0 |                    validateCredentials(credentials);  | 
  |  313 |    0 |                    setCredentials(credentials);  | 
  |  314 |    0 |                    validateConfiguration();  | 
  |  315 |     | 
     | 
  |  316 |    0 |                    connectionHandler = getNewConnectionHandler();  | 
  |  317 |    0 |                    conn = getConnection();  | 
  |  318 |     | 
     | 
  |  319 |    0 |                    if (connectionHandler.isConnectionError() && skipOnConnectionError) { | 
  |  320 |     | 
                             | 
  |  321 |     | 
                             | 
  |  322 |    0 |                            return;  | 
  |  323 |     | 
                   }  | 
  |  324 |     | 
     | 
  |  325 |     | 
                     | 
  |  326 |    0 |                    configureTransactions();  | 
  |  327 |     | 
     | 
  |  328 |     | 
                     | 
  |  329 |    0 |                    successfulStatements = 0;  | 
  |  330 |    0 |                    totalStatements = 0;  | 
  |  331 |     | 
     | 
  |  332 |     | 
                     | 
  |  333 |    0 |                    SQLExecutor executor = getSqlExecutor();  | 
  |  334 |     | 
     | 
  |  335 |     | 
                   try { | 
  |  336 |    0 |                            executor.execute();  | 
  |  337 |    0 |                    } catch (SQLException e) { | 
  |  338 |    0 |                            throw new MojoExecutionException("Error executing SQL", e); | 
  |  339 |    0 |                    }  | 
  |  340 |    0 |            }  | 
  |  341 |     | 
     | 
  |  342 |     | 
             | 
  |  343 |     | 
     | 
  |  344 |     | 
     | 
  |  345 |     | 
     | 
  |  346 |     | 
     | 
  |  347 |     | 
     | 
  |  348 |     | 
           public void addText(String sql) { | 
  |  349 |    0 |                    this.sqlCommand += sql;  | 
  |  350 |    0 |            }  | 
  |  351 |     | 
     | 
  |  352 |     | 
             | 
  |  353 |     | 
     | 
  |  354 |     | 
     | 
  |  355 |     | 
     | 
  |  356 |     | 
     | 
  |  357 |     | 
     | 
  |  358 |     | 
           public void setDelimiter(String delimiter) { | 
  |  359 |    0 |                    this.delimiter = delimiter;  | 
  |  360 |    0 |            }  | 
  |  361 |     | 
     | 
  |  362 |     | 
             | 
  |  363 |     | 
     | 
  |  364 |     | 
     | 
  |  365 |     | 
     | 
  |  366 |     | 
     | 
  |  367 |     | 
     | 
  |  368 |     | 
           public void setDelimiterType(String delimiterType) { | 
  |  369 |    0 |                    this.delimiterType = delimiterType;  | 
  |  370 |    0 |            }  | 
  |  371 |     | 
     | 
  |  372 |     | 
             | 
  |  373 |     | 
     | 
  |  374 |     | 
     | 
  |  375 |     | 
     | 
  |  376 |     | 
     | 
  |  377 |     | 
     | 
  |  378 |     | 
           public void setShowheaders(boolean showheaders) { | 
  |  379 |    0 |                    this.showheaders = showheaders;  | 
  |  380 |    0 |            }  | 
  |  381 |     | 
     | 
  |  382 |     | 
             | 
  |  383 |     | 
     | 
  |  384 |     | 
     | 
  |  385 |     | 
     | 
  |  386 |     | 
     | 
  |  387 |     | 
     | 
  |  388 |     | 
           public void setAppend(boolean append) { | 
  |  389 |    0 |                    this.append = append;  | 
  |  390 |    0 |            }  | 
  |  391 |     | 
     | 
  |  392 |     | 
             | 
  |  393 |     | 
     | 
  |  394 |     | 
     | 
  |  395 |     | 
     | 
  |  396 |     | 
     | 
  |  397 |     | 
     | 
  |  398 |     | 
           public void setKeepFormat(boolean keepformat) { | 
  |  399 |    0 |                    this.keepFormat = keepformat;  | 
  |  400 |    0 |            }  | 
  |  401 |     | 
     | 
  |  402 |     | 
             | 
  |  403 |     | 
     | 
  |  404 |     | 
     | 
  |  405 |     | 
     | 
  |  406 |     | 
     | 
  |  407 |     | 
     | 
  |  408 |     | 
           public void setEscapeProcessing(boolean enable) { | 
  |  409 |    0 |                    escapeProcessing = enable;  | 
  |  410 |    0 |            }  | 
  |  411 |     | 
     | 
  |  412 |     | 
           protected SQLExecutor getSqlExecutor() throws MojoExecutionException { | 
  |  413 |     | 
                   try { | 
  |  414 |    0 |                            SQLExecutor executor = new SQLExecutor();  | 
  |  415 |    0 |                            BeanUtils.copyProperties(executor, this);  | 
  |  416 |    0 |                            executor.addListener(new MojoDatabaseListener(getLog()));  | 
  |  417 |    0 |                            return executor;  | 
  |  418 |    0 |                    } catch (InvocationTargetException e) { | 
  |  419 |    0 |                            throw new MojoExecutionException("Error copying properties from the mojo to the SQL executor", e); | 
  |  420 |    0 |                    } catch (IllegalAccessException e) { | 
  |  421 |    0 |                            throw new MojoExecutionException("Error copying properties from the mojo to the SQL executor", e); | 
  |  422 |     | 
                   }  | 
  |  423 |     | 
           }  | 
  |  424 |     | 
     | 
  |  425 |     | 
             | 
  |  426 |     | 
     | 
  |  427 |     | 
     | 
  |  428 |     | 
     | 
  |  429 |     | 
           protected void updateConfiguration() throws MojoExecutionException { | 
  |  430 |     | 
                   try { | 
  |  431 |    0 |                            new JdbcConfigurer().updateConfiguration(this);  | 
  |  432 |    0 |                    } catch (PropertyHandlingException e) { | 
  |  433 |    0 |                            throw new MojoExecutionException("Error handling properties", e); | 
  |  434 |    0 |                    }  | 
  |  435 |    0 |                    platform = PlatformFactory.getPlatformFor(targetDatabase);  | 
  |  436 |    0 |            }  | 
  |  437 |     | 
     | 
  |  438 |     | 
             | 
  |  439 |     | 
     | 
  |  440 |     | 
     | 
  |  441 |     | 
           protected void validateConfiguration() throws MojoExecutionException { | 
  |  442 |    0 |                    new JdbcConfigurer().validateConfiguration(this);  | 
  |  443 |    0 |            }  | 
  |  444 |     | 
     | 
  |  445 |     | 
           protected void validateCredentials(Credentials credentials, boolean anonymousAccessAllowed, String validationFailureMessage) throws MojoExecutionException { | 
  |  446 |    0 |                    if (anonymousAccessAllowed) { | 
  |  447 |     | 
                             | 
  |  448 |    0 |                            return;  | 
  |  449 |     | 
                   }  | 
  |  450 |    0 |                    String username = credentials.getUsername();  | 
  |  451 |    0 |                    String password = credentials.getPassword();  | 
  |  452 |    0 |                    if (!isEmpty(username) && !isEmpty(password)) { | 
  |  453 |     | 
                             | 
  |  454 |    0 |                            return;  | 
  |  455 |     | 
                   }  | 
  |  456 |    0 |                    throw new MojoExecutionException(validationFailureMessage);  | 
  |  457 |     | 
           }  | 
  |  458 |     | 
     | 
  |  459 |     | 
           protected void validateCredentials(Credentials credentials) throws MojoExecutionException { | 
  |  460 |     | 
                     | 
  |  461 |    0 |                    StringBuffer sb = new StringBuffer();  | 
  |  462 |    0 |                    sb.append("\n\n"); | 
  |  463 |    0 |                    sb.append("Username and password must be specified.\n"); | 
  |  464 |    0 |                    sb.append("Specify them in the plugin configuration or as a system property.\n"); | 
  |  465 |    0 |                    sb.append("\n"); | 
  |  466 |    0 |                    sb.append("For example:\n"); | 
  |  467 |    0 |                    sb.append("-Dusername=myuser\n"); | 
  |  468 |    0 |                    sb.append("-Dpassword=mypassword\n"); | 
  |  469 |    0 |                    sb.append("\n."); | 
  |  470 |    0 |                    validateCredentials(credentials, enableAnonymousUsername && enableAnonymousPassword, sb.toString());  | 
  |  471 |    0 |            }  | 
  |  472 |     | 
     | 
  |  473 |     | 
           protected boolean isNullOrEmpty(Collection<?> c) { | 
  |  474 |    0 |                    if (c == null) { | 
  |  475 |    0 |                            return true;  | 
  |  476 |     | 
                   }  | 
  |  477 |    0 |                    if (c.size() == 0) { | 
  |  478 |    0 |                            return true;  | 
  |  479 |     | 
                   }  | 
  |  480 |    0 |                    return false;  | 
  |  481 |     | 
           }  | 
  |  482 |     | 
     | 
  |  483 |     | 
           protected String convertNullToEmpty(String s) { | 
  |  484 |    0 |                    if (s == null) { | 
  |  485 |    0 |                            return "";  | 
  |  486 |     | 
                   } else { | 
  |  487 |    0 |                            return s;  | 
  |  488 |     | 
                   }  | 
  |  489 |     | 
           }  | 
  |  490 |     | 
     | 
  |  491 |     | 
             | 
  |  492 |     | 
     | 
  |  493 |     | 
     | 
  |  494 |     | 
     | 
  |  495 |     | 
     | 
  |  496 |     | 
           protected void updateCredentials(Credentials credentials) { | 
  |  497 |    0 |                    Server server = getServerFromSettingsKey();  | 
  |  498 |    0 |                    String username = getUpdatedUsername(server, credentials.getUsername());  | 
  |  499 |    0 |                    String password = getUpdatedPassword(server, credentials.getPassword());  | 
  |  500 |    0 |                    credentials.setUsername(convertNullToEmpty(username));  | 
  |  501 |    0 |                    credentials.setPassword(convertNullToEmpty(password));  | 
  |  502 |    0 |            }  | 
  |  503 |     | 
     | 
  |  504 |     | 
           protected Server getServerFromSettingsKey() { | 
  |  505 |    0 |                    Server server = getSettings().getServer(getSettingsKey());  | 
  |  506 |    0 |                    if (server == null) { | 
  |  507 |     | 
                             | 
  |  508 |    0 |                            return getSettings().getServer("impex." + getUrl()); | 
  |  509 |     | 
                   } else { | 
  |  510 |    0 |                            return null;  | 
  |  511 |     | 
                   }  | 
  |  512 |     | 
           }  | 
  |  513 |     | 
     | 
  |  514 |     | 
           protected String getUpdatedPassword(Server server, String password) { | 
  |  515 |     | 
                     | 
  |  516 |    0 |                    if (!isEmpty(password)) { | 
  |  517 |    0 |                            return password;  | 
  |  518 |     | 
                   }  | 
  |  519 |    0 |                    if (server != null) { | 
  |  520 |     | 
                             | 
  |  521 |    0 |                            getLog().info("Located a password in settings.xml under the server id '" + server.getId() + "' Password: " + getDisplayPassword(server.getPassword())); | 
  |  522 |    0 |                            return server.getPassword();  | 
  |  523 |     | 
                   }  | 
  |  524 |    0 |                    getLog().info("Using default password generated from the artifact id"); | 
  |  525 |    0 |                    return platform.getSchemaName(getProject().getArtifactId());  | 
  |  526 |     | 
           }  | 
  |  527 |     | 
     | 
  |  528 |     | 
           protected String getDisplayPassword(String password) { | 
  |  529 |    0 |                    if (isShowPassword()) { | 
  |  530 |    0 |                            return password;  | 
  |  531 |     | 
                   } else { | 
  |  532 |    0 |                            return StringUtils.repeat("*", password.length()); | 
  |  533 |     | 
                   }  | 
  |  534 |     | 
           }  | 
  |  535 |     | 
     | 
  |  536 |     | 
           protected String getUpdatedUsername(Server server, String username) { | 
  |  537 |     | 
                     | 
  |  538 |    0 |                    if (!isEmpty(username)) { | 
  |  539 |    0 |                            return username;  | 
  |  540 |     | 
                   }  | 
  |  541 |    0 |                    if (server != null) { | 
  |  542 |     | 
                             | 
  |  543 |    0 |                            getLog().info("Located a username in settings.xml under the server id '" + server.getId() + "' Username: " + server.getUsername()); | 
  |  544 |    0 |                            return server.getUsername();  | 
  |  545 |     | 
                   }  | 
  |  546 |    0 |                    getLog().info("Using default username generated from the artifact id"); | 
  |  547 |    0 |                    return platform.getSchemaName(getProject().getArtifactId());  | 
  |  548 |     | 
           }  | 
  |  549 |     | 
     | 
  |  550 |     | 
             | 
  |  551 |     | 
     | 
  |  552 |     | 
     | 
  |  553 |     | 
     | 
  |  554 |     | 
     | 
  |  555 |     | 
     | 
  |  556 |     | 
     | 
  |  557 |     | 
     | 
  |  558 |     | 
     | 
  |  559 |     | 
     | 
  |  560 |     | 
     | 
  |  561 |     | 
     | 
  |  562 |     | 
           protected Connection getConnection() throws MojoExecutionException { | 
  |  563 |     | 
                   try { | 
  |  564 |    0 |                            return connectionHandler.getConnection();  | 
  |  565 |    0 |                    } catch (Exception e) { | 
  |  566 |    0 |                            throw new MojoExecutionException("Error establishing connection", e); | 
  |  567 |     | 
                   }  | 
  |  568 |     | 
           }  | 
  |  569 |     | 
     | 
  |  570 |     | 
             | 
  |  571 |     | 
     | 
  |  572 |     | 
     | 
  |  573 |     | 
     | 
  |  574 |     | 
     | 
  |  575 |     | 
     | 
  |  576 |     | 
           protected Properties getDriverProperties() throws MojoExecutionException { | 
  |  577 |    0 |                    Properties properties = new Properties();  | 
  |  578 |     | 
     | 
  |  579 |    0 |                    if (isEmpty(this.driverProperties)) { | 
  |  580 |    0 |                            return properties;  | 
  |  581 |     | 
                   }  | 
  |  582 |     | 
     | 
  |  583 |    0 |                    String[] tokens = split(this.driverProperties, ",");  | 
  |  584 |    0 |                    for (int i = 0; i < tokens.length; ++i) { | 
  |  585 |    0 |                            String[] keyValueTokens = split(tokens[i].trim(), "=");  | 
  |  586 |    0 |                            if (keyValueTokens.length != 2) { | 
  |  587 |    0 |                                    throw new MojoExecutionException("Invalid JDBC Driver properties: " + this.driverProperties); | 
  |  588 |     | 
                           }  | 
  |  589 |    0 |                            properties.setProperty(keyValueTokens[0], keyValueTokens[1]);  | 
  |  590 |     | 
                   }  | 
  |  591 |    0 |                    return properties;  | 
  |  592 |     | 
           }  | 
  |  593 |     | 
     | 
  |  594 |     | 
           public String getUsername() { | 
  |  595 |    0 |                    return this.username;  | 
  |  596 |     | 
           }  | 
  |  597 |     | 
     | 
  |  598 |     | 
           public void setUsername(String username) { | 
  |  599 |    0 |                    this.username = username;  | 
  |  600 |    0 |            }  | 
  |  601 |     | 
     | 
  |  602 |     | 
           public String getPassword() { | 
  |  603 |    0 |                    return this.password;  | 
  |  604 |     | 
           }  | 
  |  605 |     | 
     | 
  |  606 |     | 
           public void setPassword(String password) { | 
  |  607 |    0 |                    this.password = password;  | 
  |  608 |    0 |            }  | 
  |  609 |     | 
     | 
  |  610 |     | 
           public String getUrl() { | 
  |  611 |    0 |                    return this.url;  | 
  |  612 |     | 
           }  | 
  |  613 |     | 
     | 
  |  614 |     | 
           public void setUrl(String url) { | 
  |  615 |    0 |                    this.url = url;  | 
  |  616 |    0 |            }  | 
  |  617 |     | 
     | 
  |  618 |     | 
           public String getDriver() { | 
  |  619 |    0 |                    return this.driver;  | 
  |  620 |     | 
           }  | 
  |  621 |     | 
     | 
  |  622 |     | 
           public void setDriver(String driver) { | 
  |  623 |    0 |                    this.driver = driver;  | 
  |  624 |    0 |            }  | 
  |  625 |     | 
     | 
  |  626 |     | 
           public void setAutocommit(boolean autocommit) { | 
  |  627 |    0 |                    this.autocommit = autocommit;  | 
  |  628 |    0 |            }  | 
  |  629 |     | 
     | 
  |  630 |     | 
           public File[] getSrcFiles() { | 
  |  631 |    0 |                    return this.srcFiles;  | 
  |  632 |     | 
           }  | 
  |  633 |     | 
     | 
  |  634 |     | 
           public void setSrcFiles(File[] files) { | 
  |  635 |    0 |                    this.srcFiles = files;  | 
  |  636 |    0 |            }  | 
  |  637 |     | 
     | 
  |  638 |     | 
             | 
  |  639 |     | 
     | 
  |  640 |     | 
     | 
  |  641 |     | 
     | 
  |  642 |     | 
     | 
  |  643 |     | 
           public int getSuccessfulStatements() { | 
  |  644 |    0 |                    return successfulStatements;  | 
  |  645 |     | 
           }  | 
  |  646 |     | 
     | 
  |  647 |     | 
             | 
  |  648 |     | 
     | 
  |  649 |     | 
     | 
  |  650 |     | 
     | 
  |  651 |     | 
     | 
  |  652 |     | 
           public int getTotalStatements() { | 
  |  653 |    0 |                    return totalStatements;  | 
  |  654 |     | 
           }  | 
  |  655 |     | 
     | 
  |  656 |     | 
           public String getOnError() { | 
  |  657 |    0 |                    return this.onError;  | 
  |  658 |     | 
           }  | 
  |  659 |     | 
     | 
  |  660 |     | 
           public void setOnError(String action) { | 
  |  661 |    0 |                    if (SQLExecutor.ON_ERROR_ABORT.equalsIgnoreCase(action)) { | 
  |  662 |    0 |                            this.onError = SQLExecutor.ON_ERROR_ABORT;  | 
  |  663 |    0 |                    } else if (SQLExecutor.ON_ERROR_CONTINUE.equalsIgnoreCase(action)) { | 
  |  664 |    0 |                            this.onError = SQLExecutor.ON_ERROR_CONTINUE;  | 
  |  665 |    0 |                    } else if (SQLExecutor.ON_ERROR_ABORT_AFTER.equalsIgnoreCase(action)) { | 
  |  666 |    0 |                            this.onError = SQLExecutor.ON_ERROR_ABORT_AFTER;  | 
  |  667 |     | 
                   } else { | 
  |  668 |    0 |                            throw new IllegalArgumentException(action + " is not a valid value for onError, only '" + SQLExecutor.ON_ERROR_ABORT + "', '" + SQLExecutor.ON_ERROR_ABORT_AFTER + "', or '" + SQLExecutor.ON_ERROR_CONTINUE + "'.");  | 
  |  669 |     | 
                   }  | 
  |  670 |    0 |            }  | 
  |  671 |     | 
     | 
  |  672 |     | 
           public void setSettingsKey(String key) { | 
  |  673 |    0 |                    this.settingsKey = key;  | 
  |  674 |    0 |            }  | 
  |  675 |     | 
     | 
  |  676 |     | 
           public void setDriverProperties(String driverProperties) { | 
  |  677 |    0 |                    this.driverProperties = driverProperties;  | 
  |  678 |    0 |            }  | 
  |  679 |     | 
     | 
  |  680 |     | 
           public String getSqlCommand() { | 
  |  681 |    0 |                    return sqlCommand;  | 
  |  682 |     | 
           }  | 
  |  683 |     | 
     | 
  |  684 |     | 
           public void setSqlCommand(String sqlCommand) { | 
  |  685 |    0 |                    this.sqlCommand = sqlCommand;  | 
  |  686 |    0 |            }  | 
  |  687 |     | 
     | 
  |  688 |     | 
           public Vector<Transaction> getTransactions() { | 
  |  689 |    0 |                    return transactions;  | 
  |  690 |     | 
           }  | 
  |  691 |     | 
     | 
  |  692 |     | 
           public void setTransactions(Vector<Transaction> transactions) { | 
  |  693 |    0 |                    this.transactions = transactions;  | 
  |  694 |    0 |            }  | 
  |  695 |     | 
     | 
  |  696 |     | 
           public void setFileFilter(MavenFileFilter filter) { | 
  |  697 |    0 |                    this.fileFilter = filter;  | 
  |  698 |    0 |            }  | 
  |  699 |     | 
     | 
  |  700 |     | 
           public String getTargetDatabase() { | 
  |  701 |    0 |                    return targetDatabase;  | 
  |  702 |     | 
           }  | 
  |  703 |     | 
     | 
  |  704 |     | 
           public void setTargetDatabase(String targetDatabase) { | 
  |  705 |    0 |                    this.targetDatabase = targetDatabase;  | 
  |  706 |    0 |            }  | 
  |  707 |     | 
     | 
  |  708 |     | 
           public Connection getConn() { | 
  |  709 |    0 |                    return conn;  | 
  |  710 |     | 
           }  | 
  |  711 |     | 
     | 
  |  712 |     | 
           public void setConn(Connection conn) { | 
  |  713 |    0 |                    this.conn = conn;  | 
  |  714 |    0 |            }  | 
  |  715 |     | 
     | 
  |  716 |     | 
           public String getDelimiter() { | 
  |  717 |    0 |                    return delimiter;  | 
  |  718 |     | 
           }  | 
  |  719 |     | 
     | 
  |  720 |     | 
           public String getDelimiterType() { | 
  |  721 |    0 |                    return delimiterType;  | 
  |  722 |     | 
           }  | 
  |  723 |     | 
     | 
  |  724 |     | 
           public boolean isKeepFormat() { | 
  |  725 |    0 |                    return keepFormat;  | 
  |  726 |     | 
           }  | 
  |  727 |     | 
     | 
  |  728 |     | 
           public boolean isShowheaders() { | 
  |  729 |    0 |                    return showheaders;  | 
  |  730 |     | 
           }  | 
  |  731 |     | 
     | 
  |  732 |     | 
           public boolean isAppend() { | 
  |  733 |    0 |                    return append;  | 
  |  734 |     | 
           }  | 
  |  735 |     | 
     | 
  |  736 |     | 
           public boolean isEscapeProcessing() { | 
  |  737 |    0 |                    return escapeProcessing;  | 
  |  738 |     | 
           }  | 
  |  739 |     | 
     | 
  |  740 |     | 
           public boolean isSkipOnConnectionError() { | 
  |  741 |    0 |                    return skipOnConnectionError;  | 
  |  742 |     | 
           }  | 
  |  743 |     | 
     | 
  |  744 |     | 
           public void setSkipOnConnectionError(boolean skipOnConnectionError) { | 
  |  745 |    0 |                    this.skipOnConnectionError = skipOnConnectionError;  | 
  |  746 |    0 |            }  | 
  |  747 |     | 
     | 
  |  748 |     | 
           public MavenFileFilter getFileFilter() { | 
  |  749 |    0 |                    return fileFilter;  | 
  |  750 |     | 
           }  | 
  |  751 |     | 
     | 
  |  752 |     | 
           public boolean isShowPassword() { | 
  |  753 |    0 |                    return showPassword;  | 
  |  754 |     | 
           }  | 
  |  755 |     | 
     | 
  |  756 |     | 
           public void setShowPassword(boolean showPassword) { | 
  |  757 |    0 |                    this.showPassword = showPassword;  | 
  |  758 |    0 |            }  | 
  |  759 |     | 
     | 
  |  760 |     | 
           public boolean isEnableAnonymousPassword() { | 
  |  761 |    0 |                    return enableAnonymousPassword;  | 
  |  762 |     | 
           }  | 
  |  763 |     | 
     | 
  |  764 |     | 
           public void setEnableAnonymousPassword(boolean enableAnonymousPassword) { | 
  |  765 |    0 |                    this.enableAnonymousPassword = enableAnonymousPassword;  | 
  |  766 |    0 |            }  | 
  |  767 |     | 
     | 
  |  768 |     | 
           public String getSettingsKey() { | 
  |  769 |    0 |                    return settingsKey;  | 
  |  770 |     | 
           }  | 
  |  771 |     | 
     | 
  |  772 |     | 
           public boolean isAutocommit() { | 
  |  773 |    0 |                    return autocommit;  | 
  |  774 |     | 
           }  | 
  |  775 |     | 
     | 
  |  776 |     | 
           public void setSuccessfulStatements(int successfulStatements) { | 
  |  777 |    0 |                    this.successfulStatements = successfulStatements;  | 
  |  778 |    0 |            }  | 
  |  779 |     | 
     | 
  |  780 |     | 
           public void setTotalStatements(int totalStatements) { | 
  |  781 |    0 |                    this.totalStatements = totalStatements;  | 
  |  782 |    0 |            }  | 
  |  783 |     | 
     | 
  |  784 |     | 
           public void setCredentials(Credentials credentials) { | 
  |  785 |    0 |                    this.credentials = credentials;  | 
  |  786 |    0 |            }  | 
  |  787 |     | 
     | 
  |  788 |     | 
           public Credentials getCredentials() { | 
  |  789 |    0 |                    return credentials;  | 
  |  790 |     | 
           }  | 
  |  791 |     | 
     | 
  |  792 |     | 
   }  |