Commit 244816c6 authored by Robert Butora's avatar Robert Butora
Browse files

removes DataLink from ServletMerge response-serialization (uses CutResult instead)

parent 294ce7ed
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ public class ServletCutout extends javax.servlet.http.HttpServlet



   //protected DataLink doCutoutFile(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
   protected CutResult doCutoutFile(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, String respFormat)
         throws IOException, InterruptedException
@@ -174,8 +173,6 @@ public class ServletCutout extends javax.servlet.http.HttpServlet

      CutResult cutResult = cutout.doFile(relPathname, hdunum, pos, band, time, pol, pixels, false, null);

      //DataLink dlk = new DataLink(settings, cutResult, id, pos, band, time, pol, countNullValues);

      return cutResult;
   }

@@ -286,8 +283,6 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
               boolean  countNullValues = vlkbReq_getNullValues(request);
               response.setContentType(respFormat);

//               DataLink respDataLink = doCutoutFile(id, pos, band, time, pol, pixels, countNullValues,
//                     respFormat);
               CutResult cutResult = doCutoutFile(id, pos, band, time, pol, pixels, countNullValues,
                     respFormat);

@@ -296,9 +291,6 @@ public class ServletCutout extends javax.servlet.http.HttpServlet

               PrintWriter writer =new PrintWriter(new OutputStreamWriter(respOutputStream, RESPONSE_ENCODING));

//               XmlSerializer.serializeToLegacyCutResults(writer,
//                     respEncoding, respDataLink, showDuration, startTime_msec);

               String accessUrl = convertLocalPathnameToRemoteUrl(cutResult.fileName,
                     settings.fitsPaths.cutouts(),
                     settings.fitsPaths.cutoutsUrl());
+35 −11
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ public class ServletMerge extends javax.servlet.http.HttpServlet
            Band   band = null;
            Time   time = null;
            Pol    pol  = null;
            String pixels = null;



@@ -135,8 +136,6 @@ public class ServletMerge extends javax.servlet.http.HttpServlet

            CutResult cutResult = datasets.doMerge(parseLegacyPubdidArr(id), coord, countNullValues);

            DataLink dlk = new DataLink(cutResult);

            String contentType = respContentType;
            String respEncoding = RESPONSE_ENCODING;

@@ -144,14 +143,24 @@ public class ServletMerge extends javax.servlet.http.HttpServlet
            {
               LOGGER.info("writing xml");
               PrintWriter writer = new PrintWriter(new OutputStreamWriter(respOutputStream, respEncoding));
               XmlSerializer.serializeToLegacyCutResults(writer, respEncoding, dlk, showDuration, startTime_msec);

               String accessUrl = convertLocalPathnameToRemoteUrl(cutResult.fileName,
                     settings.fitsPaths.cutouts(),
                     settings.fitsPaths.cutoutsUrl());

               XmlSerializer.serializeToLegacyCutResult(writer, RESPONSE_ENCODING,
                     cutResult, accessUrl,
                     id, pos, band, time, pol, pixels, countNullValues,
                     showDuration, startTime_msec);

               writer.close();
            }
            else if(contentType.equals("application/fits"))
            {
               LOGGER.info("streaming the file");

               File downloadFile = new File(dlk.absCutPathname);
               String absCutPathname = cutResult.fileName;
               File downloadFile = new File(absCutPathname);
               FileInputStream input = new FileInputStream(downloadFile);

               input.transferTo(respOutputStream);
@@ -217,5 +226,20 @@ public class ServletMerge extends javax.servlet.http.HttpServlet
   }   



      private String convertLocalPathnameToRemoteUrl(String localPathname,
         String FITScutpath, String FITSRemoteUrlCutouts)
   {
      LOGGER.info("trace " + localPathname);
      String fileName = localPathname.replaceAll(FITScutpath + "/", "");
      LOGGER.info("local filename: " + fileName);
      String remotefname = FITSRemoteUrlCutouts + "/" + fileName;
      LOGGER.info("remote url    : " + remotefname);
      return remotefname;
   }




}
+31 −4
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ public class UWSMergeWork extends JobThread
         Band   band = null;
         Time   time = null;
         Pol    pol  = null;
         String pixels = null;

         if(parser.sodaReq_hasSodaId())
         {
@@ -80,10 +81,9 @@ public class UWSMergeWork extends JobThread
            band = parser.vlkbReq_getVelocity();
         }

         Coord coord = new Coord(DEFAULT_SKY_SYSTEM, pos, DEFAULT_SPEC_SYSTEM, band, time, pol);
         Coord coord = new Coord(pos, band, time, pol);

         CutResult cutResult  = datasets.doMerge(parseLegacyPubdidArr(id), coord, false);//countNullValues);
         DataLink dlk = new DataLink(cutResult);

         final String respFormat = "text/xml";// FIXME read from param RESPONSEFORMAT ?

@@ -97,12 +97,22 @@ public class UWSMergeWork extends JobThread
         if(contentType.equals("text/xml") || contentType.equals("application/xml"))
         {
            PrintWriter writer = new PrintWriter(new OutputStreamWriter(respOutputStream, respEncoding));
            XmlSerializer.serializeToLegacyCutResults(writer, respEncoding, dlk, showDuration, startTime_msec);

            String accessUrl = convertLocalPathnameToRemoteUrl(cutResult.fileName,
                  settings.fitsPaths.cutouts(),
                  settings.fitsPaths.cutoutsUrl());

            XmlSerializer.serializeToLegacyCutResult(writer, RESPONSE_ENCODING,
                  cutResult, accessUrl,
                  id, pos, band, time, pol, pixels, false,//countNullValues,
                  showDuration, startTime_msec);

            writer.close();
         }
         else if(contentType.equals("application/fits"))
         {
            File downloadFile = new File(dlk.absCutPathname);
            String absCutPathname = cutResult.fileName;
            File downloadFile = new File(absCutPathname);
            FileInputStream input = new FileInputStream(downloadFile);
            input.transferTo(respOutputStream);
            downloadFile.delete();
@@ -130,6 +140,23 @@ public class UWSMergeWork extends JobThread
   }





   private String convertLocalPathnameToRemoteUrl(String localPathname,
         String FITScutpath, String FITSRemoteUrlCutouts)
   {
      LOGGER.info("trace " + localPathname);
      String fileName = localPathname.replaceAll(FITScutpath + "/", "");
      LOGGER.info("local filename: " + fileName);
      String remotefname = FITSRemoteUrlCutouts + "/" + fileName;
      LOGGER.info("remote url    : " + remotefname);
      return remotefname;
   }




   /* semi-colon separated list of pudids convert to arra */
   private String[] parseLegacyPubdidArr(String pubdids)
   {
+15 −10
Original line number Diff line number Diff line
@@ -46,8 +46,6 @@ public class UWSSodaWork extends JobThread
   @Override
   protected void jobWork() throws UWSException, InterruptedException
   {
      // result.setSize(size); // FIXME how to add this? not set in ServeltCutout either (only inside DataLink)

      long startTime_msec = System.currentTimeMillis();
      boolean showDuration = true;

@@ -105,10 +103,6 @@ public class UWSSodaWork extends JobThread

         CutResult cutResult = datasets.doCutoutFile(rsl.relPathname, rsl.hdunum, pos, band, time, pol, false, null);

//         DataLink respDataLink = new DataLink(cutResult);

//         respDataLink.inputs = new Inputs(id, coord, false);//countNullValues);

         /* send Results */

         Result result = createResult("cutout");
@@ -119,8 +113,6 @@ public class UWSSodaWork extends JobThread
         {
            PrintWriter writer = new PrintWriter(new OutputStreamWriter(respOutputStream, RESPONSE_ENCODING));

            // XmlSerializer.serializeToLegacyCutResults(writer, RESPONSE_ENCODING, respDataLink, showDuration, startTime_msec);

            String accessUrl = convertLocalPathnameToRemoteUrl(cutResult.fileName,
                  settings.fitsPaths.cutouts(),
                  settings.fitsPaths.cutoutsUrl());
@@ -130,13 +122,12 @@ public class UWSSodaWork extends JobThread
                  id, pos, band, time, pol, null, false,
                  showDuration, startTime_msec);


               writer.close();
         }
         else if(respContentType.equals("application/fits"))
         {
            String absCutPathname = cutResult.fileName;
            File downloadFile = new File(/*respDataLink.*/absCutPathname);
            File downloadFile = new File(absCutPathname);
            FileInputStream input = new FileInputStream(downloadFile);

            input.transferTo(respOutputStream);
@@ -164,6 +155,20 @@ public class UWSSodaWork extends JobThread
   }


   private String convertLocalPathnameToRemoteUrl(String localPathname,
         String FITScutpath, String FITSRemoteUrlCutouts)
   {
      LOGGER.info("trace " + localPathname);
      String fileName = localPathname.replaceAll(FITScutpath + "/", "");
      LOGGER.info("local filename: " + fileName);
      String remotefname = FITSRemoteUrlCutouts + "/" + fileName;
      LOGGER.info("remote url    : " + remotefname);
      return remotefname;
   }




   /* see UWSParameters::getAdditionalParameter -> UWSParameters.java.l465: ...returned value maybe an array... */
   /* Object getAdditionalParameterValue(String paramName) --> calls UWSParameters::getAdditionalParameters()   */
   private Map<SodaParam, String[]> collectSodaParams(UWSJob job)