Commit ee77a823 authored by Robert Butora's avatar Robert Butora
Browse files

adds support for coord-system params (POSSYS BANDSYS TIMESYS) and their defaults from settings-file

parent 4420ab3b
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -52,9 +52,15 @@ class FormatResponseWrapper extends HttpServletResponseWrapper
public class FormatResponseFilter implements Filter
{
   private static final Logger LOGGER = Logger.getLogger("FormatResponseFilter");
   private static final FormatResponseSettings settings = FormatResponseSettings.getInstance("formatresponsefilter.properties");
   private static final FormatResponseSettings settings = FormatResponseSettings.getInstance(
         "formatresponsefilter.properties");

   final String RESPONSE_ENCODING = "UTF-8";
   final String DEFAULT_RESPONSEFORMAT = settings.defaults.responseFormat;
   final String DEFAULT_SKY_SYSTEM     = settings.defaults.skySystem;
   final String DEFAULT_SPEC_SYSTEM    = settings.defaults.specSystem;
   final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from confif file

   protected Subsurvey[] dbSubsurveyArr  = null;
   private String reqQueryString;

@@ -101,10 +107,9 @@ public class FormatResponseFilter implements Filter
         // FIXME add invalid param excpetions -> params already parsed in servlet

         Coord coord = new Coord();
         coord.pos  = Pos.parsePos(params);
         coord.pos.setSystem(Pos.System.ICRS);
         coord.band = Band.parseBand(params);
         coord.time = Time.parseTime(params);
         coord.pos  = Pos.parsePos(params, DEFAULT_SKY_SYSTEM);
         coord.band = Band.parseBand(params, DEFAULT_SPEC_SYSTEM);
         coord.time = Time.parseTime(params, DEFAULT_TIME_SYSTEM);
         coord.pol  = Pol.parsePol(params);

         ObsCore[] obsCoreArr = queryObsCore(pubdidArr,
+22 −2
Original line number Diff line number Diff line
@@ -11,6 +11,14 @@ class FormatResponseSettings
{
   private static final Logger LOGGER = Logger.getLogger("FormatResponseSettings");

   public static class DefaultParamValues
   {
      String responseFormat;
      String skySystem;
      String specSystem;
      boolean showDuration;
   }

/*
   public static class DBConn
   {
@@ -58,6 +66,7 @@ class FormatResponseSettings

   public DBConn     dbConn;
   public ServiceUrls serviceUrls;
   public DefaultParamValues defaults;


   // will not start without config-file; no reasonable code-defaults can be invented
@@ -74,8 +83,9 @@ class FormatResponseSettings

            DBConn      dbConn      = loadDBConn(properties);
            ServiceUrls serviceUrls = loadServiceUrls(properties);
            DefaultParamValues defaults = loadDefaults(properties);

            return new FormatResponseSettings(dbConn, serviceUrls);
            return new FormatResponseSettings(dbConn, serviceUrls, defaults);
         }
         else
         {
@@ -92,10 +102,11 @@ class FormatResponseSettings



   private FormatResponseSettings(DBConn dbConn, ServiceUrls serviceUrls)
   private FormatResponseSettings(DBConn dbConn, ServiceUrls serviceUrls, DefaultParamValues defaults)
   {
      this.dbConn      = dbConn;
      this.serviceUrls = serviceUrls;
      this.defaults    = defaults;
   }


@@ -121,6 +132,15 @@ class FormatResponseSettings
      return serviceUrls;
   }

   private static DefaultParamValues loadDefaults(Properties properties)
   {
      DefaultParamValues defaults = new DefaultParamValues();
      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;
   }

}
+9 −3
Original line number Diff line number Diff line
@@ -24,6 +24,12 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
   private static final Logger         LOGGER   = Logger.getLogger("PSearch");
   private static final SearchSettings settings = SearchSettings.getInstance("search.properties");

   final String RESPONSE_ENCODING = "utf-8";
   final String DEFAULT_RESPONSEFORMAT = settings.defaults.responseFormat;
   final String DEFAULT_SKY_SYSTEM     = settings.defaults.skySystem;
   final String DEFAULT_SPEC_SYSTEM    = settings.defaults.specSystem;
   final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from config file


   public void init() throws ServletException
   {
@@ -66,9 +72,9 @@ public class SearchServlet extends javax.servlet.http.HttpServlet

         // new based on vlkb-volib
         Coord coord = new Coord();
         coord.pos  = Pos.parsePos(params);
         coord.band = Band.parseBand(params);
         coord.time = Time.parseTime(params);
         coord.pos  = Pos.parsePos(params, DEFAULT_SKY_SYSTEM);
         coord.band = Band.parseBand(params, DEFAULT_SPEC_SYSTEM);
         coord.time = Time.parseTime(params, DEFAULT_TIME_SYSTEM);
         coord.pol  = Pol.parsePol(params);

         /* query Obscore table */
+25 −4
Original line number Diff line number Diff line
@@ -11,6 +11,15 @@ 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
   {
@@ -31,7 +40,7 @@ class SearchSettings
   }
*/
    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)
@@ -46,8 +55,9 @@ class SearchSettings
            properties.load(ins);

            DBConn      dbConn      = loadDBConn(properties);
            DefaultParamValues defaults = loadDefaults(properties);

            return new SearchSettings(dbConn);
            return new SearchSettings(dbConn, defaults);
         }
         else
         {
@@ -64,9 +74,10 @@ class SearchSettings



   private SearchSettings(DBConn dbConn)
   private SearchSettings(DBConn dbConn,  DefaultParamValues defaults)
   {
      this.dbConn      = dbConn;
      this.defaults  = defaults;
   }


@@ -81,5 +92,15 @@ class SearchSettings
      return dbConn;
   }

   private static DefaultParamValues loadDefaults(Properties properties)
   {
      DefaultParamValues defaults = new DefaultParamValues();
      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;
   }

}
+1.09 KiB (22.5 KiB)

File changed.

No diff preview for this file type.