Commit 684bbf11 authored by gmantele's avatar gmantele
Browse files

[UWS] New feature: possibility to set a jobInfo in the job description.

Additionally when an XML document is submitted in an HTTP POST request
(i.e. with the Content-Type = (text|application)/(.+-)?xml), this is
immediately set as a jobInfo in the created job.
parent 66304427
Loading
Loading
Loading
Loading
+39 −2
Original line number Diff line number Diff line
@@ -16,17 +16,19 @@ package org.json;
 * You should have received a copy of the GNU Lesser General Public License
 * along with UWSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 *                       Astronomisches Rechen Institut (ARI)
 */

import java.util.Iterator;

import uws.ISO8601Format;
import uws.UWSException;
import uws.job.ErrorSummary;
import uws.job.JobList;
import uws.job.Result;
import uws.job.UWSJob;
import uws.job.jobInfo.JobInfo;
import uws.job.user.JobOwner;
import uws.service.UWS;
import uws.service.UWSUrl;
@@ -35,7 +37,7 @@ import uws.service.UWSUrl;
 * Useful conversion functions from UWS to JSON.
 * 
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 4.1 (12/2014)
 * @version 4.2 (06/2017)
 */
public final class Json4Uws {

@@ -139,11 +141,46 @@ public final class Json4Uws {
				json.put(UWSJob.PARAM_PARAMETERS, getJobParamsJson(job));
				json.put(UWSJob.PARAM_RESULTS, getJobResultsJson(job));
				json.put(UWSJob.PARAM_ERROR_SUMMARY, getJson(job.getErrorSummary()));
				if (job.getJobInfo() != null)
					json.put(UWSJob.PARAM_JOB_INFO, getJobInfoJson(job));
			}
		}
		return json;
	}

	/**
	 * Gets the JSON representation of the jobInfo of the given job.
	 * 
	 * <p><b>Important note:</b>
	 * 	This function transforms the XML returned by
	 * 	{@link JobInfo#getXML(String)} into a JSON object
	 * 	(see {@link XML#toJSONObject(String)}).
	 * </p>
	 * 
	 * @param job				The job whose the jobInfo must be represented
	 *           				in JSON.
	 * 
	 * @return					The JSON representation of its jobInfo.
	 * 
	 * @throws JSONException	If there is an error while building the JSON
	 *                      	object.
	 * 
	 * @see JobInfo#getXML(String)
	 * @see XML#toJSONObject(String)
	 * 
	 * @since 4.2
	 */
	public final static JSONObject getJobInfoJson(final UWSJob job) throws JSONException{
		if (job.getJobInfo() != null){
			try{
				return XML.toJSONObject(job.getJobInfo().getXML(null));
			}catch(UWSException ue){
				throw new JSONException(ue);
			}
		}else
			return null;
	}

	/**
	 * Gets the JSON representation of the parameters of the given job.
	 * @param job				The job whose the parameters must be represented in JSON.
+38 −39
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package tap;
 * You should have received a copy of the GNU Lesser General Public License
 * along with TAPLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2014 - Astronomisches Rechen Institut (ARI)
 * Copyright 2014-2017 - Astronomisches Rechen Institut (ARI)
 */

import java.io.IOException;
@@ -30,55 +30,58 @@ import uws.UWSToolBox;
import uws.service.file.UWSFileManager;
import uws.service.request.FormEncodedParser;
import uws.service.request.MultipartParser;
import uws.service.request.NoEncodingParser;
import uws.service.request.RequestParser;
import uws.service.request.UploadFile;

/**
 * <p>This parser adapts the request parser to use in function of the request content-type:</p>
 * This parser adapts the request parser to use in function of the request
 * content-type:
 * 
 * <ul>
 * 	<li><b>application/x-www-form-urlencoded</b>: {@link FormEncodedParser}</li>
 * 	<li><b>multipart/form-data</b>: {@link MultipartParser}</li>
 * 	<li><b>other</b>: {@link NoEncodingParser} (the whole request body will be stored as one single parameter)</li>
 * 	<li><b>other</b>: no parameter is returned</li>
 * </ul>
 * 
 * <p>
 * 	The request body size is limited for the multipart AND the no-encoding parsers. If you want to change this limit,
 * 	you MUST do it for each of these parsers, setting the following static attributes: resp. {@link MultipartParser#SIZE_LIMIT}
 * 	and {@link NoEncodingParser#SIZE_LIMIT}.
 * 	The request body size is limited for the multipart. If you want to change
 * 	this limit, you MUST do it for each of these parsers, setting the following
 * 	static attributes: {@link MultipartParser#SIZE_LIMIT}.
 * </p>
 * 
 * <p><i>Note:
 * 	If you want to change the support other request parsing, you will have to write your own {@link RequestParser} implementation.
 * 	If you want to change the support other request parsing, you will have to
 * 	write your own {@link RequestParser} implementation.
 * </i></p>
 * 
 * @author Gr&eacute;gory Mantelet (ARI)
 * @version 2.0 (12/2014)
 * @version 2.1 (06/2017)
 * @since 2.0
 */
public class TAPRequestParser implements RequestParser {

	/** File manager to use to create {@link UploadFile} instances.
	 * It is required by this new object to execute open, move and delete operations whenever it could be asked. */
	 * It is required by this new object to execute open, move and delete
	 * operations whenever it could be asked. */
	private final UWSFileManager fileManager;

	/** {@link RequestParser} to use when a application/x-www-form-urlencoded request must be parsed. This attribute is set by {@link #parse(HttpServletRequest)}
	 * only when needed, by calling the function {@link #getFormParser()}. */
	/** {@link RequestParser} to use when a application/x-www-form-urlencoded
	 * request must be parsed. This attribute is set by
	 * {@link #parse(HttpServletRequest)} only when needed, by calling the
	 * function {@link #getFormParser()}. */
	private RequestParser formParser = null;

	/** {@link RequestParser} to use when a multipart/form-data request must be parsed. This attribute is set by {@link #parse(HttpServletRequest)}
	/** {@link RequestParser} to use when a multipart/form-data request must be
	 * parsed. This attribute is set by {@link #parse(HttpServletRequest)}
	 * only when needed, by calling the function {@link #getMultipartParser()}. */
	private RequestParser multipartParser = null;

	/** {@link RequestParser} to use when none of the other parsers can be used ; it will then transform the whole request body in a parameter called "JDL"
	 * (Job Description Language). This attribute is set by {@link #parse(HttpServletRequest)} only when needed, by calling the function
	 * {@link #getNoEncodingParser()}. */
	private RequestParser noEncodingParser = null;

	/**
	 * Build a {@link RequestParser} able to choose the most appropriate {@link RequestParser} in function of the request content-type.
	 * Build a {@link RequestParser} able to choose the most appropriate
	 * {@link RequestParser} in function of the request content-type.
	 * 
	 * @param fileManager	The file manager to use in order to store any eventual upload. <b>MUST NOT be NULL</b>
	 * @param fileManager	The file manager to use in order to store any
	 *                   	eventual upload. <b>MUST NOT be NULL</b>
	 */
	public TAPRequestParser(final UWSFileManager fileManager){
		if (fileManager == null)
@@ -103,7 +106,7 @@ public class TAPRequestParser implements RequestParser {
			else if (MultipartParser.isMultipartContent(req))
				params = getMultipartParser().parse(req);
			else
				params = getNoEncodingParser().parse(req);
				params = new HashMap<String,Object>(0);

			// Only for POST requests, the parameters specified in the URL must be added:
			if (method.equals("post"))
@@ -115,10 +118,12 @@ public class TAPRequestParser implements RequestParser {
	}

	/**
	 * Get the {@link RequestParser} to use for application/x-www-form-urlencoded HTTP requests.
	 * Get the {@link RequestParser} to use for
	 * application/x-www-form-urlencoded HTTP requests.
	 * This parser may be created if not already done.
	 * 
	 * @return	The {@link RequestParser} to use for application/x-www-form-urlencoded requests. <i>Never NULL</i>
	 * @return	The {@link RequestParser} to use for
	 *        	application/x-www-form-urlencoded requests. <i>Never NULL</i>
	 */
	private synchronized final RequestParser getFormParser(){
		return (formParser != null) ? formParser : (formParser = new FormEncodedParser(){
@@ -142,10 +147,12 @@ public class TAPRequestParser implements RequestParser {
	}

	/**
	 * Get the {@link RequestParser} to use for multipart/form-data HTTP requests.
	 * Get the {@link RequestParser} to use for multipart/form-data HTTP
	 * requests.
	 * This parser may be created if not already done.
	 * 
	 * @return	The {@link RequestParser} to use for multipart/form-data requests. <i>Never NULL</i>
	 * @return	The {@link RequestParser} to use for multipart/form-data
	 *        	requests. <i>Never NULL</i>
	 */
	private synchronized final RequestParser getMultipartParser(){
		return (multipartParser != null) ? multipartParser : (multipartParser = new MultipartParser(fileManager){
@@ -176,22 +183,14 @@ public class TAPRequestParser implements RequestParser {
	}

	/**
	 * Get the {@link RequestParser} to use for HTTP requests whose the content type is neither application/x-www-form-urlencoded nor multipart/form-data.
	 * This parser may be created if not already done.
	 * 
	 * @return	The {@link RequestParser} to use for requests whose the content-type is not supported. <i>Never NULL</i>
	 */
	private synchronized final RequestParser getNoEncodingParser(){
		return (noEncodingParser == null) ? (noEncodingParser = new NoEncodingParser(fileManager)) : noEncodingParser;
	}

	/**
	 * Create a new array in which the given String is appended at the end of the given array.
	 * Create a new array in which the given String is appended at the end of
	 * the given array.
	 * 
	 * @param value		String to append in the array.
	 * @param oldValue	The array after which the given String must be appended.
	 * 
	 * @return	The new array containing the values of the array and then the given String.
	 * @return	The new array containing the values of the array and then the
	 *        	given String.
	 */
	private final static String[] append(final String value, final String[] oldValue){
		// Create the corresponding array of Strings:
+11 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package uws.config;
 * You should have received a copy of the GNU Lesser General Public License
 * along with UWSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2016 - Astronomisches Rechen Institut (ARI)
 * Copyright 2016-2017 - Astronomisches Rechen Institut (ARI)
 */

import static uws.config.UWSConfiguration.KEY_REGEXP_MAX_DESTRUCTION_INTERVAL;
@@ -49,6 +49,7 @@ import uws.job.ErrorSummary;
import uws.job.JobThread;
import uws.job.Result;
import uws.job.UWSJob;
import uws.job.jobInfo.JobInfo;
import uws.job.parameters.DestructionTimeController;
import uws.job.parameters.DurationParamController;
import uws.job.parameters.ExecutionDurationController;
@@ -68,7 +69,7 @@ import uws.service.request.UWSRequestParser;
 * Concrete implementation of a {@link UWSFactory} which is parameterized by a UWS configuration file.
 * 
 * @author Gr&eacute;gory Mantelet (ARI)
 * @version 4.2 (09/2016)
 * @version 4.2 (06/2017)
 * @since 4.2
 */
public class ConfigurableUWSFactory implements UWSFactory {
@@ -620,7 +621,14 @@ public class ConfigurableUWSFactory implements UWSFactory {
			requestID = request.getAttribute(UWS.REQ_ATTRIBUTE_ID).toString();

		// Create the job:
		return new UWSJob(user, createUWSParameters(request), requestID);
		UWSJob newJob = new UWSJob(user, createUWSParameters(request), requestID);

		// Set the XML job description if any:
		Object jobDesc = request.getAttribute(UWS.REQ_ATTRIBUTE_JOB_DESCRIPTION);
		if (jobDesc != null && jobDesc instanceof JobInfo)
			newJob.setJobInfo((JobInfo)jobDesc);

		return newJob;
	}

	@Override
+73 −7
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package uws.job;
 * You should have received a copy of the GNU Lesser General Public License
 * along with UWSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2012-2016 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 *                       Astronomisches Rechen Institut (ARI)
 */

@@ -37,6 +37,7 @@ import uws.ISO8601Format;
import uws.UWSException;
import uws.UWSExceptionFactory;
import uws.UWSToolBox;
import uws.job.jobInfo.JobInfo;
import uws.job.manager.ExecutionManager;
import uws.job.parameters.UWSParameters;
import uws.job.serializer.UWSSerializer;
@@ -114,7 +115,7 @@ import uws.service.request.UploadFile;
 * </ul>
 * 
 * @author	Gr&eacute;gory Mantelet (CDS;ARI)
 * @version	4.2 (01/2016)
 * @version	4.2 (06/2017)
 */
public class UWSJob extends SerializableUWSObject {
	private static final long serialVersionUID = 1L;
@@ -170,6 +171,10 @@ public class UWSJob extends SerializableUWSObject {
	/** Name of the parameter <i>results</i>. */
	public static final String PARAM_RESULTS = "results";

	/** Name of the parameter <i>jobInfo</i>.
	 * @since 4.2 */
	public static final String PARAM_JOB_INFO = "jobInfo";

	/** Default value of {@link #owner} if no ID are given at the job creation. */
	public final static String ANONYMOUS_OWNER = "anonymous";

@@ -249,6 +254,10 @@ public class UWSJob extends SerializableUWSObject {
	/** List of all input parameters (UWS standard and non-standard parameters). */
	protected final UWSParameters inputParams;

	/** Additional description of this job.
	 * @since 4.2 */
	protected JobInfo jobInfo = null;

	/** The thread to start for executing the job. */
	protected transient JobThread thread = null;

@@ -1143,6 +1152,54 @@ public class UWSJob extends SerializableUWSObject {
		}
	}

	/**
	 * Get the additional information about this job.
	 * 
	 * @return	Additional info. about this job,
	 *        	or NULL if there is none.
	 * 
	 * @since 4.2
	 */
	public final JobInfo getJobInfo(){
		return jobInfo;
	}

	/**
	 * Set the additional information about this job.
	 * 
	 * <p><i>Note:
	 * 	By default, this function replaces the current {@link JobInfo}
	 * 	of this job by the given one (even if NULL). This behavior
	 * 	can be changed by overwriting this function and by returning the
	 * 	extended {@link UWSJob} in the used {@link UWSFactory}.
	 * </i></p>
	 * 
	 * <p><b>Important note:</b>
	 * 	When attributing a {@link JobInfo} to a {@link UWSJob}, you
	 * 	may have to call {@link JobInfo#setJob(UWSJob)} on the former
	 * 	and the new jobInfo (see the default implementation for an example)
	 * 	for some implementations of {@link JobInfo}.
	 * </p>
	 * 
	 * @param newJobInfo	The new additional info. about this job.
	 *                  	<i>NULL is allowed and should be used to remove a
	 *                  	JobInfo from a job.</i>
	 * 
	 * @since 4.2
	 */
	public void setJobInfo(final JobInfo newJobInfo){
		// Cut the link between the former jobInfo and this job:
		if (this.jobInfo != null)
			this.jobInfo.setJob(null);

		// Establish a link between the new jobInfo and this job:
		if (newJobInfo != null)
			newJobInfo.setJob(this);

		// Replace the former jobInfo by the given one:
		this.jobInfo = newJobInfo;
	}

	/**
	 * Gets the execution manager of this job, if any.
	 * 
@@ -1458,7 +1515,7 @@ public class UWSJob extends SerializableUWSObject {
	 * <p>Stops the job if running, removes the job from the execution manager, stops the timer for the execution duration
	 * and may clear all files or any other resources associated to this job.</p>
	 * 
	 * <p><i>By default the job is aborted, the {@link UWSJob#thread} attribute is set to null, the timers are stopped and uploaded files, results and the error summary are deleted.</i></p>
	 * <p><i>By default the job is aborted, the {@link UWSJob#thread} attribute is set to null, the timers are stopped and uploaded files, results and the error summary are deleted and the jobInfo is destroyed.</i></p>
	 */
	public void clearResources(){
		// If still running, abort/stop the job:
@@ -1507,6 +1564,15 @@ public class UWSJob extends SerializableUWSObject {
			}
		}

		// Destroy the additional job info.:
		if (jobInfo != null){
			try{
				jobInfo.destroy();
			}catch(UWSException ue){
				getLogger().logJob(LogLevel.ERROR, this, "CLEAR_RESOURCES", "Impossible to destroy the additional information about the job \"" + jobId + "\"", ue);
			}
		}

		getLogger().logJob(LogLevel.INFO, this, "CLEAR_RESOURCES", "Resources associated with the job \"" + getJobId() + "\" have been successfully freed.", null);
	}

@@ -1677,7 +1743,7 @@ public class UWSJob extends SerializableUWSObject {

	@Override
	public String toString(){
		return "JOB {jobId: " + jobId + "; phase: " + phase + "; runId: " + getRunId() + "; ownerId: " + owner + "; executionDuration: " + getExecutionDuration() + "; destructionTime: " + getDestructionTime() + "; quote: " + quote + "; NbResults: " + results.size() + "; " + ((errorSummary != null) ? errorSummary.toString() : "No error") + " }";
		return "JOB {jobId: " + jobId + "; phase: " + phase + "; runId: " + getRunId() + "; ownerId: " + owner + "; executionDuration: " + getExecutionDuration() + "; destructionTime: " + getDestructionTime() + "; quote: " + quote + "; NbResults: " + results.size() + "; " + ((errorSummary != null) ? errorSummary.toString() : "No error") + " ; HasJobInfo: \"" + ((jobInfo != null) ? "yes" : "no") + "\"  }";
	}

	@Override
+207 −0
Original line number Diff line number Diff line
package uws.job.jobInfo;

/*
 * This file is part of UWSLibrary.
 * 
 * UWSLibrary is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * UWSLibrary is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with UWSLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2017 - Astronomisches Rechen Institut (ARI)
 */

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

import javax.servlet.http.HttpServletResponse;

import uws.UWSException;
import uws.job.UWSJob;
import uws.job.serializer.XMLSerializer;

/**
 * API wrapping an object which provides more information about a job.
 * 
 * <p>
 * 	It can be a simple information (e.g. job progress ;
 * 	see {@link SingleValueJobInfo}) or a whole job description instead of
 * 	parameters as described in REC-UWS-1.0,
 * 	"1.3. Job description language, service contracts and universality"
 * 	(e.g. an XML document ; see {@link XMLJobInfo}).
 * </p>
 * 
 * <p><b>Representation</b></p>
 * <p>
 * 	As requested by REC-UWS-1.0, the function {@link #getXML(String)}
 * 	must return an XML representation of this jobInfo, but that does not
 * 	mean that the additional job information have to be in XML ; they can be
 * 	an XML, a .txt, an image, ... The function {@link #getXML(String)} just
 * 	needs to return a representation of this jobInfo:
 * 	either the jobInfo content itself or a link to access it into details.
 * </p>
 * <p>
 * 	The function {@link #write(HttpServletResponse)} is only used when
 * 	ONLY the content of a job's jobInfo is requested:
 * 	with the URL <code>{uws-root}/{job-list}/{job-id}/jobInfo</code>.
 * 	It allows to return the real content of this jobInfo (if not already
 * 	the XML returned by {@link #getXML(String)}).
 * </p>
 * 
 * <p><b>Resource management</b></p>
 * <p>
 * 	In case the jobInfo is associated with other resources (e.g. memory, file,
 * 	...), the function {@link #destroy()} must be able to discard them.
 * 	This function is always called at job destruction.
 * </p>
 * 
 * <p><b>Backup</b></p>
 * <p>
 * 	The implementation of a {@link JobInfo} being free, the only viable way to
 * 	backup a such object is by Java Class Serialization (see
 * 	{@link Serializable}, {@link ObjectOutputStream} and
 * 	{@link ObjectInputStream}). A default serialization is already implemented,
 * 	but it can be customized by overriding the following functions:
 * </p>
 * <ul>
 * 	<li><code>private void writeObject(java.io.ObjectOutputStream out)
 *              throws IOException</code></li>
 * 	<li><code>private void readObject(java.io.ObjectInputStream in)
 *              throws IOException, ClassNotFoundException;</code></li>
 * 	<li><code>private void readObjectNoData()
 *              throws ObjectStreamException;</code></li>
 * </ul>
 * 
 * <p><i>See the Javadoc of {@link Serializable} for more details.</i></p>
 * 
 * <p><b>Link with {@link UWSJob}</b></p>
 * 
 * <p>
 * 	Once a {@link JobInfo} is attached to a job (thanks to
 * 	{@link UWSJob#setJobInfo(JobInfo)}), the function {@link #setJob(UWSJob)} is
 * 	called. In some implementation, no action is needed (see
 * 	{@link SingleValueJobInfo}), but in some others it may be required to either
 * 	keep a link with the parent job or to execute some special action.
 * </p>
 * 
 * <p><b>Warning:</b>
 * 	Since a {@link JobInfo} must be {@link Serializable} it is recommended to
 * 	flag complex objects like {@link UWSJob} as <i>transient</i> as much as
 * 	possible in order to make the backup and restore processes lighter.
 * 	Some objects like the parent job are naturally restored when
 * 	{@link #setJob(UWSJob)} is called. See {@link XMLJobInfo} for a concrete
 * 	example.
 * </p>
 * 
 * @author Gr&eacute;gory Mantelet (ARI)
 * @version 4.2 (06/2017)
 * @since 4.2
 */
public interface JobInfo extends Serializable {

	/**
	 * Get the XML representation of this {@link JobInfo}.
	 * 
	 * <p><i>Note 1:
	 * 	This function does not force the jobInfo to be in
	 * 	XML but asks for a piece of XML document to append
	 * 	to the XML representation of a job and representing
	 * 	this jobInfo. It may be a full serialization of it or
	 * 	merely a link (see <a href="https://www.w3.org/TR/xlink11/">Xlink</a>)
	 * 	toward a complete document (XML or not).
	 * </i></p>
	 * 
	 * <p><i>Note 2:
	 * 	The returned piece of XML can refer to the following
	 * 	XML schemas:
	 * </i></p>
	 * <ul><i>
	 * 	<li>"http://www.ivoa.net/xml/UWS/v1.0" (no prefix),</li>
	 * 	<li>"http://www.w3.org/1999/xlink" (prefix: xlink),</li>
	 * 	<li>"http://www.w3.org/2001/XMLSchema" (prefix: xs),</li>
	 * 	<li>"http://www.w3.org/2001/XMLSchema-instance" (prefix: xsi).</li>
	 * </i></ul>
	 * <p><i>
	 * 	If more namespaces are needed they should be specified directly
	 * 	at the root of the XML returned by this function (if possible
	 * 	with a valid <code>xsi:schemaLocation</code>). An alternative
	 * 	would be to extend {@link XMLSerializer} in order to append
	 * 	the needed namespaces to the root XML node of any formatted XML
	 * 	documents.
	 * </i></p>
	 * 
	 * @param newLinePrefix	Characters (generally white-spaces) that should
	 *                     	prefix all new line of the returned piece of
	 *                     	XML. New line characters should also be
	 *                     	included in this string ; if not, the
	 *                     	returned XML should be on a single line.
	 *                     	<i>This parameter may be NULL.</i>
	 * 
	 * @return	XML representation of this jobInfo.
	 * 
	 * @throws UWSException	If any error occurs while building the XML
	 *                     	representation of this jobInfo.
	 */
	public String getXML(final String newLinePrefix) throws UWSException;

	/**
	 * Write the content of this jobInfo as a complete HTTP response
	 * when the URL <code>{uws-root}/{job-list}/{job-id}/jobInfo</code> is
	 * requested.
	 * 
	 * <p><b>Important:</b>
	 * 	At least the Content-Type, the Content-Length and Character-Encoding
	 * 	should be set in addition of the response content.
	 * </p>
	 * 
	 * <p><i>Note:
	 * 	If formatted into XML, the root node of the returned document
	 * 	may be the UWS node "jobInfo" or not, depending on your
	 * 	desired implementation. Since the UWS standard does not specify
	 * 	any way to retrieve individually a jobInfo, this part is left
	 * 	here totally free to the developer will.
	 * </i></p>
	 * 
	 * @param response	HTTP response in which the jobInfo content must be
	 *                	written.
	 * 
	 * @throws IOException	If there is any error while writing the jobInfo
	 *                    	content.
	 * @throws UWSException	If there is any error while formating the jobInfo
	 *                     	content.
	 */
	public void write(final HttpServletResponse response) throws IOException, UWSException;

	/**
	 * Notify this {@link JobInfo} that it is now owned by the given job.
	 * 
	 * @param myJob	The new owner of this {@link JobInfo}.
	 *             	<i>This parameter may be NULL.</i>
	 */
	public void setJob(final UWSJob myJob);

	/**
	 * Free/Discard any resource associated with this {@link JobInfo}.
	 * 
	 * <p><i>Note:</i>
	 * 	This function should be called only at job destruction.
	 * 	It particularly aims to delete any file containing the full
	 * 	content of this JobInfo, but it should also be used for any
	 * 	other kind of associated resource.
	 * </p>
	 * 
	 * @throws UWSException	If all associated resources can not be freed.
	 */
	public void destroy() throws UWSException;

}
Loading