Skip to content
Snippets Groups Projects
Commit 15f2fb81 authored by gmantele's avatar gmantele
Browse files

[UWS] Add the UWS protocol version as attributes of the nodes <uws>, <jobs> and

<job>.

This commit also:

    - set the version of the UWS protocol to 1.1 (cf UWS.VERSION)
	- add a static constant for the standardID (cf UWS.STANDARD_ID)
	- add a xlink:type and xlink:href for jobListRef in the uws XML
	- set the @version Javadoc attribute of all modified classes to 4.3
	  (scheduled version of the UWSLibrary supporting UWS-1.1)
parent 404db993
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,7 @@ import uws.service.UWSUrl; ...@@ -37,7 +37,7 @@ import uws.service.UWSUrl;
* Useful conversion functions from UWS to JSON. * Useful conversion functions from UWS to JSON.
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 4.2 (09/2017) * @version 4.3 (09/2017)
*/ */
public final class Json4Uws { public final class Json4Uws {
...@@ -55,6 +55,7 @@ public final class Json4Uws { ...@@ -55,6 +55,7 @@ public final class Json4Uws {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
if (uws != null){ if (uws != null){
json.put("name", uws.getName()); json.put("name", uws.getName());
json.put("version", UWS.VERSION);
json.put("description", uws.getDescription()); json.put("description", uws.getDescription());
JSONArray jobLists = new JSONArray(); JSONArray jobLists = new JSONArray();
...@@ -83,6 +84,7 @@ public final class Json4Uws { ...@@ -83,6 +84,7 @@ public final class Json4Uws {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
if (jobsList != null){ if (jobsList != null){
json.put("name", jobsList.getName()); json.put("name", jobsList.getName());
json.put("version", UWS.VERSION);
JSONArray jsonJobs = new JSONArray(); JSONArray jsonJobs = new JSONArray();
UWSUrl jobsListUrl = jobsList.getUrl(); UWSUrl jobsListUrl = jobsList.getUrl();
Iterator<UWSJob> it = jobsList.getJobs(owner); Iterator<UWSJob> it = jobsList.getJobs(owner);
...@@ -119,6 +121,7 @@ public final class Json4Uws { ...@@ -119,6 +121,7 @@ public final class Json4Uws {
public final static JSONObject getJson(final UWSJob job, final UWSUrl jobsListUrl, final boolean reference) throws JSONException{ public final static JSONObject getJson(final UWSJob job, final UWSUrl jobsListUrl, final boolean reference) throws JSONException{
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
if (job != null){ if (job != null){
json.put("version", UWS.VERSION);
json.put(UWSJob.PARAM_JOB_ID, job.getJobId()); json.put(UWSJob.PARAM_JOB_ID, job.getJobId());
json.put(UWSJob.PARAM_PHASE, job.getPhase()); json.put(UWSJob.PARAM_PHASE, job.getPhase());
if (reference){ if (reference){
......
...@@ -40,7 +40,7 @@ import uws.service.request.UploadFile; ...@@ -40,7 +40,7 @@ import uws.service.request.UploadFile;
* Lets serializing any UWS resource in XML. * Lets serializing any UWS resource in XML.
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 4.2 (09/2017) * @version 4.3 (09/2017)
*/ */
public class XMLSerializer extends UWSSerializer { public class XMLSerializer extends UWSSerializer {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -150,7 +150,7 @@ public class XMLSerializer extends UWSSerializer { ...@@ -150,7 +150,7 @@ public class XMLSerializer extends UWSSerializer {
String name = uws.getName(), description = uws.getDescription(); String name = uws.getName(), description = uws.getDescription();
StringBuffer xml = new StringBuffer(getHeader()); StringBuffer xml = new StringBuffer(getHeader());
xml.append("<uws").append(getUWSNamespace(true)); xml.append("<uws version=\"").append(UWS.VERSION).append('"').append(getUWSNamespace(true));
if (name != null) if (name != null)
xml.append(" name=\"").append(escapeXMLAttribute(name)).append('"'); xml.append(" name=\"").append(escapeXMLAttribute(name)).append('"');
xml.append(">\n"); xml.append(">\n");
...@@ -161,10 +161,14 @@ public class XMLSerializer extends UWSSerializer { ...@@ -161,10 +161,14 @@ public class XMLSerializer extends UWSSerializer {
xml.append("\t<jobLists>\n"); xml.append("\t<jobLists>\n");
for(JobList jobList : uws){ for(JobList jobList : uws){
UWSUrl jlUrl = jobList.getUrl(); UWSUrl jlUrl = jobList.getUrl();
xml.append("\t\t<jobListRef name=\"").append(escapeXMLAttribute(jobList.getName())).append("\" href=\""); xml.append("\t\t<jobListRef name=\"").append(escapeXMLAttribute(jobList.getName())).append('"');
/* The XLink attributes are optional. So if no URL is available for
* this Job List reference, none is written here: */
if (jlUrl != null && jlUrl.getRequestURL() != null) if (jlUrl != null && jlUrl.getRequestURL() != null)
xml.append(escapeXMLAttribute(jlUrl.getRequestURL())); xml.append(" xlink:type=\"simple\" xlink:href=\"").append(escapeXMLAttribute(jlUrl.getRequestURL())).append('"');
xml.append("\" />\n");
xml.append(" />\n");
} }
xml.append("\t</jobLists>\n"); xml.append("\t</jobLists>\n");
...@@ -177,7 +181,7 @@ public class XMLSerializer extends UWSSerializer { ...@@ -177,7 +181,7 @@ public class XMLSerializer extends UWSSerializer {
public String getJobList(final JobList jobsList, final JobOwner owner, final boolean root){ public String getJobList(final JobList jobsList, final JobOwner owner, final boolean root){
StringBuffer xml = new StringBuffer(getHeader()); StringBuffer xml = new StringBuffer(getHeader());
xml.append("<jobs").append(getUWSNamespace(true)); xml.append("<jobs version=\"").append(UWS.VERSION).append('"').append(getUWSNamespace(true));
/* NOTE: NO ATTRIBUTE "name" IN THE XML SCHEMA! /* NOTE: NO ATTRIBUTE "name" IN THE XML SCHEMA!
* String name = jobsList.getName(); * String name = jobsList.getName();
* if (name != null) * if (name != null)
...@@ -201,7 +205,7 @@ public class XMLSerializer extends UWSSerializer { ...@@ -201,7 +205,7 @@ public class XMLSerializer extends UWSSerializer {
String newLine = "\n\t"; String newLine = "\n\t";
// general information: // general information:
xml.append("<job").append(getUWSNamespace(root)).append('>'); xml.append("<job version=\"").append(UWS.VERSION).append('"').append(getUWSNamespace(root)).append('>');
xml.append(newLine).append(getJobID(job, false)); xml.append(newLine).append(getJobID(job, false));
if (job.getRunId() != null) if (job.getRunId() != null)
xml.append(newLine).append(getRunID(job, false)); xml.append(newLine).append(getRunID(job, false));
......
...@@ -64,13 +64,17 @@ import uws.service.request.UWSRequestParser; ...@@ -64,13 +64,17 @@ import uws.service.request.UWSRequestParser;
* </b></p> * </b></p>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 4.2 (09/2017) * @version 4.3 (09/2017)
*/ */
public interface UWS extends Iterable<JobList> { public interface UWS extends Iterable<JobList> {
/** Version of the UWS protocol used in this library. /** Version of the UWS protocol used in this library.
* @since 4.2 */ * @since 4.2 */
public final static String VERSION = "1.0"; public final static String VERSION = "1.1";
/** IVOA standardID of a UWS service currently generated by this library.
* @since 4.2 */
public final static String STANDARD_ID = "ivo://ivoa.net/std/UWS#rest-1.1";
/** Attribute of the HttpServletRequest to set and to get in order to access the request ID set by the UWS library. /** Attribute of the HttpServletRequest to set and to get in order to access the request ID set by the UWS library.
* @since 4.1 */ * @since 4.1 */
......
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