You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Hank Bruning <ha...@jblade.com> on 2015/09/20 15:55:26 UTC

ODataError use with Actions

Is the class
org.apache.olingo.commons.api.ex.ODataError.java

the implemention of the Oasis spec
OData JSON Format Version 4.0 Plus Errata 02, Section 19. Error Response ?
Here is a link to section 19.
http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940655

I'm trying to create an Action that returns the Olingo ODataError class.
Should the processor for the Olingo Action be  ActionEntityProcess or
ActionComplexProcessor.

Am I even going about this the correct way? I can not seem to find and
example of Actions returning errors in the format of the Oasis spec Section
19. Any pointers or ideas would help.

Hank

RE: ODataError use with Actions

Posted by "Amend, Christian" <ch...@sap.com>.
Hi Hank,



yes and no J



If you would like to give back an error message to the client you just have to throw an ODataApplication Exception. This Exception will then get transformed into an ODataError. The Exception message will be the ODataError message, the ODataErorCode will be the error code etc.



If you want more control for the serialization you can always register your own ErrorProcessor. Also have a look at the org.apache.olingo.server.api.processor.DefaultProcessor to see how we handle and serialize these error messages.



Best Regards,

Christian



From: Hank Bruning [mailto:hank@jblade.com]
Sent: Dienstag, 22. September 2015 00:09
To: user@olingo.apache.org
Subject: Re: ODataError use with Actions



Christian,

No that is not my question.

I want to return an ODataError when there is a problem. In most cases the Action will return a ComplexType with two strings.

When I encounter an error inside the ActionEntityProcessor or ActionComplexProcessor

I want to create an ODataError and return it to the OData Client that initated the Action.



The ODataError that is returned to the client I want to contain specific data so I would like to call these methods

ODataError.setCode(final String code)

ODataError.setMessage(final String message)
 setDetails(final List<ODataErrorDetail> details)

before returning it to the client.

Am I going about this the correct way?

Hank





On Mon, Sep 21, 2015 at 4:33 AM, Amend, Christian <ch...@sap.com>> wrote:

Hi Hank,



do I understand that correctly that you would like to create an Action which is giving back an OData Error response as the default? This use case as such is not specified since you would have to define the action in the metadata and there you can`t define the ODataError as a return type.



You can implement it though. First of all we will dispatch to the Processor which is linked to the return type specified in the metadata. So if you call an Action which returns an entity we will dispatch to the ActionEntityProcessor. If you specify an action with no return value we will dispatch to the AvtionVoidProcessor. Inside the process… method you can then throw an ODataApplication Exception which will be automatically transformed into an ODataError and send back to the client.



Does this answer your question?



Best Regards,

Christian



From: Hank Bruning [mailto:hank@jblade.com<ma...@jblade.com>]
Sent: Sonntag, 20. September 2015 15:55
To: Olingo User Group
Subject: ODataError use with Actions





Is the class
org.apache.olingo.commons.api.ex.ODataError.java

the implemention of the Oasis spec
OData JSON Format Version 4.0 Plus Errata 02, Section 19. Error Response ?
Here is a link to section 19.
http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940655

I'm trying to create an Action that returns the Olingo ODataError class.

Should the processor for the Olingo Action be  ActionEntityProcess or ActionComplexProcessor.

Am I even going about this the correct way? I can not seem to find and example of Actions returning errors in the format of the Oasis spec Section 19. Any pointers or ideas would help.



Hank




Re: ODataError use with Actions

Posted by Hank Bruning <ha...@jblade.com>.
Christian,
No that is not my question.
I want to return an ODataError when there is a problem. In most cases the
Action will return a ComplexType with two strings.
When I encounter an error inside the ActionEntityProcessor or
ActionComplexProcessor
I want to create an ODataError and return it to the OData Client that
initated the Action.

The ODataError that is returned to the client I want to contain specific
data so I would like to call these methods
ODataError.setCode(final String code)
ODataError.setMessage(final String message)
 setDetails(final List<ODataErrorDetail> details)
before returning it to the client.

Am I going about this the correct way?
Hank


On Mon, Sep 21, 2015 at 4:33 AM, Amend, Christian <ch...@sap.com>
wrote:

> Hi Hank,
>
>
>
> do I understand that correctly that you would like to create an Action
> which is giving back an OData Error response as the default? This use case
> as such is not specified since you would have to define the action in the
> metadata and there you can`t define the ODataError as a return type.
>
>
>
> You can implement it though. First of all we will dispatch to the
> Processor which is linked to the return type specified in the metadata. So
> if you call an Action which returns an entity we will dispatch to the
> ActionEntityProcessor. If you specify an action with no return value we
> will dispatch to the AvtionVoidProcessor. Inside the process… method you
> can then throw an ODataApplication Exception which will be automatically
> transformed into an ODataError and send back to the client.
>
>
>
> Does this answer your question?
>
>
>
> Best Regards,
>
> Christian
>
>
>
> *From:* Hank Bruning [mailto:hank@jblade.com]
> *Sent:* Sonntag, 20. September 2015 15:55
> *To:* Olingo User Group
> *Subject:* ODataError use with Actions
>
>
>
>
>
> Is the class
> org.apache.olingo.commons.api.ex.ODataError.java
>
> the implemention of the Oasis spec
> OData JSON Format Version 4.0 Plus Errata 02, Section 19. Error Response ?
> Here is a link to section 19.
>
> http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940655
>
> I'm trying to create an Action that returns the Olingo ODataError class.
>
> Should the processor for the Olingo Action be  ActionEntityProcess or
> ActionComplexProcessor.
>
> Am I even going about this the correct way? I can not seem to find and
> example of Actions returning errors in the format of the Oasis spec Section
> 19. Any pointers or ideas would help.
>
>
>
> Hank
>

RE: ODataError use with Actions

Posted by "Amend, Christian" <ch...@sap.com>.
Hi Hank,

do I understand that correctly that you would like to create an Action which is giving back an OData Error response as the default? This use case as such is not specified since you would have to define the action in the metadata and there you can`t define the ODataError as a return type.

You can implement it though. First of all we will dispatch to the Processor which is linked to the return type specified in the metadata. So if you call an Action which returns an entity we will dispatch to the ActionEntityProcessor. If you specify an action with no return value we will dispatch to the AvtionVoidProcessor. Inside the process… method you can then throw an ODataApplication Exception which will be automatically transformed into an ODataError and send back to the client.

Does this answer your question?

Best Regards,
Christian

From: Hank Bruning [mailto:hank@jblade.com]
Sent: Sonntag, 20. September 2015 15:55
To: Olingo User Group
Subject: ODataError use with Actions


Is the class
org.apache.olingo.commons.api.ex.ODataError.java
the implemention of the Oasis spec
OData JSON Format Version 4.0 Plus Errata 02, Section 19. Error Response ?
Here is a link to section 19.
http://docs.oasis-open.org/odata/odata-json-format/v4.0/errata02/os/odata-json-format-v4.0-errata02-os-complete.html#_Toc403940655
I'm trying to create an Action that returns the Olingo ODataError class.
Should the processor for the Olingo Action be  ActionEntityProcess or ActionComplexProcessor.
Am I even going about this the correct way? I can not seem to find and example of Actions returning errors in the format of the Oasis spec Section 19. Any pointers or ideas would help.

Hank