diff --git a/data-discovery/src/main/java/webapi/formatfilter/FormatResponseFilter.java b/data-discovery/src/main/java/webapi/formatfilter/FormatResponseFilter.java index 3c22a03803d0adedc8babda0c173dceb4a0408bc..85af5206e842eda17f0896c228a0756210f958ff 100644 --- a/data-discovery/src/main/java/webapi/formatfilter/FormatResponseFilter.java +++ b/data-discovery/src/main/java/webapi/formatfilter/FormatResponseFilter.java @@ -41,10 +41,9 @@ public class FormatResponseFilter implements Filter LOGGER.fine("trace"); LOGGER.fine("REQUEST START"); - final String RESPONSE_ENCODING = "UTF-8"; - final String DEFAULT_RESPONSEFORMAT = "application/x-votable+xml"; - final String DEFAULT_SKY_SYSTEM = "ICRS"; // FIXME use enums - final String DEFAULT_SPEC_SYSTEM = "WAVE_Barycentric";// FIXME use enum ALSO in SearchServlet + final String RESPONSE_ENCODING = "UTF-8"; + final String DEFAULT_SKY_SYSTEM = "ICRS"; // FIXME use enums + final String DEFAULT_SPEC_SYSTEM = "WAVE_Barycentric";// FIXME use enum ALSO in SearchServlet FormatResponseWrapper responseWrapper = new FormatResponseWrapper((HttpServletResponse) response); @@ -66,40 +65,17 @@ public class FormatResponseFilter implements Filter Band band = Band.parseBand(params, DEFAULT_SPEC_SYSTEM); DbObstap.Obstap[] obstapArr = queryObstap(responseWrapper.getDbConnArgs(), pubdidArr, pos, band); - LOGGER.info("collected metadata for " + obstapArr.length + " datasets"); - String respFormat; - String respFormatReq[] = params.get("RESPONSEFORMAT"); - if(respFormatReq != null && (respFormatReq.length > 0) && !respFormatReq[0].isEmpty()) - { - respFormat = respFormatReq[0]; - LOGGER.finest("responseFormat(from request): " + respFormat); - } - else - { - respFormat = DEFAULT_RESPONSEFORMAT; - } + LOGGER.info("collected metadata for " + obstapArr.length + " datasets"); response.setCharacterEncoding(RESPONSE_ENCODING); + response.setContentType("application/xml"); + boolean showDuration = true; - if(respFormat.startsWith("application/x-votable+xml")) - { - response.setContentType("application/xml"); - boolean showDuration = false; - - XmlSerializer.serializeToVoTable(responseWriter, RESPONSE_ENCODING, - obstapArr, - settings.serviceUrls.cutoutUrl(), - showDuration,startTime_msec); - } - else - { - final String errMsg = "Illegal response format request: " + respFormat; - LOGGER.warning(errMsg); - response.setContentType("text/plain"); - Lib.doUsageError(errMsg, responseWriter); - // FIXME set http err code - } + XmlSerializer.serializeToVoTable(responseWriter, RESPONSE_ENCODING, + obstapArr, + settings.serviceUrls.cutoutUrl(), + showDuration,startTime_msec); responseWriter.close(); } diff --git a/data-discovery/src/main/java/webapi/formatfilter/XmlSerializer.java b/data-discovery/src/main/java/webapi/formatfilter/XmlSerializer.java index e8d5460eb62cdbece47611331d9ccfa5010e7822..8fc43aacb1125d01fa405790b327fe31da74efba 100644 --- a/data-discovery/src/main/java/webapi/formatfilter/XmlSerializer.java +++ b/data-discovery/src/main/java/webapi/formatfilter/XmlSerializer.java @@ -35,9 +35,16 @@ final class XmlSerializer dstable.setParameter(new DescribedValue( - new DefaultValueInfo("datacubeCount", Integer.class, "Count of all datacubes from VLKB-search" ), + new DefaultValueInfo("datasets count", Integer.class, "Count of all datasets from VLKB-search" ), obstapArr.length ) ); + if(showDuration) + { + dstable.setParameter(new DescribedValue( + new DefaultValueInfo("exec time", Long.class, "Execution time in [msec]" ), + System.currentTimeMillis() - startTime_msec ) ); + } + BufferedWriter out = new BufferedWriter( writer ); out.write("<?xml-stylesheet type='text/xsl' href='VOTable2XHTML.xsl'?>");