Commit 8c13b1f8 authored by Robert Butora's avatar Robert Butora
Browse files

removes authz and eliminates Dataset (uses directly obsCoreArr) builds with mvn/pom.xml

parent 61a22d4a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,7 @@ AUTH_DIR := ../auth
AUTHFILTERS  = $(wildcard $(AUTH_DIR)/src/main/java/*Filter.java) $(AUTH_DIR)/src/main/java/AuthPolicy.java
AUTHFILTERS  = $(wildcard $(AUTH_DIR)/src/main/java/*Filter.java) $(AUTH_DIR)/src/main/java/AuthPolicy.java
SRC_DIR  = src/main/java/common:src/main/java/search:src/main/java/webapi:src/main/java/webapi/formatfilter:src/main/java/webapi/authzfilter:$(AUTH_DIR)/src/main/java
SRC_DIR  = src/main/java/common:src/main/java/search:src/main/java/webapi:src/main/java/webapi/formatfilter:src/main/java/webapi/authzfilter:$(AUTH_DIR)/src/main/java
VOSI     = src/main/java/vosi/VlkbServletFile.java
VOSI     = src/main/java/vosi/VlkbServletFile.java
FILTERS  = $(wildcard src/main/java/webapi/*Filter.java)
FILTERS  = $(wildcard src/main/java/webapi/formatfilter/*Filter.java)
SERVLETS = $(wildcard src/main/java/webapi/*Servlet.java)
SERVLETS = $(wildcard src/main/java/webapi/*Servlet.java)
#===============================================================================
#===============================================================================
JFLAGS = -g
JFLAGS = -g
+4 −0
Original line number Original line Diff line number Diff line

JAVA_HOME=/usr/lib/jvm/java-17-openjdk-17.0.9.0.9-3.fc38.x86_64 mvn clean package

+30 −0
Original line number Original line Diff line number Diff line





mvn install:install-file \
   -Dfile=../java-libs/lib/auth-lib-2.0.0-SNAPSHOT.jar \
   -DgroupId=it.inaf.ia2 \
   -DartifactId=auth-lib \
   -Dversion=2.0.0-SNAPSHOT \
   -Dpackaging=jar \
   -DgeneratePom=true

mvn install:install-file \
   -Dfile=../java-libs/lib/rap-client-1.0-SNAPSHOT.jar \
   -DgroupId=it.inaf.ia2 \
   -DartifactId=rap-client \
   -Dversion=1.0-SNAPSHOT \
   -Dpackaging=jar \
   -DgeneratePom=true

mvn install:install-file \
   -Dfile=../java-libs/lib/vlkb-volib-0.9.1.jar \
   -DgroupId=vo \
   -DartifactId=vlkb-volib \
   -Dversion=0.9.1 \
   -Dpackaging=jar \
   -DgeneratePom=true

+47 −19
Original line number Original line Diff line number Diff line
@@ -2,9 +2,9 @@
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <modelVersion>4.0.0</modelVersion>
  <groupId>vlkb</groupId>
  <groupId>vlkb</groupId>
  <artifactId>psearch</artifactId>
  <artifactId>vlkb-siav2</artifactId>
  <packaging>war</packaging>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <version>1.6.5</version>
  <name>psearch Maven Webapp</name>
  <name>psearch Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <url>http://maven.apache.org</url>


@@ -34,6 +34,21 @@
                  <version>1.0-SNAPSHOT</version>
                  <version>1.0-SNAPSHOT</version>
                  <scope>provided</scope>
                  <scope>provided</scope>
          </dependency>
          </dependency>

          <!-- local -->
          <dependency>
                  <groupId>vo</groupId>
                  <artifactId>vlkb-volib</artifactId>
                  <version>0.9.1</version>
                  <!-- scope>provided</scope -->
          </dependency>

          <dependency>
                  <groupId>uk.ac.starlink</groupId>
                  <artifactId>stil</artifactId>
                  <version>4.3</version>
          </dependency>

          <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
          <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
          <dependency>
          <dependency>
                  <groupId>com.fasterxml.jackson.core</groupId>
                  <groupId>com.fasterxml.jackson.core</groupId>
@@ -95,6 +110,12 @@
                  <scope>provided</scope>
                  <scope>provided</scope>
          </dependency>
          </dependency>


          <dependency>
                  <groupId>org.apache.clerezza.ext</groupId>
                  <artifactId>org.json.simple</artifactId>
                  <version>0.4</version>
          </dependency>

          <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-api -->
          <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt-api -->
          <dependency>
          <dependency>
                  <groupId>io.jsonwebtoken</groupId>
                  <groupId>io.jsonwebtoken</groupId>
@@ -107,14 +128,13 @@
                  <groupId>io.jsonwebtoken</groupId>
                  <groupId>io.jsonwebtoken</groupId>
                  <artifactId>jjwt-jackson</artifactId>
                  <artifactId>jjwt-jackson</artifactId>
                  <version>0.11.5</version>
                  <version>0.11.5</version>
                  <!-- scope>runtime</scope -->
          </dependency>
          </dependency>


          <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
          <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
          <dependency>
          <dependency>
                  <groupId>org.postgresql</groupId>
                  <groupId>org.postgresql</groupId>
                  <artifactId>postgresql</artifactId>
                  <artifactId>postgresql</artifactId>
          <version>42.6.0</version>
                  <version>42.2.5</version>
          </dependency>
          </dependency>


          <dependency>
          <dependency>
@@ -127,12 +147,20 @@
  </dependencies>
  </dependencies>


  <build>
  <build>
          <finalName>psearch</finalName>
          <finalName>vlkb-siav2</finalName>
          <plugins>
          <plugins>
                  <plugin>
                  <plugin>
                          <artifactId>maven-war-plugin</artifactId>
                          <artifactId>maven-war-plugin</artifactId>
                          <version>3.3.2</version>
                          <version>3.3.2</version>
                  </plugin>
                  </plugin>
                  <plugin>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <version>3.8.1</version>
                          <configuration>
                                  <compilerArgument>-Xlint:unchecked</compilerArgument>
                          </configuration>
                  </plugin>

          </plugins>
          </plugins>
  </build>
  </build>


+108 −11
Original line number Original line Diff line number Diff line
@@ -33,6 +33,54 @@ public class DbPSearch
   }
   }




   static class ObsCore
   {
      String dataproduct_type;
      Integer calib_level;
      String obs_collection;
      String obs_title;
      String obs_id;
      String obs_publisher_did;
      String bib_reference;
      String data_rights;

      String access_url;
      String access_format;
      Long access_estsize;

      String target_name;

      Double s_ra, s_dec, s_fov;
      String s_region;
      Long s_xel1, s_xel2;
      Double s_resolution;

      Double t_min, t_max, t_exptime, t_resolution;
      Long t_xel;

      Double em_min, em_max, em_res_power;
      Long em_xel;
      boolean em_valid;

      String o_ucd;

      String pol_states;
      Long   pol_xel;

      String facility_name;
      String instrument_name;

      // VLKB extesnion

      Integer overlapCodeSky;
      Integer overlapCodeVel;
      Integer overlapCode;

      String s_region_galactic;
      Double vel_min, vel_max;
   }






   public String[] queryOverlapingPubdid(Coord coord)
   public String[] queryOverlapingPubdid(Coord coord)
@@ -153,7 +201,7 @@ public class DbPSearch






   public FormatResponseFilter.ObsCore[] queryOutputData(String[] pubdidArr, Pos pos)
   public ObsCore[] queryOutputData(String[] pubdidArr, Pos pos, Band band)
      throws Exception
      throws Exception
   {
   {
      LOGGER.fine("trace");
      LOGGER.fine("trace");
@@ -172,7 +220,7 @@ public class DbPSearch


      //LOGGER.fine(theQuery);
      //LOGGER.fine(theQuery);


      List<FormatResponseFilter.ObsCore> obsCoreList = new ArrayList<>();
      List<ObsCore> obsCoreList = new ArrayList<>();


      LOGGER.fine("Connecting to: " + dbConn.uri()
      LOGGER.fine("Connecting to: " + dbConn.uri()
            + " with optional user/pwd: " + dbConn.userName() +" / "+ dbConn.password() );
            + " with optional user/pwd: " + dbConn.userName() +" / "+ dbConn.password() );
@@ -183,7 +231,7 @@ public class DbPSearch
      {
      {
         while (res.next())
         while (res.next())
         {
         {
            FormatResponseFilter.ObsCore obsCore = new FormatResponseFilter.ObsCore();
            ObsCore obsCore = new ObsCore();


            obsCore.dataproduct_type  = this.getString(res,"dataproduct_type");
            obsCore.dataproduct_type  = this.getString(res,"dataproduct_type");
            obsCore.calib_level       = this.getInt(res,"calib_level");
            obsCore.calib_level       = this.getInt(res,"calib_level");
@@ -205,7 +253,6 @@ public class DbPSearch
            obsCore.s_dec        = this.getDouble(res,"s_dec");
            obsCore.s_dec        = this.getDouble(res,"s_dec");
            obsCore.s_fov        = this.getDouble(res,"s_fov");
            obsCore.s_fov        = this.getDouble(res,"s_fov");
            obsCore.s_region     = this.getString(res,"s_region");
            obsCore.s_region     = this.getString(res,"s_region");
            obsCore.s_region_galactic = this.getString(res,"s_region_galactic");
            obsCore.s_xel1       = this.getLong(res,"s_xel1");
            obsCore.s_xel1       = this.getLong(res,"s_xel1");
            obsCore.s_xel2       = this.getLong(res,"s_xel2");
            obsCore.s_xel2       = this.getLong(res,"s_xel2");
            obsCore.s_resolution = this.getDouble(res,"s_resolution");
            obsCore.s_resolution = this.getDouble(res,"s_resolution");
@@ -216,9 +263,6 @@ public class DbPSearch
            obsCore.t_resolution  = this.getDouble(res,"t_resolution");
            obsCore.t_resolution  = this.getDouble(res,"t_resolution");
            obsCore.t_xel         = this.getLong(res,"t_xel");
            obsCore.t_xel         = this.getLong(res,"t_xel");


            obsCore.vel_min      = this.getDouble(res,"vel_min"); //boolean em_min_valid = !res.wasNull();
            obsCore.vel_max      = this.getDouble(res,"vel_max"); //boolean em_max_valid = !res.wasNull();

            obsCore.em_min       = this.getDouble(res,"em_min"); boolean em_min_valid = !res.wasNull();
            obsCore.em_min       = this.getDouble(res,"em_min"); boolean em_min_valid = !res.wasNull();
            obsCore.em_max       = this.getDouble(res,"em_max"); boolean em_max_valid = !res.wasNull();
            obsCore.em_max       = this.getDouble(res,"em_max"); boolean em_max_valid = !res.wasNull();
            obsCore.em_valid     = em_min_valid && em_max_valid;;
            obsCore.em_valid     = em_min_valid && em_max_valid;;
@@ -233,9 +277,20 @@ public class DbPSearch
            obsCore.facility_name = this.getString(res,"facility_name");
            obsCore.facility_name = this.getString(res,"facility_name");
            obsCore.instrument_name = this.getString(res,"instrument_name");
            obsCore.instrument_name = this.getString(res,"instrument_name");


            obsCore.vertices_str  = this.getString(res,"polygon_region_galactic");
            // VLKB extension
            obsCore.inputInsideDb = res.getBoolean("inputInsideDb");

            obsCore.dbInsideInput = res.getBoolean("dbInsideInput");
            obsCore.s_region_galactic = this.getString(res,"s_region_galactic");
            obsCore.vel_min           = this.getDouble(res,"vel_min"); //boolean em_min_valid = !res.wasNull();
            obsCore.vel_max           = this.getDouble(res,"vel_max"); //boolean em_max_valid = !res.wasNull();

            boolean inputInsideDb = res.getBoolean("inputInsideDb");
            boolean dbInsideInput = res.getBoolean("dbInsideInput");
            obsCore.overlapCodeSky = convertToOverlapCodeSky(inputInsideDb, dbInsideInput);

            obsCore.overlapCodeVel = convertToOverlapCodeVel(band,obsCore.em_valid,obsCore.em_min,obsCore.em_max);

            obsCore.overlapCode    = convertToOverlapCode(obsCore.overlapCodeSky, obsCore.overlapCodeVel);



            obsCoreList.add(obsCore);
            obsCoreList.add(obsCore);
         }
         }
@@ -249,11 +304,53 @@ public class DbPSearch
         throw new Exception(se.toString());
         throw new Exception(se.toString());
      }
      }


      FormatResponseFilter.ObsCore[] cubes = obsCoreList.toArray(new FormatResponseFilter.ObsCore[0]);
      ObsCore[] cubes = obsCoreList.toArray(new ObsCore[0]);


      return cubes;
      return cubes;
   }
   }


   /* convert overlap codes */

   private Integer convertToOverlapCodeSky(boolean inpInDb, boolean dbInInp)
   {   
      if(!inpInDb && !dbInInp) return 4; // parial overlap
      else if( inpInDb && !dbInInp) return 3; // input region completely inside fits-datacube
      else if(!inpInDb &&  dbInInp) return 2; // datacube completely inside input-region
      else return 5; // exact match: both inpInDb dbInInp are true
   }

   private Integer convertToOverlapCodeVel(Band band, boolean v_valid, double v_min, double v_max)
   {
      if((band != null) && v_valid)
      {
         if(band.system == Band.System.VELO_LSRK)
         {
            // FIXME assert coord: vel_min <= vel_max
            // FIXME assert cube:  v_min   <= v_max

            boolean dbInInp = (band.getMin() <= v_min) && (v_min <= band.getMax())
               && (band.getMin() <= v_max) && (v_max <= band.getMax());

            boolean inpInDb = (v_min <= band.getMin()) && (band.getMin() <= v_max)
               && (v_min <= band.getMax() ) && (band.getMax() <= v_max);

            return convertToOverlapCodeSky(inpInDb, dbInInp);

         }
         else return null;// FIXME other v_type NotImplemented yet
      }

      return null;
   }

   private Integer convertToOverlapCode(Integer ovcSky, Integer ovcVel)
   {
      if(ovcVel == null) return ovcSky; // 2D images
      else if(ovcSky == ovcVel) return ovcSky;
      else return 4;// partial overlap
   }


   /* conversions tolerate missing columns */
   /* conversions tolerate missing columns */


   private Integer getInt(ResultSet res, String colLabel)
   private Integer getInt(ResultSet res, String colLabel)
Loading