Returning text file as Processing output

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Returning text file as Processing output

sapre73
Hi,
I have a problem to return a text file as output of Processing. I define the getOutputDataType in this way:

        public Class<?> getOutputDataType(String id) {
               
            if (id.equalsIgnoreCase("volumi")) {
                return FileDataBinding.class;
         }    
                return null;
        }

In the run method, I populate the result in this way:
 
                        File outFile = new File (path + "volumi_002.out");
                        IData result = new FileDataBinding(outFile);
                        resultMap.put("volumi", result);

The response document section is:

  <wps:ResponseForm>
    <wps:ResponseDocument storeExecuteResponse="true">
      <wps:Output asReference="true">
        <ows:Identifier>volumi</ows:Identifier>
      </wps:Output>                                                           
    </wps:ResponseDocument>

But when processing stops, wps generate the following exception:

17:10:15.599 [pool-1-thread-2] ERROR o.n.w.server.response.OutputDataItem - The
data passed from the algorithm to the generator is a file, but no shapefile
java.io.IOException: The data passed from the algorithm to the generator is a file, but no shapefile

Thanks in advance for any help you will gave me.

Sandro
Reply | Threaded
Open this post in threaded view
|

Re: Returning text file as Processing output

BenjaminPross
Hi Sandro,

Is there a reason why you use the FileDataBinding? This is not really
supported by the built-in parsers/generators.
I'd recommend to use the GenericFileDatabinding instead.

Cheers,

Benjamin

Am 01.08.2014 17:25, schrieb sapre73:

> Hi,
> I have a problem to return a text file as output of Processing. I define the
> getOutputDataType in this way:
>
> public Class<?> getOutputDataType(String id) {
>
>    if (id.equalsIgnoreCase("volumi")) {
>        return FileDataBinding.class;
>          }
> return null;
> }
>
> In the run method, I populate the result in this way:
>  
> File outFile = new File (path + "volumi_002.out");
> IData result = new FileDataBinding(outFile);
> resultMap.put("volumi", result);
>
> The response document section is:
>
>    <wps:ResponseForm>
>      <wps:ResponseDocument storeExecuteResponse="true">
>        <wps:Output asReference="true">
>          <ows:Identifier>volumi</ows:Identifier>
>        </wps:Output>
>      </wps:ResponseDocument>
>
> But when processing stops, wps generate the following exception:
>
> 17:10:15.599 [pool-1-thread-2] ERROR o.n.w.server.response.OutputDataItem -
> The
> data passed from the algorithm to the generator is a file, but no shapefile
> java.io.IOException: The data passed from the algorithm to the generator is
> a file, but no shapefile
>
> Thanks in advance for any help you will gave me.
>
> Sandro
>
>
>
> --
> View this message in context: http://geoprocessing.forum.52north.org/Returning-text-file-as-Processing-output-tp4025732.html
> Sent from the 52° North - Geoprocessing Community Forum mailing list archive at Nabble.com.
> _______________________________________________
> Geoprocessingservices mailing list
> [hidden email]
> http://list.52north.org/mailman/listinfo/geoprocessingservices
> http://geoprocessing.forum.52north.org


--
Benjamin Proß
Software Engineer
52°North Geoprocessing Community

52°North Initiative for Geospatial Open Source Software GmbH
Martin-Luther-King-Weg 24
Fon: +49-(0)-251–396371-42
Fax: +49-(0)-251–396371-11
[hidden email]
http://52north.org/

General Managers: Dr. Albert Remke, Dr. Andreas Wytzisk
Local Court Muenster HRB 10849

_______________________________________________
Geoprocessingservices mailing list
[hidden email]
http://list.52north.org/mailman/listinfo/geoprocessingservices
http://geoprocessing.forum.52north.org
Reply | Threaded
Open this post in threaded view
|

Re: Returning text file as Processing output

sapre73
Hi Benjamin,
I used GenericFileDatabinding and it works. The text file returned by the process has extension .out. I used text/plain as mime type, but when I open file, it is a binary file. Looking for documentation about mime types, I found someone that use application/octet-stream for out files. However, wher I try to execute the process, the following error has been generated:
java.lang.RuntimeException: org.n52.wps.server.ExceptionReport: Could not determine output format.

Where is the mistake?
Thanks.
Sandro
Reply | Threaded
Open this post in threaded view
|

Re: Returning text file as Processing output

BenjaminPross
Hi Sandro,

Sorry for the late reply, I was on vacation last week. Now the error you get is caused by the fact that the mime type is not supported by the GenericFileGenerator. You can fix that by adding the line

<Format mimetype="application/octet-stream" />

to the GenericFileGenerator in the wps_config.
But I don't think this will solve your problem. I ran a few tests with a similar process setup as you and I always get the text file as plain text (i.e. what I expected). So we need some more information. Could you attach the process description of your process and also the execute request?

Cheers,

Benjamin