diff --git a/data-access/servlet/src/main/java/webapi/ServletCutout.java b/data-access/servlet/src/main/java/webapi/ServletCutout.java index 74fff0971bae99c916bbd3b125ff4abaf4e78570..8747ce90367fa280545d976523187b93ad037158 100644 --- a/data-access/servlet/src/main/java/webapi/ServletCutout.java +++ b/data-access/servlet/src/main/java/webapi/ServletCutout.java @@ -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()); diff --git a/data-access/servlet/src/main/java/webapi/ServletMerge.java b/data-access/servlet/src/main/java/webapi/ServletMerge.java index 7fce57f1d2757dd967ddfadcb750101ece71794a..2b34a4e59bc7f75d7b30ae8b2f0cfad3c28a086f 100644 --- a/data-access/servlet/src/main/java/webapi/ServletMerge.java +++ b/data-access/servlet/src/main/java/webapi/ServletMerge.java @@ -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); @@ -190,18 +199,18 @@ public class ServletMerge extends javax.servlet.http.HttpServlet LOGGER.info("processRequest normal exit"); } -/* - private Map<SodaParam, String[]> collectSodaParams(HttpServletRequest req) - { + /* + private Map<SodaParam, String[]> collectSodaParams(HttpServletRequest req) + { Map<SodaParam, String[]> params = new HashMap<SodaParam, String[]>(); for(SodaParam paramToken : SodaParam.values()) { - String[] paramValue = req.getParameterValues(paramToken.toString()); - params.put(paramToken, paramValue); + String[] paramValue = req.getParameterValues(paramToken.toString()); + params.put(paramToken, paramValue); } return params; - } -*/ + } + */ /* semi-colon separated list of pudids convert to arra */ private String[] parseLegacyPubdidArr(String pubdids) @@ -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; + } + + + + } diff --git a/data-access/servlet/src/main/java/webapi/UWSMergeWork.java b/data-access/servlet/src/main/java/webapi/UWSMergeWork.java index 3e1ab78d1490d900e4609bfb47f3f2f1a77a208a..a6e75ce1216d9402f1b79c49b25746f2e2838f6c 100644 --- a/data-access/servlet/src/main/java/webapi/UWSMergeWork.java +++ b/data-access/servlet/src/main/java/webapi/UWSMergeWork.java @@ -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) { diff --git a/data-access/servlet/src/main/java/webapi/UWSSodaWork.java b/data-access/servlet/src/main/java/webapi/UWSSodaWork.java index 5ac6b0ad784240ce1d294f2dddbb8b070c0d9617..cc6c31a645426aef3c73a141b5ad83fa3eadef80 100644 --- a/data-access/servlet/src/main/java/webapi/UWSSodaWork.java +++ b/data-access/servlet/src/main/java/webapi/UWSSodaWork.java @@ -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)