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

mcutout: separates out VLKB-specific funcs (null-value-count & extra-cards) from doFile()

parent 8ccd3c26
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -164,8 +164,27 @@ public class ServletCutout extends HttpServlet
         String cutAbsPathname = settings.fitsPaths.cutouts() + "/"
                          + generateSubimgPathname(resolver.relPathname(), resolver.hdunum());

         return vlkb.doFile(resolver.relPathname(), resolver.hdunum(),
               pos, band, time, pol, pixels, countNullValues, extraCards, cutAbsPathname);
         vlkb.doFile(resolver.relPathname(), resolver.hdunum(),
               pos, band, time, pol, pixels, cutAbsPathname);


         // VLKB specific: null-value-count and extra-cards

         CutResult cutResult = new CutResult();

         cutResult.fileName = cutAbsPathname;
         cutResult.fileSize = Files.size(Paths.get(cutAbsPathname));
         if(countNullValues)
         {
            cutResult.nullValueCount = vlkb.doCountNullValues(cutAbsPathname, 1);
         }
         if(extraCards == null || (extraCards.length < 1))
         {
            LOGGER.finer("Adding extraCards to cut-file implemented only in VlkbAmql");
         }
         cutResult.pixels = null;

         return cutResult;
      }


+21 −11
Original line number Diff line number Diff line
@@ -87,21 +87,32 @@ class VlkbCli implements Vlkb
      return new CutResult();
   }


   public CutResult doFile(String relPathname, int hdunum,
   public CutResult doFileAmqp(String relPathname, int hdunum,
         Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, FitsCard[] extraCards,
         String cutAbsPathname)
         throws IOException, InterruptedException
   {
         LOGGER.fine("trace: " + pos.toString() );
         LOGGER.finer("Using doStream() to local file : " + cutAbsPathname);
      LOGGER.fine("trace doFileAmqp by CLI is NOT IMPLEMENTED (only by AMQP)");

      return new CutResult();
   }



   public void doFile(String relPathname, int hdunum,
         Pos pos, Band band, Time time, Pol pol, String pixels,
         /*boolean countNullValues, FitsCard[] extraCards,*/
			String cutAbsPathname)
         throws IOException, InterruptedException
      {
         LOGGER.fine("trace: " + cutAbsPathname );

			try(OutputStream fileOutputStream = new FileOutputStream(new File(cutAbsPathname)))
			{
			  soda.doStream(relPathname, hdunum, pos, band, time, pol, pixels, fileOutputStream);
			}

/*
			CutResult cutResult = new CutResult();

			cutResult.fileName = cutAbsPathname;
@@ -117,7 +128,7 @@ class VlkbCli implements Vlkb
			cutResult.pixels = null;

			return cutResult;
		}
*/		}


   public MCutResult doMCutout(String jdlJson, String workDir)
@@ -194,10 +205,9 @@ class VlkbCli implements Vlkb
			String cutAbsPathname = workDir + "/"
				+ generateSubimgPathname(ix, relPathname, hdunum, MAX_FILENAME_LEN);

			CutResult cutResult = doFile(relPathname, hdunum, pos, band, time, pol, pixels,
					countNullValues, extraCards, cutAbsPathname);
			doFile(relPathname, hdunum, pos, band, time, pol, pixels, cutAbsPathname);

			cut.content     = cutResult.fileName;
			cut.content     = cutAbsPathname;
			cut.contentType = MCutResult.Cut.ContentType.FILENAME;
		}
		catch(MultiValuedParamNotSupported ex)
@@ -325,7 +335,7 @@ class VlkbCli implements Vlkb
		}


	private NullValueCount doCountNullValues(String absPathname, int hdunum)
	public NullValueCount doCountNullValues(String absPathname, int hdunum)
		throws IOException, InterruptedException
		{
			ByteArrayOutputStream bos = new ByteArrayOutputStream();
+15 −5
Original line number Diff line number Diff line
@@ -13,20 +13,30 @@ import vo.parameter.*;

public interface Vlkb
{
   public CutResult doFile(String relPathname, int hdunum,
   public void doFile(String relPathname, int hdunum,
         Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, FitsCard[] extraCards,
         String cutAbsPathname)
         throws IOException, InterruptedException;



   public MCutResult doMCutout(String jdlJson, String workDir)
      throws IOException, InterruptedException;



   public CutResult doMerge(String[] idArr, Coord coord, boolean countNullValues)
      throws FileNotFoundException, IOException;


	// misc

	NullValueCount doCountNullValues(String absPathname, int hdunum)
      throws IOException, InterruptedException;

	// deprecated - used only in VlkbAmqp
   public CutResult doFileAmqp(String relPathname, int hdunum,
         Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, FitsCard[] extraCards,
			String cutAbsPathname)
         throws IOException, InterruptedException;
}
+366 −352
Original line number Diff line number Diff line
@@ -64,6 +64,12 @@ class VlkbAmqp implements Vlkb
   }


	public NullValueCount doCountNullValues(String absPathname, int hdunum)
		throws IOException, InterruptedException
		{
			LOGGER.fine("trace: not implemented; TB deprecated");
			return new NullValueCount();
		}


	public CutResult doMerge(String[] idArr, Coord coord, boolean countNullValues)
@@ -76,8 +82,16 @@ class VlkbAmqp implements Vlkb


	///////////////////////////////////////////////////////////////////////////////////
	public void doFile(String relPathname, int hdunum,
			Pos pos, Band band, Time time, Pol pol, String pixels,
			/*boolean countNullValues, FitsCard[] extraCards,*/ String dummyCutAbsPathname)
		throws IOException, InterruptedException
		{
			;// only placehoder for compatibility with Vlkb.java interface,
			 //Amqp support is deprecated
		}

   public CutResult doFile(String relPathname, int hdunum,
	public CutResult doFileAmqp(String relPathname, int hdunum,
			Pos pos, Band band, Time time, Pol pol, String pixels,
			boolean countNullValues, FitsCard[] extraCards, String dummyCutAbsPathname)
		throws IOException, InterruptedException
@@ -133,7 +147,7 @@ class VlkbAmqp implements Vlkb

			final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from confif file

         CutResult cutResult = doFile(relPathname, hdunum, pos, band, time, pol, pixels,
			CutResult cutResult = doFileAmqp(relPathname, hdunum, pos, band, time, pol, pixels,
					countNullValues, extraCards, null);

			return cutResult;