From f7c18f7445e1f205553a93da39ccf4df76f62735 Mon Sep 17 00:00:00 2001 From: Christian Amend Date: Thu, 24 Mar 2016 14:50:08 +0100 Subject: [PATCH] [OLINGO-905] Add system query option access to $all --- .../olingo/server/api/uri/UriInfoAll.java | 46 ++++++++++++++++++- .../server/api/uri/UriInfoCrossjoin.java | 6 +++ .../core/uri/parser/TestFullResourcePath.java | 34 +++++++++++++- .../core/uri/testutil/TestUriValidator.java | 4 ++ 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java index b249b67e6..cc63abda5 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoAll.java @@ -18,10 +18,54 @@ */ package org.apache.olingo.server.api.uri; +import java.util.List; + +import org.apache.olingo.server.api.uri.queryoption.CountOption; +import org.apache.olingo.server.api.uri.queryoption.CustomQueryOption; +import org.apache.olingo.server.api.uri.queryoption.FormatOption; +import org.apache.olingo.server.api.uri.queryoption.SearchOption; +import org.apache.olingo.server.api.uri.queryoption.SkipOption; +import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption; +import org.apache.olingo.server.api.uri.queryoption.TopOption; + /** * Used for URI info kind {@link UriInfoKind#all} to describe URIs like * http://.../serviceroot/$all */ public interface UriInfoAll { - // No additional methods needed for now. + + /** + * @return List of custom query options used in the URI (without alias definitions) + */ + List getCustomQueryOptions(); + + /** + * @return Object containing information of the $format option + */ + FormatOption getFormatOption(); + + /** + * @return Object containing information of the $count option + */ + CountOption getCountOption(); + + /** + * @return Object containing information of the $search option + */ + SearchOption getSearchOption(); + + /** + * @return Object containing information of the $skip option + */ + SkipOption getSkipOption(); + + /** + * @return Object containing information of the $skiptoken option + */ + SkipTokenOption getSkipTokenOption(); + + /** + * @return Object containing information of the $top option + */ + TopOption getTopOption(); } diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java index 657c12048..8fdba84ed 100644 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java +++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoCrossjoin.java @@ -25,6 +25,7 @@ import org.apache.olingo.server.api.uri.queryoption.ExpandOption; import org.apache.olingo.server.api.uri.queryoption.FilterOption; import org.apache.olingo.server.api.uri.queryoption.FormatOption; import org.apache.olingo.server.api.uri.queryoption.OrderByOption; +import org.apache.olingo.server.api.uri.queryoption.SearchOption; import org.apache.olingo.server.api.uri.queryoption.SelectOption; import org.apache.olingo.server.api.uri.queryoption.SkipOption; import org.apache.olingo.server.api.uri.queryoption.SkipTokenOption; @@ -65,6 +66,11 @@ public interface UriInfoCrossjoin { * @return Object containing information of the $orderby option */ OrderByOption getOrderByOption(); + + /** + * @return Object containing information of the $search option + */ + SearchOption getSearchOption(); /** * @return Object containing information of the $select option diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java index e3c798d0d..2596f5ce3 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/parser/TestFullResourcePath.java @@ -18,6 +18,8 @@ */ package org.apache.olingo.server.core.uri.parser; +import static org.junit.Assert.assertNotNull; + import java.util.Arrays; import java.util.Collections; @@ -27,12 +29,13 @@ import org.apache.olingo.commons.api.edm.FullQualifiedName; import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.server.api.OData; import org.apache.olingo.server.api.edmx.EdmxReference; +import org.apache.olingo.server.api.uri.UriInfoAll; +import org.apache.olingo.server.api.uri.UriInfoCrossjoin; import org.apache.olingo.server.api.uri.UriInfoKind; import org.apache.olingo.server.api.uri.UriResourceKind; import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind; import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind; import org.apache.olingo.server.core.uri.parser.UriParserSemanticException.MessageKeys; -import org.apache.olingo.server.core.uri.parser.UriParserSyntaxException; import org.apache.olingo.server.core.uri.parser.search.SearchParserException; import org.apache.olingo.server.core.uri.testutil.FilterValidator; import org.apache.olingo.server.core.uri.testutil.TestUriValidator; @@ -57,6 +60,35 @@ public class TestFullResourcePath { private final TestUriValidator testUri = new TestUriValidator().setEdm(edm); private final FilterValidator testFilter = new FilterValidator().setEdm(edm); + @Test + public void allowedSystemQueryOptionsOnAll() throws Exception { + UriInfoAll uriInfoAll = testUri.run("$all", "$count=true&$format=json&$search=abc&$skip=5&$top=5&$skiptoken=abc") + .getUriInfoRoot().asUriInfoAll(); + assertNotNull(uriInfoAll.getCountOption()); + assertNotNull(uriInfoAll.getFormatOption()); + assertNotNull(uriInfoAll.getSearchOption()); + assertNotNull(uriInfoAll.getSkipOption()); + assertNotNull(uriInfoAll.getTopOption()); + assertNotNull(uriInfoAll.getSkipTokenOption()); + } + + @Test + public void allowedSystemQueryOptionsOnCrossjoin() throws Exception { + UriInfoCrossjoin uriInfoCrossjoin = + testUri.run("$crossjoin(ESAllPrim,ESTwoPrim)", "$count=true&$expand=ESAllPrim" + + "&$filter=ESAllPrim/PropertyInt16 eq 2&$format=json&$orderby=ESAllPrim/PropertyInt16" + + "&$search=abc&$skip=5&$top=5&$skiptoken=abc").getUriInfoRoot().asUriInfoCrossjoin(); + assertNotNull(uriInfoCrossjoin.getCountOption()); + assertNotNull(uriInfoCrossjoin.getExpandOption()); + assertNotNull(uriInfoCrossjoin.getFilterOption()); + assertNotNull(uriInfoCrossjoin.getFormatOption()); + assertNotNull(uriInfoCrossjoin.getOrderByOption()); + assertNotNull(uriInfoCrossjoin.getSearchOption()); + assertNotNull(uriInfoCrossjoin.getSkipOption()); + assertNotNull(uriInfoCrossjoin.getTopOption()); + assertNotNull(uriInfoCrossjoin.getSkipTokenOption()); + } + @Test public void trimQueryOptionsValue() throws Exception { // OLINGO-846 trim query option value diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java index fbce5c963..bee3401f0 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/testutil/TestUriValidator.java @@ -238,4 +238,8 @@ public class TestUriValidator implements TestValidator { assertEquals(fullName, uriInfo.getEntityTypeCast().getFullQualifiedName()); return this; } + + public UriInfo getUriInfoRoot() { + return uriInfo; + } }