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

removes unused 'defaults' search-settings

parent f702eb5a
No related branches found
No related tags found
No related merge requests found
...@@ -24,10 +24,9 @@ public class SearchServlet extends javax.servlet.http.HttpServlet ...@@ -24,10 +24,9 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
private static final SearchSettings settings = SearchSettings.getInstance("search.properties"); private static final SearchSettings settings = SearchSettings.getInstance("search.properties");
final String RESPONSE_ENCODING = "utf-8"; final String RESPONSE_ENCODING = "utf-8";
final String DEFAULT_RESPONSEFORMAT = settings.defaults.responseFormat; final String DEFAULT_SKY_SYSTEM = "ICRS";
final String DEFAULT_SKY_SYSTEM = settings.defaults.skySystem; final String DEFAULT_SPEC_SYSTEM = "WAVE_Barycentric";
final String DEFAULT_SPEC_SYSTEM = settings.defaults.specSystem; final String DEFAULT_TIME_SYSTEM = "MJD_UTC";
final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from config file
public void init() throws ServletException public void init() throws ServletException
...@@ -90,8 +89,6 @@ public class SearchServlet extends javax.servlet.http.HttpServlet ...@@ -90,8 +89,6 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
LOGGER.info("Found " + pubdidArr.length + " records"); LOGGER.info("Found " + pubdidArr.length + " records");
final String RESPONSE_ENCODING = "UTF-8";
/* if filters installed response will be wrapped */ /* if filters installed response will be wrapped */
if(response instanceof FormatResponseWrapper) if(response instanceof FormatResponseWrapper)
...@@ -146,7 +143,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet ...@@ -146,7 +143,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
catch(Exception ex) catch(Exception ex)
{ {
LOGGER.warning("Exception: " + ex.getMessage()); LOGGER.warning("Exception: " + ex.getMessage());
// ex.printStackTrace(); ex.printStackTrace();
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setContentType("text/plain"); response.setContentType("text/plain");
......
import java.util.logging.Logger;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.Properties; import java.util.Properties;
import java.io.PrintWriter;
class SearchSettings class SearchSettings
{ {
//private static final Logger LOGGER = Logger.getLogger("SearchSettings");
public static class DefaultParamValues
{
String responseFormat;
String skySystem;
String specSystem;
boolean showDuration;
}
/*
public static class DBConn
{
private String uri;
private String schema;
private String user_name;
private String password;
public String uri() {return uri;}
public String schema() {return schema;}
public String userName() {return user_name;}
public String password() {return password;}
public String toString()
{
return uri + " schema[" + schema + "] " + user_name + " / " + password;
}
}
*/
public DBConn dbConn;
public DefaultParamValues defaults;
// will not start without config-file; no reasonable code-defaults can be invented
public static SearchSettings getInstance(String settingsFileName) public static SearchSettings getInstance(String settingsFileName)
{ {
try try
...@@ -55,9 +18,8 @@ class SearchSettings ...@@ -55,9 +18,8 @@ class SearchSettings
properties.load(ins); properties.load(ins);
DBConn dbConn = loadDBConn(properties); DBConn dbConn = loadDBConn(properties);
DefaultParamValues defaults = loadDefaults(properties);
return new SearchSettings(dbConn, defaults); return new SearchSettings(dbConn);
} }
else else
{ {
...@@ -71,35 +33,26 @@ class SearchSettings ...@@ -71,35 +33,26 @@ class SearchSettings
} }
} }
private SearchSettings(DBConn dbConn, DefaultParamValues defaults)
{
this.dbConn = dbConn;
this.defaults = defaults;
}
private static DBConn loadDBConn(Properties properties) private static DBConn loadDBConn(Properties properties)
{ {
DBConn dbConn = new DBConn(); DBConn dbConn = new DBConn();
dbConn.uri = properties.getProperty("db_uri","jdbc:postgresql://localhost:5432/vialactea").strip(); dbConn.uri = properties.getProperty("db_uri","jdbc:postgresql://localhost:5432/vialactea").strip();
dbConn.schema = properties.getProperty("db_schema","datasets").strip(); dbConn.schema = properties.getProperty("db_schema","ivoa").strip();
dbConn.user_name = properties.getProperty("db_user_name","").strip(); dbConn.user_name = properties.getProperty("db_user_name","").strip();
dbConn.password = properties.getProperty("db_password","").strip(); dbConn.password = properties.getProperty("db_password","").strip();
return dbConn; return dbConn;
} }
private static DefaultParamValues loadDefaults(Properties properties)
// instance; separate classes allow grouping of settings
// DBConn - db_*
public DBConn dbConn;
private SearchSettings(DBConn dbConn)
{ {
DefaultParamValues defaults = new DefaultParamValues(); this.dbConn = dbConn;
defaults.responseFormat = properties.getProperty("default_response_format", "application/fits").strip();
defaults.skySystem = properties.getProperty("default_sky_system", "ICRS").strip();
defaults.specSystem = properties.getProperty("default_spec_system", "WAVE_Barycentric").strip();
defaults.showDuration = "yes".equals(properties.getProperty("show_duration", "no").strip());
return defaults;
} }
} }
......
# database with 'obscore' table # database with 'obscore' table
# db_uri=jdbc:postgresql://localhost:5432/vialactea # db_uri=jdbc:postgresql://localhost:5432/vialactea
# db_schema=datasets # db_schema=ivoa
db_user_name= db_user_name=
db_password= db_password=
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment