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