You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@olingo.apache.org by "Tobias Stolzenberger (JIRA)" <ji...@apache.org> on 2015/11/03 10:55:27 UTC

[jira] [Commented] (OLINGO-807) ODataJPATombstoneEntityListener uses delta token instead of delta link

    [ https://issues.apache.org/jira/browse/OLINGO-807?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14987002#comment-14987002 ] 

Tobias Stolzenberger commented on OLINGO-807:
---------------------------------------------

Hi Michael,

thanks for the API proposal. Let me suggest some improvements on the new method on ODataJPATombstoneEntityListener:

{code:title=ODataJPATombstoneEntityListener.java|borderStyle=solid}
/**
   * Implement this method to return the delta link.
   * If this method returns <code>null</code> than method {@link #generateDeltaToken(List, Query)} is used to generate the
   * delta information.
   * The result URL of this method is placed in the "href" field of the delta link:
   * <code><link rel="delta" href="<result of this method>"/></code>
   * @param deltas is list of delta JPA Entities
   * @param query is an instance of type {@link javax.persistence.Query} that was used for handling delta entities
   * @param entitySetUriInfo information about the related OData request
   * @return the delta link URL 
   */
  public URL getDeltaLink(GetEntitySetUriInfo entitySetUriInfo, List<Object> deltas, Query query) {
    return null;
  }
{code}

I think it is a good idea to add the GetEntitySetUriInfo to the parameter list. In addition you should add the same parameters from the "legacy" method.
I would not recommend that the application should to the XML or JSON encoding here as this part should be independent of the requested format. Returning a URL escaped String would be OK in my eyes. In my proposal I return a java.net.URL object which avoids confusion on this parameter. What do you think about that?
In addition you should also add some more words in the Javadoc how this new method and the old method works together. Maybe deprecating the old one is an option.

Regards,
Tobias

> ODataJPATombstoneEntityListener uses delta token instead of delta link
> ----------------------------------------------------------------------
>
>                 Key: OLINGO-807
>                 URL: https://issues.apache.org/jira/browse/OLINGO-807
>             Project: Olingo
>          Issue Type: Bug
>          Components: odata2-jpa
>    Affects Versions: V2 2.0.5
>            Reporter: Tobias Stolzenberger
>            Assignee: Michael Bolz
>
> I have a scenario which requires delta handling in combination with query options. The OData consumer for example uses filters to get data. For example:
> GET http://myhost/myService/MyEntity?$filter=name eq 'test'
> For performance reasons the server should return the data including a delta link. In this delta link I require the query options of the original request such as:
>  <link rel="delta" href="http://myhost/myService/MyEntity?$filter=name eq 'test'&amp;!deltatoken=20151009-112156372"/>
> If you use the Olingo core libraries (org.apache.olingo.odata2.api.ep.callback.TombstoneCallbackResult) you an return any URL here by implementing getDeltaLink()
> But when you use the JPA adapter (org.apache.olingo.odata2.jpa.processor.api.ODataJPATombstoneEntityListener) you can only return the delta token but not the delta link. As a consequence of this you can only return a delta link like this:
>  <link rel="delta" href="http://myhost/myService/MyEntity?!deltatoken=20151009-112156372"/>
> Via trial and error I found that you can implement method ODataJPATombstoneEntityListener#generateDeltaToken(List<Object>, Query) and return a delta token plus filter parameters. But for me this looks like a bug as the returned delta token should be URL escaped.
> My proposal is to add an additional method in class ODataJPATombstoneEntityListener:
>  public String generateDeltaLink(List<Object> deltas, Query query){ return null; }
> In its default implementation this method return null to keep it compatible with previous releases. The idea is that the JPA processor should first call the new callback method generateDeltaLink. If this returns a value != null than this value should be used as href of the delta link. Otherwise the existing logical applies.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)