Skip to content
Snippets Groups Projects
Commit 02aa8d21 authored by Robert Butora's avatar Robert Butora
Browse files

renames class DBConn -> DbConnArgs

parent 931ca42d
No related branches found
No related tags found
No related merge requests found
class DBConn class DbConnArgs
{ {
public String uri; public String uri;
public String schema; public String schema;
......
...@@ -24,12 +24,12 @@ import vo.parameter.*; ...@@ -24,12 +24,12 @@ import vo.parameter.*;
public class DbPSearch public class DbPSearch
{ {
private static final Logger LOGGER = Logger.getLogger(DbPSearch.class.getName()); private static final Logger LOGGER = Logger.getLogger(DbPSearch.class.getName());
private DBConn dbConn; private DbConnArgs dbConnArgs;
DbPSearch(DBConn dbConn) DbPSearch(DbConnArgs dbConnArgs)
{ {
this.dbConn = dbConn; this.dbConnArgs = dbConnArgs;
} }
...@@ -143,11 +143,11 @@ public class DbPSearch ...@@ -143,11 +143,11 @@ public class DbPSearch
List<String> pubdidList = new ArrayList<>(); List<String> pubdidList = new ArrayList<>();
LOGGER.fine("Connecting to: " + dbConn.uri() LOGGER.fine("Connecting to: " + dbConnArgs.uri()
+ " with optional user/pwd: " + dbConn.userName() +" / "+ dbConn.password() ); + " with optional user/pwd: " + dbConnArgs.userName() +" / "+ dbConnArgs.password() );
try( try(
Connection conn = DriverManager.getConnection(dbConn.uri(), dbConn.userName(), dbConn.password()); Connection conn = DriverManager.getConnection(dbConnArgs.uri(), dbConnArgs.userName(), dbConnArgs.password());
Statement st = conn.createStatement(); Statement st = conn.createStatement();
ResultSet res = st.executeQuery(theQuery);) ResultSet res = st.executeQuery(theQuery);)
{ {
...@@ -222,10 +222,10 @@ public class DbPSearch ...@@ -222,10 +222,10 @@ public class DbPSearch
List<ObsCore> obsCoreList = new ArrayList<>(); List<ObsCore> obsCoreList = new ArrayList<>();
LOGGER.fine("Connecting to: " + dbConn.uri() LOGGER.fine("Connecting to: " + dbConnArgs.uri()
+ " with optional user/pwd: " + dbConn.userName() +" / "+ dbConn.password() ); + " with optional user/pwd: " + dbConnArgs.userName() +" / "+ dbConnArgs.password() );
try( try(
Connection conn = DriverManager.getConnection(dbConn.uri(), dbConn.userName(), dbConn.password()); Connection conn = DriverManager.getConnection(dbConnArgs.uri(), dbConnArgs.userName(), dbConnArgs.password());
Statement st = conn.createStatement(); Statement st = conn.createStatement();
ResultSet res = st.executeQuery(theQuery);) ResultSet res = st.executeQuery(theQuery);)
{ {
......
...@@ -31,7 +31,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet ...@@ -31,7 +31,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
public void init() throws ServletException public void init() throws ServletException
{ {
LOGGER.config("DB: " + settings.dbConn.toString()); LOGGER.config("DB: " + settings.dbConnArgs.toString());
} }
protected void doGet(HttpServletRequest request, HttpServletResponse response) protected void doGet(HttpServletRequest request, HttpServletResponse response)
...@@ -81,7 +81,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet ...@@ -81,7 +81,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
DbPSearch dbps; DbPSearch dbps;
synchronized(DbPSearch.class) synchronized(DbPSearch.class)
{ {
dbps = new DbPSearch(settings.dbConn); dbps = new DbPSearch(settings.dbConnArgs);
} }
String[] pubdidArr = dbps.queryOverlapingPubdid(qArgs); String[] pubdidArr = dbps.queryOverlapingPubdid(qArgs);
...@@ -100,7 +100,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet ...@@ -100,7 +100,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
FormatResponseWrapper responseWrapper = (FormatResponseWrapper) response; FormatResponseWrapper responseWrapper = (FormatResponseWrapper) response;
responseWrapper.setPubdidArr(pubdidArr); responseWrapper.setPubdidArr(pubdidArr);
responseWrapper.setDBConn(settings.dbConn); responseWrapper.setDbConnArgs(settings.dbConnArgs);
} }
else else
{ {
......
...@@ -17,9 +17,9 @@ class SearchSettings ...@@ -17,9 +17,9 @@ class SearchSettings
Properties properties = new Properties(); Properties properties = new Properties();
properties.load(ins); properties.load(ins);
DBConn dbConn = loadDBConn(properties); DbConnArgs dbConnArgs = loadDbConnArgs(properties);
return new SearchSettings(dbConn); return new SearchSettings(dbConnArgs);
} }
else else
{ {
...@@ -33,26 +33,26 @@ class SearchSettings ...@@ -33,26 +33,26 @@ class SearchSettings
} }
} }
private static DBConn loadDBConn(Properties properties) private static DbConnArgs loadDbConnArgs(Properties properties)
{ {
DBConn dbConn = new DBConn(); DbConnArgs dbConnArgs = new DbConnArgs();
dbConn.uri = properties.getProperty("db_uri","jdbc:postgresql://localhost:5432/vialactea").strip(); dbConnArgs.uri = properties.getProperty("db_uri","jdbc:postgresql://localhost:5432/vialactea").strip();
dbConn.schema = properties.getProperty("db_schema","ivoa").strip(); dbConnArgs.schema = properties.getProperty("db_schema","ivoa").strip();
dbConn.user_name = properties.getProperty("db_user_name","").strip(); dbConnArgs.user_name = properties.getProperty("db_user_name","").strip();
dbConn.password = properties.getProperty("db_password","").strip(); dbConnArgs.password = properties.getProperty("db_password","").strip();
return dbConn; return dbConnArgs;
} }
// instance; separate classes allow grouping of settings // instance; separate classes allow grouping of settings
// DBConn - db_* // DbConnArgs - db_*
public DBConn dbConn; public DbConnArgs dbConnArgs;
private SearchSettings(DBConn dbConn) private SearchSettings(DbConnArgs dbConnArgs)
{ {
this.dbConn = dbConn; this.dbConnArgs = dbConnArgs;
} }
} }
......
...@@ -64,7 +64,7 @@ public class FormatResponseFilter implements Filter ...@@ -64,7 +64,7 @@ public class FormatResponseFilter implements Filter
Pos pos = Pos.parsePos(params, DEFAULT_SKY_SYSTEM); Pos pos = Pos.parsePos(params, DEFAULT_SKY_SYSTEM);
Band band = Band.parseBand(params, DEFAULT_SPEC_SYSTEM); Band band = Band.parseBand(params, DEFAULT_SPEC_SYSTEM);
DbPSearch.ObsCore[] obsCoreArr = queryObsCore(responseWrapper.getDBConn(), pubdidArr, pos, band); DbPSearch.ObsCore[] obsCoreArr = queryObsCore(responseWrapper.getDbConnArgs(), pubdidArr, pos, band);
String respFormat; String respFormat;
String respFormatReq[] = params.get("RESPONSEFORMAT"); String respFormatReq[] = params.get("RESPONSEFORMAT");
...@@ -150,7 +150,7 @@ public class FormatResponseFilter implements Filter ...@@ -150,7 +150,7 @@ public class FormatResponseFilter implements Filter
} }
private DbPSearch.ObsCore[] queryObsCore(DBConn dbConn, String[] pubdidArr, Pos pos, Band band) private DbPSearch.ObsCore[] queryObsCore(DbConnArgs dbConnArgs, String[] pubdidArr, Pos pos, Band band)
throws Exception throws Exception
{ {
...@@ -159,7 +159,7 @@ public class FormatResponseFilter implements Filter ...@@ -159,7 +159,7 @@ public class FormatResponseFilter implements Filter
DbPSearch dbps; DbPSearch dbps;
synchronized(DbPSearch.class) synchronized(DbPSearch.class)
{ {
dbps = new DbPSearch(dbConn); dbps = new DbPSearch(dbConnArgs);
} }
return dbps.queryOutputData(pubdidArr, pos, band); return dbps.queryOutputData(pubdidArr, pos, band);
......
...@@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletResponseWrapper; ...@@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletResponseWrapper;
class FormatResponseWrapper extends HttpServletResponseWrapper class FormatResponseWrapper extends HttpServletResponseWrapper
{ {
private String[] pubdidArr; private String[] pubdidArr;
private DBConn dbConn; private DbConnArgs dbConnArgs;
public FormatResponseWrapper(HttpServletResponse response) public FormatResponseWrapper(HttpServletResponse response)
{ {
...@@ -16,7 +16,7 @@ class FormatResponseWrapper extends HttpServletResponseWrapper ...@@ -16,7 +16,7 @@ class FormatResponseWrapper extends HttpServletResponseWrapper
public void setPubdidArr(String[] pubdidArr) { this.pubdidArr = pubdidArr; } public void setPubdidArr(String[] pubdidArr) { this.pubdidArr = pubdidArr; }
public String[] getPubdidArr() { return this.pubdidArr; } public String[] getPubdidArr() { return this.pubdidArr; }
public void setDBConn(DBConn dbConn) { this.dbConn = dbConn; } public void setDbConnArgs(DbConnArgs dbConnArgs) { this.dbConnArgs = dbConnArgs; }
public DBConn getDBConn() { return this.dbConn; } public DbConnArgs getDbConnArgs() { return this.dbConnArgs; }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment