You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/09/08 14:31:57 UTC
svn commit: r1701787 -
/olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext
Author: chrish
Date: Tue Sep 8 12:31:57 2015
New Revision: 1701787
URL: http://svn.apache.org/r1701787
Log:
CMS commit to olingo by chrish
Modified:
olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext
Modified: olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext
URL: http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext?rev=1701787&r1=1701786&r2=1701787&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext (original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/sqo_tcs/tutorial_sqo_tcs.mdtext Tue Sep 8 12:31:57 2015
@@ -252,11 +252,15 @@ Then we can do the actual job, which is
SkipOption skipOption = uriInfo.getSkipOption();
if (skipOption != null) {
int skipNumber = skipOption.getValue();
- if(skipNumber >= 0 && skipNumber <= entityList.size()){
- entityList = entityList.subList(skipNumber, entityList.size());
- }else{
- throw new ODataApplicationException("Invalid value for `$skip`",
- HttpStatusCode.BAD_REQUEST.getStatusCode(),Locale.ROOT);
+ if (skipNumber >= 0) {
+ if(skipNumber <= entityList.size()) {
+ entityList = entityList.subList(skipNumber, entityList.size());
+ } else {
+ // The client skipped all entities
+ entityList.clear();
+ }
+ } else {
+ throw new ODataApplicationException("Invalid value for $skip", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
}
@@ -280,13 +284,14 @@ Again we follow the 4 mentioned steps, t
:::java
TopOption topOption = uriInfo.getTopOption();
- if(topOption != null){
+ if (topOption != null) {
int topNumber = topOption.getValue();
- if(topNumber >= 0 && topNumber <= entityList.size()){
- entityList = entityList.subList(0, topNumber);
- }else{
- throw new ODataApplicationException("Invalid value for $top",
- HttpStatusCode.BAD_REQUEST.getStatusCode(),Locale.ROOT);
+ if (topNumber >= 0) {
+ if(topNumber <= entityList.size()) {
+ entityList = entityList.subList(0, topNumber);
+ } // else the client has requested more entities than available => return what we have
+ } else {
+ throw new ODataApplicationException("Invalid value for $top", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
}
@@ -323,23 +328,28 @@ So now we can finally have a look at the
SkipOption skipOption = uriInfo.getSkipOption();
if (skipOption != null) {
int skipNumber = skipOption.getValue();
- if(skipNumber >= 0 && skipNumber <= entityList.size()){
- entityList = entityList.subList(skipNumber, entityList.size());
- }else{
- throw new ODataApplicationException("Invalid value for $skip",
- HttpStatusCode.BAD_REQUEST.getStatusCode(),Locale.ROOT);
+ if (skipNumber >= 0) {
+ if(skipNumber <= entityList.size()) {
+ entityList = entityList.subList(skipNumber, entityList.size());
+ } else {
+ // The client skipped all entities
+ entityList.clear();
+ }
+ } else {
+ throw new ODataApplicationException("Invalid value for $skip", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
}
// handle $top
TopOption topOption = uriInfo.getTopOption();
- if(topOption != null){
+ if (topOption != null) {
int topNumber = topOption.getValue();
- if(topNumber >= 0 && topNumber <= entityList.size()){
- entityList = entityList.subList(0, topNumber);
- }else{
- throw new ODataApplicationException("Invalid value for $top",
- HttpStatusCode.BAD_REQUEST.getStatusCode(),Locale.ROOT);
+ if (topNumber >= 0) {
+ if(topNumber <= entityList.size()) {
+ entityList = entityList.subList(0, topNumber);
+ } // else the client has requested more entities than available => return what we have
+ } else {
+ throw new ODataApplicationException("Invalid value for $top", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
}
@@ -349,8 +359,7 @@ So now we can finally have a look at the
}
// 4th: create a serializer based on the requested format (json)
- ODataFormat format = ODataFormat.fromContentType(responseFormat);
- ODataSerializer serializer = odata.createSerializer(format);
+ ODataSerializer serializer = odata.createSerializer(responseFormat);
// and serialize the content: transform from the EntitySet object to InputStream
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
@@ -423,4 +432,4 @@ More system query options will be treate
* [Official OData Homepage](http://odata.org/)
* [OData documentation](http://www.odata.org/documentation/)
- * [Olingo Javadoc](/javadoc/odata4/index.html)
+ * [Olingo Javadoc](/javadoc/odata4/index.html)
\ No newline at end of file