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
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ import uws.service.UWSUrl;
 * Useful conversion functions from UWS to JSON.
 *
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 4.2 (09/2017)
 * @version 4.3 (09/2017)
 */
public final class Json4Uws {

@@ -55,6 +55,7 @@ public final class Json4Uws {
		JSONObject json = new JSONObject();
		if (uws != null){
			json.put("name", uws.getName());
			json.put("version", UWS.VERSION);
			json.put("description", uws.getDescription());

			JSONArray jobLists = new JSONArray();
@@ -83,6 +84,7 @@ public final class Json4Uws {
		JSONObject json = new JSONObject();
		if (jobsList != null){
			json.put("name", jobsList.getName());
			json.put("version", UWS.VERSION);
			JSONArray jsonJobs = new JSONArray();
			UWSUrl jobsListUrl = jobsList.getUrl();
			Iterator<UWSJob> it = jobsList.getJobs(owner);
@@ -119,6 +121,7 @@ public final class Json4Uws {
	public final static JSONObject getJson(final UWSJob job, final UWSUrl jobsListUrl, final boolean reference) throws JSONException{
		JSONObject json = new JSONObject();
		if (job != null){
			json.put("version", UWS.VERSION);
			json.put(UWSJob.PARAM_JOB_ID, job.getJobId());
			json.put(UWSJob.PARAM_PHASE, job.getPhase());
			if (reference){
+11 −7
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ import uws.service.request.UploadFile;
 * Lets serializing any UWS resource in XML.
 *
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 4.2 (09/2017)
 * @version 4.3 (09/2017)
 */
public class XMLSerializer extends UWSSerializer {
	private static final long serialVersionUID = 1L;
@@ -150,7 +150,7 @@ public class XMLSerializer extends UWSSerializer {
		String name = uws.getName(), description = uws.getDescription();
		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)
			xml.append(" name=\"").append(escapeXMLAttribute(name)).append('"');
		xml.append(">\n");
@@ -161,10 +161,14 @@ public class XMLSerializer extends UWSSerializer {
		xml.append("\t<jobLists>\n");
		for(JobList jobList : uws){
			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)
				xml.append(escapeXMLAttribute(jlUrl.getRequestURL()));
			xml.append("\" />\n");
				xml.append(" xlink:type=\"simple\" xlink:href=\"").append(escapeXMLAttribute(jlUrl.getRequestURL())).append('"');

			xml.append(" />\n");
		}
		xml.append("\t</jobLists>\n");

@@ -177,7 +181,7 @@ public class XMLSerializer extends UWSSerializer {
	public String getJobList(final JobList jobsList, final JobOwner owner, final boolean root){
		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!
		 * String name = jobsList.getName();
		 * if (name != null)
@@ -201,7 +205,7 @@ public class XMLSerializer extends UWSSerializer {
		String newLine = "\n\t";

		// 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));
		if (job.getRunId() != null)
			xml.append(newLine).append(getRunID(job, false));
+6 −2
Original line number Diff line number Diff line
@@ -64,13 +64,17 @@ import uws.service.request.UWSRequestParser;
 * </b></p>
 *
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 4.2 (09/2017)
 * @version 4.3 (09/2017)
 */
public interface UWS extends Iterable<JobList> {

	/** Version of the UWS protocol used in this library.
	 * @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.
	 * @since 4.1 */