blob: 5e210b18cfa1aa5acb8692b8758e1b842294a1fb [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Apache Olingo provides libraries which enable developers to implement OData producers and OData consumers. The available OData Java library implements OData version 2.0. In future on goal is to provide an OData 4.0 compliant library once the OData standard is published at OASIS. The focus within the community is currently on the Java technology but it is up to the community to discuss if other environments find interest.">
<meta name="author" content="">
<link rel="icon" href="/favicon.ico">
<title>Apache Olingo Library</title>
<!-- Bootstrap core CSS -->
<link href="/css/bootstrap.css" rel="stylesheet" type="text/css"><!-- Custom styles for this template -->
<link href="/css/navbar.css" rel="stylesheet" type="text/css"><!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<link href="/css/offcanvas.css" rel="stylesheet" type="text/css"><!-- Custom styles for this template -->
<link rel="stylesheet" href="/css/main.css">
<!--[if lt IE 9]><script src="/js/ie8-responsive-file-warning.js"></script><![endif]-->
<style>
.headerlink {
visibility: hidden;
}
dt:hover > .headerlink, p:hover > .headerlink, td:hover > .headerlink, h1:hover > .headerlink, h2:hover > .headerlink, h3:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, h6:hover > .headerlink {
visibility: visible
} </style>
<script src="/js/ie-emulation-modes-warning.js" type="text/javascript">
</script><!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="/js/ie10-viewport-bug-workaround.js" type="text/javascript">
</script><!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="/js/html5shiv.min.js"></script>
<script src="/js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<!-- Static navbar -->
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img class="navbar-brand" src="/img/OlingoOrangeTM.png" style="width:62px;" >
<a class="navbar-brand" href="/">Apache Olingo™</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="http://www.apache.org/foundation/">ASF Home</a></li>
<li><a href="http://projects.apache.org/">Projects</a></li>
<li><a href="http://people.apache.org/">People</a></li>
<li><a href="http://www.apache.org/foundation/getinvolved.html">Get Involved</a></li>
<li><a href="http://www.apache.org/dyn/closer.cgi">Download</a></li>
<li><a href="http://www.apache.org/security/">Security</a></li>
<li><a href="http://www.apache.org/foundation/sponsorship.html">Support Apache</a></li>
</ul>
</li>
<li><a href="http://www.apache.org/licenses/">License</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Download <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="/doc/odata2/download.html">Download OData 2.0 Java</a></li>
<li><a href="/doc/odata4/download.html">Download OData 4.0 Java</a></li>
<li><a href="/doc/javascript/download.html">Download OData 4.0 JavaScript</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="/doc/odata2/index.html">Documentation OData 2.0 Java</a></li>
<li><a href="/doc/odata4/index.html">Documentation OData 4.0 Java</a></li>
<li><a href="/doc/javascript/index.html">Documentation OData 4.0 JavaScript</a></li>
</ul>
</li>
<li><a href="/support.html">Support</a></li>
<li><a href="/contribute.html">Contribute</a></li>
</ul>
<a class="navbar-right" href="http://www.apache.org/foundation/" target="_blank">
<img class="navbar-right" height="50px" src="/img/asf_logo_url.svg" alt="Apache Software Foundation">
</a>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</div><!-- Main component for a primary marketing message or call to action -->
<h1 id="delta-responses">Delta Responses<a class="headerlink" href="#delta-responses" title="Permalink">&para;</a></h1>
<p>Delta responses is a feature on top of OData 2.0 for requesting changes. The feature is defined in OData 4.0 and this is a preliminary and lightweight implementation close to the OData 4.0 specification <a href="http://docs.oasis-open.org/odata/odata/v4.0/cos01/part1-protocol/odata-v4.0-cos01-part1-protocol.html#_Toc372793707">(see here)</a>.</p>
<p>Because of delta responses are not defined in OData 2.0 this feature is optional.</p>
<p>Features:</p>
<ul>
<li>Delta Links (for Atom and Json)</li>
<li>Tombstones <a href="http://tools.ietf.org/html/rfc6721">RFC6721</a> for deleted entries in Atom format</li>
<li>Deleted Entries in Json as a lightweight implementation of <a href="http://docs.oasis-open.org/odata/odata-json-format/v4.0/cos01/odata-json-format-v4.0-cos01.html#_Toc372793080">Delta Responses</a></li>
</ul>
<h3 id="use-case">Use Case<a class="headerlink" href="#use-case" title="Permalink">&para;</a></h3>
<p>A client requests a (paged) feed. A server can add a delta link on the last feed page. Using the delta link returns only changed data of the feed to the client. Changed data are feed entries with changed properties or deleted entries.</p>
<h3 id="implementation">Implementation<a class="headerlink" href="#implementation" title="Permalink">&para;</a></h3>
<p>A server has to implement the <code>TombstoneCallback</code> interface:</p>
<pre><code>public interface TombstoneCallback extends ODataCallback {
...
}
</code></pre>
<p>Basically the implementation of this interface has to carry information about deleted data and the delta link which is realized as custom query option:</p>
<pre><code>http://host:80/service/Rooms?!deltatoken=1234
</code></pre>
<p>Finally the following code has to go into a <code>ODataSingleProcessor</code> implementation:</p>
<pre><code>/**
* @see EntitySetProcessor
*/
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final String contentType) throws ODataException {
[...]
Map&lt;String, ODataCallback&gt; callbacks = new HashMap&lt;String, ODataCallback&gt;();
callbacks.put(TombstoneCallback.CALLBACK_KEY_TOMBSTONE, tombstoneCallback);
EntityProviderWriteProperties properties = EntityProviderWriteProperties.serviceRoot(new URI(BASE_URI)).callbacks(callbacks).build();
final ODataResponse response = new JsonEntityProvider().writeFeed(entitySet, roomsData, properties);
[...]
return response;
}
</code></pre>
<h5 id="json-response">Json Response<a class="headerlink" href="#json-response" title="Permalink">&para;</a></h5>
<p>This is an example for a Json response:</p>
<pre><code> [...]
{
"__metadata":{
"id":"http://host:80/service/Rooms('2')",
"uri":"http://host:80/service/Rooms('2')",
"type":"RefScenario.Room",
"etag":"W/\"2\""
},
"Id":"2",
"Name":null,
"Seats":66,
"Version":2,
"nr_Employees":{
"__deferred":{
"uri":"http://host:80/service/Rooms('2')/nr_Employees"
}
},
"nr_Building":{
"__deferred":{
"uri":"http://host:80/service/Rooms('2')/nr_Building"
}
}
},
{
"@odata.context":"$metadata#Rooms/$deletedEntity",
"id":"http://host:80/service/Rooms('3')"
},
{
"@odata.context":"$metadata#Rooms/$deletedEntity",
"id":"http://host:80/service/Rooms('4')"
},
{
"@odata.context":"$metadata#Rooms/$deletedEntity",
"id":"http://host:80/service/Rooms('5')"
},
],
"__delta":"http://host:80/service/Rooms?!deltatoken=1234"
}
}
</code></pre>
<h5 id="atom-response">Atom Response<a class="headerlink" href="#atom-response" title="Permalink">&para;</a></h5>
<p>This is an example of an Atom delta response (tombstones, RFC6721)</p>
<pre><code>&lt;feed ...&gt;
[..]
&lt;entry m:etag="W/&amp;quot;3&amp;quot;"&gt;
&lt;id&gt;http://host:80/service/Rooms('2')&lt;/id&gt;
&lt;title type="text"&gt;Rooms&lt;/title&gt;
&lt;updated&gt;2014-01-14T18:11:06.681+01:00&lt;/updated&gt;
&lt;category term="RefScenario.Room" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/&gt;
&lt;link href="Rooms('2')" rel="edit" title="Room"/&gt;
&lt;link href="Rooms('2')/nr_Employees" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nr_Employees" title="nr_Employees" type="application/atom+xml;type=feed"/&gt;
&lt;link href="Rooms('2')/nr_Building" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/nr_Building" title="nr_Building" type="application/atom+xml;type=entry"/&gt;
&lt;content type="application/xml"&gt;
&lt;m:properties&gt;
&lt;d:Id&gt;2&lt;/d:Id&gt;
&lt;d:Name&gt;Neu Schwanstein2&lt;/d:Name&gt;
&lt;d:Seats&gt;20&lt;/d:Seats&gt;
&lt;d:Version&gt;3&lt;/d:Version&gt;
&lt;/m:properties&gt;
&lt;/content&gt;
&lt;/entry&gt;
&lt;at:deleted-entry ref="http://host:80/service/Rooms('2')" when="2014-01-14T18:11:06.682+01:00"/&gt;
&lt;link rel="delta" href="http://host:80/service/Rooms?!deltatoken=1234"/&gt;
&lt;/feed&gt;
</code></pre>
<div align="center">
<p>Copyright © 2013-2022, The Apache Software Foundation<br>
Apache Olingo, Olingo, Apache, the Apache feather, and
the Apache Olingo project logo are trademarks of the Apache Software
Foundation.</p>
<small><a href="/doc/odata2/privacy.html">Privacy</a></small>
</div>
</div><!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery.js" type="text/javascript">
</script>
<script src="/js/bootstrap.js" type="text/javascript">
</script>
<script src="/js/offcanvas.js" type="text/javascript">
</script>
<link rel="stylesheet" href="/css/docco.css">
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.0.1/build/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</body>
</html>