diff --git a/src/tap/formatter/VOTableFormat.java b/src/tap/formatter/VOTableFormat.java index b6b59c4d496d865c8e9730be51fcff11834ff0b4..eab9fc7d109212ff911e1b054dd5d2069653793e 100644 --- a/src/tap/formatter/VOTableFormat.java +++ b/src/tap/formatter/VOTableFormat.java @@ -212,7 +212,9 @@ public class VOTableFormat implements OutputFormat { BufferedWriter out = new BufferedWriter(writer); // Set the root VOTABLE node: - out.write("<VOTABLE" + VOSerializer.formatAttribute("version", votVersion.getVersionNumber()) + VOSerializer.formatAttribute("xmlns", votVersion.getXmlNamespace()) + ">"); + out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); + out.newLine(); + out.write("<VOTABLE" + VOSerializer.formatAttribute("version", votVersion.getVersionNumber()) + VOSerializer.formatAttribute("xmlns", votVersion.getXmlNamespace()) + VOSerializer.formatAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") + VOSerializer.formatAttribute("xsi:schemaLocation", votVersion.getXmlNamespace() + " " + votVersion.getSchemaLocation()) + ">"); out.newLine(); // The RESOURCE note MUST have a type "results": [REQUIRED] @@ -234,7 +236,7 @@ public class VOTableFormat implements OutputFormat { Iterator<Map.Entry<String,String>> it = otherInfo.entrySet().iterator(); while(it.hasNext()){ Map.Entry<String,String> entry = it.next(); - out.write("<INFO " + VOSerializer.formatAttribute("name", entry.getKey()) + ">" + VOSerializer.formatText(entry.getValue()) + "</INFO>"); + out.write("<INFO " + VOSerializer.formatAttribute("name", entry.getKey()) + VOSerializer.formatAttribute("value", entry.getValue()) + "/>"); out.newLine(); } } @@ -304,7 +306,9 @@ public class VOTableFormat implements OutputFormat { */ protected void writeHeader(final VOTableVersion votVersion, final TAPExecutionReport execReport, final BufferedWriter out) throws IOException, TAPException{ // Set the root VOTABLE node: - out.write("<VOTABLE" + VOSerializer.formatAttribute("version", votVersion.getVersionNumber()) + VOSerializer.formatAttribute("xmlns", votVersion.getXmlNamespace()) + ">"); + out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); + out.newLine(); + out.write("<VOTABLE" + VOSerializer.formatAttribute("version", votVersion.getVersionNumber()) + VOSerializer.formatAttribute("xmlns", votVersion.getXmlNamespace()) + VOSerializer.formatAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance") + VOSerializer.formatAttribute("xsi:schemaLocation", votVersion.getXmlNamespace() + " " + votVersion.getSchemaLocation()) + ">"); out.newLine(); // The RESOURCE note MUST have a type "results": [REQUIRED] @@ -324,7 +328,7 @@ public class VOTableFormat implements OutputFormat { // Append the ADQL query at the origin of this result: [OPTIONAL] String adqlQuery = execReport.parameters.getQuery(); if (adqlQuery != null){ - out.write("<INFO name=\"QUERY\">" + VOSerializer.formatText(adqlQuery) + "</INFO>"); + out.write("<INFO name=\"QUERY\"" + VOSerializer.formatAttribute("value", adqlQuery) + "/>"); out.newLine(); } diff --git a/src/tap/parameters/FormatController.java b/src/tap/parameters/FormatController.java index 4e8d37a5c16c5dc8b8d78a84b698c70ad432b2c7..93e654b69fc6635e436739ff85f05dfd5f75022f 100644 --- a/src/tap/parameters/FormatController.java +++ b/src/tap/parameters/FormatController.java @@ -86,11 +86,11 @@ public class FormatController implements InputParamController { return getDefault(); if (service.getOutputFormat(strFormat) == null) - throw new UWSException(UWSException.BAD_REQUEST, "Unknown value for the job parameter format: \"" + strFormat + "\". It should be " + getAllowedFormats()); + throw new UWSException(UWSException.BAD_REQUEST, "Unknown value for the parameter \"format\": \"" + strFormat + "\". It should be " + getAllowedFormats()); else return strFormat; }else - throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the format parameter: class \"" + format.getClass().getName() + "\"! It should be a String."); + throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the parameter \"format\": class \"" + format.getClass().getName() + "\"! It should be a String."); } /** diff --git a/src/tap/parameters/MaxRecController.java b/src/tap/parameters/MaxRecController.java index 0fc665587a3364894a7d284f7165f892e0c17390..6aa4694653467239a045ad31eb3d91409ca8016e 100644 --- a/src/tap/parameters/MaxRecController.java +++ b/src/tap/parameters/MaxRecController.java @@ -103,10 +103,10 @@ public class MaxRecController implements InputParamController { try{ maxRec = Integer.parseInt(strValue); }catch(NumberFormatException nfe){ - throw new UWSException(UWSException.BAD_REQUEST, "Wrong format for the MaxRec parameter: \"" + strValue + "\"! It should be a integer value between " + TAPJob.UNLIMITED_MAX_REC + " and " + maxOutputLimit + " (Default value: " + defaultOutputLimit + ")."); + throw new UWSException(UWSException.BAD_REQUEST, "Wrong format for the parameter \"maxrec\": \"" + strValue + "\"! It should be a integer value between " + TAPJob.UNLIMITED_MAX_REC + " and " + maxOutputLimit + " (Default value: " + defaultOutputLimit + ")."); } }else - throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the MaxRec parameter: class \"" + value.getClass().getName() + "\"! It should be an integer or a string containing only an integer value."); + throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the parameter \"maxrec\": class \"" + value.getClass().getName() + "\"! It should be an integer or a string containing only an integer value."); // A negative output limit is considered as an unlimited output limit: if (maxRec < TAPJob.UNLIMITED_MAX_REC) diff --git a/src/tap/parameters/TAPDestructionTimeController.java b/src/tap/parameters/TAPDestructionTimeController.java index 1087aa84ad28f70eef8941569c69543021d57168..4546561350e36ad167a46d73e75d867ec9fa13f5 100644 --- a/src/tap/parameters/TAPDestructionTimeController.java +++ b/src/tap/parameters/TAPDestructionTimeController.java @@ -148,14 +148,14 @@ public class TAPDestructionTimeController implements InputParamController { try{ date = UWSJob.dateFormat.parse(strValue); }catch(ParseException pe){ - throw new UWSException(UWSException.BAD_REQUEST, pe, "Wrong date format for the destruction time parameter: \"" + strValue + "\"! The format to respect is: " + UWSJob.DEFAULT_DATE_FORMAT); + throw new UWSException(UWSException.BAD_REQUEST, pe, "Wrong date format for the parameter \"destruction\": \"" + strValue + "\"! The format to respect is: " + UWSJob.DEFAULT_DATE_FORMAT); } }else - throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the destruction time parameter: class \"" + value.getClass().getName() + "\"! It should be a Date or a string containing a date with the format \"" + UWSJob.DEFAULT_DATE_FORMAT + "\"."); + throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the parameter \"destruction\": class \"" + value.getClass().getName() + "\"! It should be a Date or a string containing a date with the format \"" + UWSJob.DEFAULT_DATE_FORMAT + "\"."); Date maxDate = getMaxDestructionTime(); if (maxDate != null && date.after(maxDate)) - throw new UWSException(UWSException.BAD_REQUEST, "The TAP service limits the DESTRUCTION INTERVAL (since now) to " + getMaxRetentionPeriod() + " s !"); + throw new UWSException(UWSException.BAD_REQUEST, "The TAP service limits the destruction interval (since now) to " + getMaxRetentionPeriod() + " s !"); return date; } diff --git a/src/tap/parameters/TAPExecutionDurationController.java b/src/tap/parameters/TAPExecutionDurationController.java index 85922cd158814f7e89542e97401e2e608d1c6d97..63d15ba28de6cbb1ea1a0c13e037f6603eea3921 100644 --- a/src/tap/parameters/TAPExecutionDurationController.java +++ b/src/tap/parameters/TAPExecutionDurationController.java @@ -104,10 +104,10 @@ public class TAPExecutionDurationController implements InputParamController { try{ duration = Long.parseLong((String)value); }catch(NumberFormatException nfe){ - throw new UWSException(UWSException.BAD_REQUEST, "Wrong format for the maximum duration parameter: \"" + value.toString() + "\"! It should be a long numeric value between " + TAPJob.UNLIMITED_DURATION + " and " + maxDuration + " (Default value: " + defaultDuration + ")."); + throw new UWSException(UWSException.BAD_REQUEST, "Wrong format for the parameter \"executionduration\": \"" + value.toString() + "\"! It should be a long numeric value between " + TAPJob.UNLIMITED_DURATION + " and " + maxDuration + " (Default value: " + defaultDuration + ")."); } }else - throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the maximum duration parameter: class \"" + value.getClass().getName() + "\"! It should be long or a string containing only a long value."); + throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the parameter \"executionduration\": class \"" + value.getClass().getName() + "\"! It should be long or a string containing only a long value."); if (duration < TAPJob.UNLIMITED_DURATION) duration = TAPJob.UNLIMITED_DURATION; diff --git a/src/tap/parameters/TAPParameters.java b/src/tap/parameters/TAPParameters.java index d24d2034ef2f01862abce503c187e63bd1e95041..461c7ee024abb59fca941b3de91cc070f194b54c 100644 --- a/src/tap/parameters/TAPParameters.java +++ b/src/tap/parameters/TAPParameters.java @@ -81,7 +81,7 @@ public class TAPParameters extends UWSParameters { // Multipart HTTP parameters: if (isMultipartContent(request)){ if (!service.uploadEnabled()) - throw new TAPException("Request error ! This TAP service has no Upload capability !"); + throw new TAPException("Request error ! This TAP service has no Upload capability !", UWSException.BAD_REQUEST); File uploadDir = service.getFileManager().getUploadDirectory(); try{ @@ -287,7 +287,7 @@ public class TAPParameters extends UWSParameters { for(int i = 0; i < pairs.length; i++){ String[] table = pairs[i].split(","); if (table.length != 2) - throw new TAPException("UPLOAD parameter incorrect: bad syntax! An UPLOAD parameter must contain a list of pairs separated by a ';'. Each pair is composed of 2 parts, a table name and a URI separated by a ','."); + throw new TAPException("UPLOAD parameter incorrect: bad syntax! An UPLOAD parameter must contain a list of pairs separated by a ';'. Each pair is composed of 2 parts, a table name and a URI separated by a ','.", UWSException.BAD_REQUEST); loaders[i] = new TableLoader(table[0], table[1], multipart); } @@ -298,13 +298,13 @@ public class TAPParameters extends UWSParameters { // Check that required parameters are not NON-NULL: String requestParam = getRequest(); if (requestParam == null) - throw new TAPException("The parameter \"" + TAPJob.PARAM_REQUEST + "\" must be provided and its value must be equal to \"" + TAPJob.REQUEST_DO_QUERY + "\" or \"" + TAPJob.REQUEST_GET_CAPABILITIES + "\" !"); + throw new TAPException("The parameter \"" + TAPJob.PARAM_REQUEST + "\" must be provided and its value must be equal to \"" + TAPJob.REQUEST_DO_QUERY + "\" or \"" + TAPJob.REQUEST_GET_CAPABILITIES + "\" !", UWSException.BAD_REQUEST); if (requestParam.equals(TAPJob.REQUEST_DO_QUERY)){ if (get(TAPJob.PARAM_LANGUAGE) == null) - throw new TAPException("The parameter \"" + TAPJob.PARAM_LANGUAGE + "\" must be provided if " + TAPJob.PARAM_REQUEST + "=" + TAPJob.REQUEST_DO_QUERY + " !"); + throw new TAPException("The parameter \"" + TAPJob.PARAM_LANGUAGE + "\" must be provided if " + TAPJob.PARAM_REQUEST + "=" + TAPJob.REQUEST_DO_QUERY + " !", UWSException.BAD_REQUEST); else if (get(TAPJob.PARAM_QUERY) == null) - throw new TAPException("The parameter \"" + TAPJob.PARAM_QUERY + "\" must be provided if " + TAPJob.PARAM_REQUEST + "=" + TAPJob.REQUEST_DO_QUERY + " !"); + throw new TAPException("The parameter \"" + TAPJob.PARAM_QUERY + "\" must be provided if " + TAPJob.PARAM_REQUEST + "=" + TAPJob.REQUEST_DO_QUERY + " !", UWSException.BAD_REQUEST); } // Check the version if needed: diff --git a/src/uws/job/parameters/StringParamController.java b/src/uws/job/parameters/StringParamController.java index 85530e3f06715366a720836d928b2cdc1fcdb5aa..2eecd59327768ed955441981ad5a911a5b29c3e3 100644 --- a/src/uws/job/parameters/StringParamController.java +++ b/src/uws/job/parameters/StringParamController.java @@ -133,11 +133,11 @@ public class StringParamController implements InputParamController { if (strValue.equalsIgnoreCase(v)) return v; } - throw new UWSException(UWSException.BAD_REQUEST, "Unknown value for the job parameter " + paramName + ": \"" + strValue + "\". It should be " + getExpectedFormat()); + throw new UWSException(UWSException.BAD_REQUEST, "Unknown value for the parameter \"" + paramName + "\": \"" + strValue + "\". It should be " + getExpectedFormat()); }else return strValue; }else - throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the parameter " + paramName + ": \"" + value.getClass().getName() + "\"! It should be a String."); + throw new UWSException(UWSException.INTERNAL_SERVER_ERROR, "Wrong type for the parameter \"" + paramName + "\": \"" + value.getClass().getName() + "\"! It should be a String."); } /** @@ -146,7 +146,7 @@ public class StringParamController implements InputParamController { * @return A string which describes the format expected by this controller. */ protected final String getExpectedFormat(){ - if (possibleValues == null || possibleValues.length == 0){ + if (possibleValues != null && possibleValues.length > 0){ StringBuffer buffer = new StringBuffer("a String value among: "); for(int i = 0; i < possibleValues.length; i++) buffer.append((i == 0) ? "" : ", ").append(possibleValues[i]);