Skip to content
Snippets Groups Projects
Commit 210cb1b0 authored by Robert Butora's avatar Robert Butora
Browse files

removes RESPONSEFORMAT param and shows exec-time in VoTable

parent 22b75e16
No related branches found
No related tags found
No related merge requests found
......@@ -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();
}
......
......@@ -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'?>");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment