1 | |
package org.apache.torque.mojo; |
2 | |
|
3 | |
import java.util.Properties; |
4 | |
|
5 | |
import org.apache.commons.lang.StringUtils; |
6 | |
|
7 | 0 | public class ImpexError { |
8 | |
Throwable throwable; |
9 | |
String message; |
10 | |
Properties info; |
11 | |
String url; |
12 | |
String driver; |
13 | |
boolean showPassword; |
14 | |
|
15 | |
public Throwable getThrowable() { |
16 | 0 | return throwable; |
17 | |
} |
18 | |
|
19 | |
public void setThrowable(Throwable throwable) { |
20 | 0 | this.throwable = throwable; |
21 | 0 | } |
22 | |
|
23 | |
public String getMessage() { |
24 | 0 | return message; |
25 | |
} |
26 | |
|
27 | |
public void setMessage(String message) { |
28 | 0 | this.message = message; |
29 | 0 | } |
30 | |
|
31 | |
public Properties getInfo() { |
32 | 0 | return info; |
33 | |
} |
34 | |
|
35 | |
public void setInfo(Properties info) { |
36 | 0 | this.info = info; |
37 | 0 | } |
38 | |
|
39 | |
public String toString() { |
40 | 0 | StringBuffer sb = new StringBuffer(); |
41 | 0 | sb.append("\n\n"); |
42 | 0 | if (!StringUtils.isEmpty(message)) { |
43 | 0 | sb.append(message + "\n\n"); |
44 | |
} |
45 | 0 | if (getThrowable() != null) { |
46 | 0 | sb.append("------------------------------------------------------\n"); |
47 | 0 | String emsg = getThrowable().getMessage(); |
48 | 0 | sb.append(emsg); |
49 | 0 | if (!emsg.endsWith("\n")) { |
50 | 0 | sb.append("\n"); |
51 | |
} |
52 | |
} |
53 | 0 | sb.append(toString(getInfo())); |
54 | 0 | return sb.toString(); |
55 | |
} |
56 | |
|
57 | |
public String toString(Properties info) { |
58 | 0 | StringBuffer sb = new StringBuffer(); |
59 | 0 | sb.append("------------------------------------------------------\n\n"); |
60 | 0 | sb.append("The following information was provided to JDBC:\n"); |
61 | 0 | sb.append("------------------------------------------------------\n"); |
62 | 0 | sb.append("URL: " + getUrl() + "\n"); |
63 | 0 | sb.append("Driver: " + getDriver() + "\n"); |
64 | 0 | String username = info.getProperty(AbstractSQLExecutorMojo.DRIVER_INFO_PROPERTIES_USER); |
65 | 0 | if (StringUtils.isEmpty(username)) { |
66 | 0 | sb.append("Username: [No username was supplied]\n"); |
67 | |
} else { |
68 | 0 | sb.append("Username: " + username + "\n"); |
69 | |
} |
70 | 0 | String password = info.getProperty(AbstractSQLExecutorMojo.DRIVER_INFO_PROPERTIES_PASSWORD); |
71 | 0 | if (isShowPassword()) { |
72 | 0 | sb.append("Password: " + password + "\n"); |
73 | |
} else { |
74 | 0 | if (StringUtils.isEmpty(password)) { |
75 | 0 | sb.append("Password: [No password was supplied]\n"); |
76 | |
} else { |
77 | 0 | sb.append("Password: *******\n"); |
78 | |
} |
79 | |
} |
80 | 0 | sb.append("------------------------------------------------------\n"); |
81 | 0 | sb.append("\n"); |
82 | 0 | return sb.toString(); |
83 | |
|
84 | |
} |
85 | |
|
86 | |
public String getUrl() { |
87 | 0 | return url; |
88 | |
} |
89 | |
|
90 | |
public void setUrl(String url) { |
91 | 0 | this.url = url; |
92 | 0 | } |
93 | |
|
94 | |
public String getDriver() { |
95 | 0 | return driver; |
96 | |
} |
97 | |
|
98 | |
public void setDriver(String driver) { |
99 | 0 | this.driver = driver; |
100 | 0 | } |
101 | |
|
102 | |
public boolean isShowPassword() { |
103 | 0 | return showPassword; |
104 | |
} |
105 | |
|
106 | |
public void setShowPassword(boolean showPassword) { |
107 | 0 | this.showPassword = showPassword; |
108 | 0 | } |
109 | |
|
110 | |
} |