[Zoo-discuss] Handling output files

Fenoy Gerald gerald.fenoy at geolabs.fr
Fri May 6 03:17:33 PDT 2016


Hi Rakesh,
My answer inline bellow.

> Le 4 mai 2016 à 00:22, rakesh prithiviraj <rakeshuk at outlook.com> a écrit :
> 
> Hi,
> 
> I have a legacy Java code that processes several input files (images, text files together) and generates  multiple output files in different formats. The output files are stored in a particular directory (configuration parameter of the processor). I am planning to create a wrapper processor for this legacy code so that I can use it based on WPS standards. 
> 
> The wrapper WPS processor will receive 3 parameters (conf, inputs, outputs) and I will pass the inputs to the legacy code which will process the input and will create output files. I will have a list of Java File objects as a result. To handle this scenario, in the zcfg file, I can write something as follows for each of the output. But this is clearly not sufficient to make the output files URLs appear in GetResult response.
> 
>  <DataOutputs>
>   [Result1]
>    Title = This is result 1
>    Abstract = A image file .
>    <ComplexData>
>     <Default>
>      mimeType = image/tiff
>      extension = tif
>     </Default>
>    </ComplexData>
>  </DataOutputs>  
> 
> In the WPS wrapper code, how do I push the output files to the "outputs" parameter (passed to wrapper processor). In the hello-java example, string is pushed to the "outputs" as follows: 
> 
>  HashMap hm1 = (HashMap)(outputs.get("Result"));
>   hm1.put("value",ZOO._("Hello "+v+" from JAVA World !!"));

In case you are already writing the file to the file system, then you can decide to write the same data in the value field of your output. Nevertheless, there is a trick here that can be of some use for your specific case. When we have integrated the SAGA-GIS services, we faced the exact same issue. Meaning that we are dealing with file generated on the file system. So, we added handling of a specific field named « generated_file » which let you directly give the name of the generated file. The limitation to this method is that your file have to be stored in the path defined in the tmpPath parameter of the [main] section of the main.cfg file of your setup. 

> 
> Similarly if I push file java object to the "value" key, will the GetResult response contain URL of the output file on the server?

Whatever method you choose (generated_file or writing data to the value field) the ZOO-Kernel will generate the reference URL only in case the user have requested for it (meaning that he have set the asReference attribute to true). It means also that even if you used the generated_file field and the user sent a request specifying that he want the output data embedded in the XML response, then it should work in a totally transparent way.

> Also who is responsible for making the output files (generated in some directory) on the server as a web accessible resource (via URL)?

As I tried to explain earlier, in case you have the value field defined and containing the data, then the ZOO-Kernel is responsible to generate a file on the file system (in the tmpPath directory) and generate the reference URL depending on the request. In case you use generated_file, then the ZOO-Kernel will be responsible to read the file content in case the request specify that the output should not be returned as a reference.

Hope it helps.

Best regards,


Gérald Fenoy
http://wiki.osgeo.org/wiki/User:Djay



More information about the Zoo-discuss mailing list