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/01 14:54:47 UTC
olingo-odata4 git commit: [OLINGO-659] TecSvc: $levels system query
options lead now to a 501 not implemented status
Repository: olingo-odata4
Updated Branches:
refs/heads/master 78a9539e3 -> a3541721e
[OLINGO-659] TecSvc: $levels system query options lead now to a 501 not implemented status
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/a3541721
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/a3541721
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/a3541721
Branch: refs/heads/master
Commit: a3541721ef0dc52021c6abbb31ef9a3c4e501d27
Parents: 78a9539
Author: Christian Holzer <c....@sap.com>
Authored: Tue Sep 1 14:50:48 2015 +0200
Committer: Christian Holzer <c....@sap.com>
Committed: Tue Sep 1 14:54:08 2015 +0200
----------------------------------------------------------------------
.../ExpandWithSystemQueryOptionsITCase.java | 71 ++++++++++++++++++++
.../ExpandSystemQueryOptionHandler.java | 6 ++
2 files changed, 77 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a3541721/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
index 658bc08..7aa230d 100644
--- a/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/tecsvc/client/ExpandWithSystemQueryOptionsITCase.java
@@ -476,6 +476,77 @@ public class ExpandWithSystemQueryOptionsITCase extends AbstractBaseTestITCase {
assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
}
}
+
+ @Test
+ public void expandWithLevels() {
+ final ODataClient client = getClient();
+ final Map<QueryOption, Object> expandOptions = new HashMap<QueryOption, Object>();
+ expandOptions.put(QueryOption.LEVELS, 2);
+
+ // expand=*($levels=2)
+ URI uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+ .expandWithOptions("*", expandOptions)
+ .build();
+
+ try {
+ client.getRetrieveRequestFactory().getEntitySetRequest(uri);
+ } catch(ODataServerErrorException e) {
+ assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
+ }
+
+ // expand=NavPropertyETTwoKeyNavMany($levels=2)
+ expandOptions.clear();
+ expandOptions.put(QueryOption.LEVELS, 2);
+ uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+ .expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
+ .build();
+
+ try {
+ client.getRetrieveRequestFactory().getEntitySetRequest(uri);
+ } catch(ODataServerErrorException e) {
+ assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
+ }
+
+ // expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2))
+ expandOptions.clear();
+ expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "($levels=2)");
+ uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+ .expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
+ .build();
+
+ try {
+ client.getRetrieveRequestFactory().getEntitySetRequest(uri);
+ } catch(ODataServerErrorException e) {
+ assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
+ }
+
+ // expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2);$levels=3)
+ expandOptions.clear();
+ expandOptions.put(QueryOption.LEVELS, 2);
+ uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+ .expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
+ .build();
+
+ try {
+ client.getRetrieveRequestFactory().getEntitySetRequest(uri);
+ } catch(ODataServerErrorException e) {
+ assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
+ }
+
+ // expand=NavPropertyETTwoKeyNavMany($expand=NavPropertyETTwoKeyNavMany($levels=2))
+ expandOptions.clear();
+ expandOptions.put(QueryOption.EXPAND, NAV_PROPERTY_ET_TWO_KEY_NAV_MANY + "($levels=2)");
+ expandOptions.put(QueryOption.LEVELS, 3);
+ uri = client.newURIBuilder(SERVICE_URI).appendEntitySetSegment(ES_KEY_NAV)
+ .expandWithOptions(NAV_PROPERTY_ET_TWO_KEY_NAV_MANY, expandOptions)
+ .build();
+
+ try {
+ client.getRetrieveRequestFactory().getEntitySetRequest(uri);
+ } catch(ODataServerErrorException e) {
+ assertEquals("HTTP/1.1 501 Not Implemented", e.getMessage());
+ }
+ }
private ODataRetrieveResponse<ClientEntitySet> buildRequest(final String entitySet, final String navigationProperty,
final Map<QueryOption, Object> expandOptions) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/a3541721/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
----------------------------------------------------------------------
diff --git a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
index 21e60d4..e0faf41 100644
--- a/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
+++ b/lib/server-tecsvc/src/main/java/org/apache/olingo/server/tecsvc/processor/queryoptions/ExpandSystemQueryOptionHandler.java
@@ -75,9 +75,15 @@ public class ExpandSystemQueryOptionHandler {
private void applyExpandOptionToEntity(final Entity entity, final EdmBindingTarget edmBindingTarget,
final ExpandOption expandOption) throws ODataApplicationException {
+
final EdmEntityType entityType = edmBindingTarget.getEntityType();
for (ExpandItem item : expandOption.getExpandItems()) {
+ if(item.getLevelsOption() != null) {
+ throw new ODataApplicationException("$levels is not implemented",
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+ }
+
List<EdmNavigationProperty> navigationProperties = new ArrayList<EdmNavigationProperty>();
if(item.isStar()) {
List<EdmNavigationPropertyBinding> bindings = edmBindingTarget.getNavigationPropertyBindings();