package net.jaekl.cfb;
+import java.io.File;
+import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.Locale;
+import net.jaekl.cfb.analyze.Analysis;
+import net.jaekl.cfb.analyze.Analyzer;
import net.jaekl.cfb.db.CfbSchema;
import net.jaekl.cfb.db.driver.DbDriver;
import net.jaekl.cfb.db.driver.PostgresqlDriver;
// Command-line parameters
String m_dbName; // db name
+ File m_fbp; // FindBugsProject file
String m_host; // db host
int m_port; // db port
String m_user; // db user
m_bundle = CfbBundle.getInst(m_locale);
m_dbName = "CFB";
+ m_fbp = null;
m_host = "localhost";
m_port = 5432;
m_pass = "";
Options opt = new Options();
opt.addOption("d", "dbname", true, "DB name");
- opt.addOption("h", "host", true, "DB hostname");
- opt.addOption("p", "pass", true, "DB password");
- opt.addOption("t", "port", true, "DB port");
- opt.addOption("u", "user", true, "DB username");
+ opt.addOption("f", "fbp", true, "FindBugsProject file");
+ opt.addOption("h", "host", true, "DB hostname");
+ opt.addOption("p", "pass", true, "DB password");
+ opt.addOption("t", "port", true, "DB port");
+ opt.addOption("u", "user", true, "DB username");
return opt;
}
if (line.hasOption("d")) {
m_dbName = line.getOptionValue("d");
}
+ if (line.hasOption("f")) {
+ m_fbp = new File(line.getOptionValue("f"));
+ }
if (line.hasOption("h")) {
m_host = line.getOptionValue("h");
}
return m_bundle.get(key);
}
- void doMain(PrintWriter pw, String[] args) throws SQLException {
+ void doMain(PrintWriter pw, String[] args) throws SQLException, IOException {
if ( ! parseArgs(pw, args) ) {
return;
}
try (Connection con = m_driver.connect(m_host, m_port, m_dbName, m_user, m_pass)) {
- if (null == con) {
- String cannotConnectFormat = trans(CfbBundle.CANNOT_CONNECT);
- String cannotConnect = MessageFormat.format(cannotConnectFormat, m_host, m_port, m_dbName, m_user);
- pw.println(cannotConnect);
- return;
- }
m_schema.ensureDbInitialized(con);
}
+ catch (SQLException exc) {
+ String cannotConnectFormat = trans(CfbBundle.CANNOT_CONNECT);
+ String cannotConnect = MessageFormat.format(cannotConnectFormat, m_host, ""+m_port, m_dbName, m_user);
+ exc.printStackTrace(pw);
+ pw.println(cannotConnect);
+ return;
+ }
+
+ File findBugsDir = new File(".");
+ File workDir = new File(".");
+ Analyzer analyzer = new Analyzer(findBugsDir);
+ Analysis analysis = analyzer.analyze(workDir, m_fbp);
}
public static void main(String[] args) {
try (PrintWriter pw = new PrintWriter(System.out)){
cfb.doMain(pw, args);
- } catch (SQLException exc) {
+ } catch (SQLException | IOException exc) {
exc.printStackTrace();
}
}