freme-project / Broker

FREME Broker
Apache License 2.0
2 stars 0 forks source link

Filter with outformat XML throws Exception via EInternalization #150

Closed ArneBinder closed 8 years ago

ArneBinder commented 8 years ago

When postprocessing filtering is used with XML as output format and a different input format like turtle, EInternalization throws BadRequestException: Can only convert to outformat "text/xml" when informat is also "text/xml" because of these lines. The (ignored) test testFilteringWithELinkXML in FilterControllerTest reproduces the bug.

jnehring commented 8 years ago

The problem came from within the internal API call to the toolbox endpoint which has informat=turtle and outformat=text/xml.

I added a configuration option that disables e-Internationalization for certain endpoints. Right now it disables all /toolbox endpoints. The unit test passes.

@ArneBinder please verify that the bug is fixed and close the issue.

fsasaki commented 8 years ago

I just tried the request from the tutorial http://api-dev.freme-project.eu/doc/knowledge-base/filtering.html changing the output to text/xml, and I get "exception":"eu.freme.broker.exception.InternalServerErrorException","message":"Conversion from \"text/xml\" to NIF failed" @ArneBinder , is this related to this issue?

fsasaki commented 8 years ago

Sorry for the noise, @ArneBinder , I saw the the issue was in my request.

ArneBinder commented 8 years ago

@fsasaki no problem. This is really strange: it works with outformat=xml, but "text/xml" produces this error:

`{
  "exception": "eu.freme.broker.exception.BadRequestException",
  "path": "/e-entity/freme-ner/documents",
  "message": "Can only convert to outformat \"text/xml\" when informat is also \"text/xml\"",
  "error": "Bad Request",
  "status": 400,
  "timestamp": 1453850870748
}

I'm not sure, if this happens because of einternalization or the filter-controller fails. I will check this asap. @jnehring do you have any ideas? @fsasaki Thanks for the hint!

ArneBinder commented 8 years ago

This issue could be related to https://github.com/freme-project/Broker/issues/154

jnehring commented 8 years ago

I fixed the problem. This API call works now, it did not work before my fix.

POST http://api-dev.freme-project.eu/current/e-terminology/tilde?informat=text&source-lang=en&target-lang=de&filter=terminology-terms-only&outformat=text/xml&input=Show me the source of the light

The problem came from EInternationalization because outformat=text/xml was set. There was an odd side effect so that it worked for outformat=xml. The PostProcessingFilter sets the Accept header to turtle and tries to delete the parameter outformat by setting outformat=null. There seems to be a bug in this code in class ModifiableParametersWrappedRequest so the parameter cannot be deleted. I fixed this code by overriding outformat=turtle in PostProcessingFilter.

@ArneBinder can you please examine this solution?