001 package org.apache.torque.mojo; 002 003 import java.util.Properties; 004 005 import org.apache.commons.lang.StringUtils; 006 007 public class ImpexError { 008 Throwable throwable; 009 String message; 010 Properties info; 011 String url; 012 String driver; 013 boolean showPassword; 014 015 public Throwable getThrowable() { 016 return throwable; 017 } 018 019 public void setThrowable(Throwable throwable) { 020 this.throwable = throwable; 021 } 022 023 public String getMessage() { 024 return message; 025 } 026 027 public void setMessage(String message) { 028 this.message = message; 029 } 030 031 public Properties getInfo() { 032 return info; 033 } 034 035 public void setInfo(Properties info) { 036 this.info = info; 037 } 038 039 public String toString() { 040 StringBuffer sb = new StringBuffer(); 041 sb.append("\n\n"); 042 if (!StringUtils.isEmpty(message)) { 043 sb.append(message + "\n\n"); 044 } 045 if (getThrowable() != null) { 046 sb.append("------------------------------------------------------\n"); 047 String emsg = getThrowable().getMessage(); 048 sb.append(emsg); 049 if (!emsg.endsWith("\n")) { 050 sb.append("\n"); 051 } 052 } 053 sb.append(toString(getInfo())); 054 return sb.toString(); 055 } 056 057 public String toString(Properties info) { 058 StringBuffer sb = new StringBuffer(); 059 sb.append("------------------------------------------------------\n\n"); 060 sb.append("The following information was provided to JDBC:\n"); 061 sb.append("------------------------------------------------------\n"); 062 sb.append("URL: " + getUrl() + "\n"); 063 sb.append("Driver: " + getDriver() + "\n"); 064 String username = info.getProperty(AbstractSQLExecutorMojo.DRIVER_INFO_PROPERTIES_USER); 065 if (StringUtils.isEmpty(username)) { 066 sb.append("Username: [No username was supplied]\n"); 067 } else { 068 sb.append("Username: " + username + "\n"); 069 } 070 String password = info.getProperty(AbstractSQLExecutorMojo.DRIVER_INFO_PROPERTIES_PASSWORD); 071 if (isShowPassword()) { 072 sb.append("Password: " + password + "\n"); 073 } else { 074 if (StringUtils.isEmpty(password)) { 075 sb.append("Password: [No password was supplied]\n"); 076 } else { 077 sb.append("Password: *******\n"); 078 } 079 } 080 sb.append("------------------------------------------------------\n"); 081 sb.append("\n"); 082 return sb.toString(); 083 084 } 085 086 public String getUrl() { 087 return url; 088 } 089 090 public void setUrl(String url) { 091 this.url = url; 092 } 093 094 public String getDriver() { 095 return driver; 096 } 097 098 public void setDriver(String driver) { 099 this.driver = driver; 100 } 101 102 public boolean isShowPassword() { 103 return showPassword; 104 } 105 106 public void setShowPassword(boolean showPassword) { 107 this.showPassword = showPassword; 108 } 109 110 }