http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/MethodKind.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/MethodKind.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/MethodKind.java deleted file mode 100644 index ef0d7cf..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/MethodKind.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.expression; - -/** - * Enumeration of supported methods - * For the semantic of these methods please see the ODATA specification for URL conventions - */ -public enum MethodKind { - CONTAINS("contains"), - STARTSWITH("startswith"), - ENDSWITH("endswith"), - LENGTH("length"), - INDEXOF("indexof"), - SUBSTRING("substring"), - TOLOWER("tolower"), - TOUPPER("toupper"), - TRIM("trim"), - CONCAT("concat"), - YEAR("year"), - MONTH("month"), - DAY("day"), - HOUR("hour"), - MINUTE("minute"), - SECOND("second"), - FRACTIONALSECONDS("fractionalseconds"), - TOTALSECONDS("totalseconds"), DATE("date"), TIME("time"), - TOTALOFFSETMINUTES("totaloffsetminutes"), - MINDATETIME("mindatetime"), - MAXDATETIME("maxdatetime"), - NOW("now"), - ROUND("round"), - FLOOR("floor"), - CEILING("ceiling"), - GEODISTANCE("geo.distance"), - GEOLENGTH("geo.length"), - GEOINTERSECTS("geo.intersects"), - CAST("cast"), - ISOF("isof"); - - private String syntax; - - /** - * Constructor for enumeration value - * @param Syntax used in the URI - */ - private MethodKind(final String syntax) { - this.syntax = syntax; - } - - @Override - /** - * @return URI syntax for that operator kind - */ - public String toString() { - return syntax; - } - - /** - * URI syntax to enumeration value - * @param method Method in the syntax used in the URI - * @return Method kind which represents the given syntax - */ - public static MethodKind get(final String method) { - for (MethodKind op : MethodKind.values()) { - - if (op.toString().equals(method)) { - return op; - } - } - return null; - } - -}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/TypeLiteral.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/TypeLiteral.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/TypeLiteral.java deleted file mode 100644 index c259eba..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/TypeLiteral.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.expression; - -import org.apache.olingo.commons.api.edm.EdmType; - -/** - * Represents a type literal expression in the expression tree - */ -public interface TypeLiteral extends Expression { - - /** - * @return Type defined by the type literal - */ - public EdmType getType(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/Unary.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/Unary.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/Unary.java deleted file mode 100644 index 7f37a0c..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/Unary.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.expression; - -/** - * Represents a unary expression node in the expression tree - * <br> - * A binary expression node is inserted in the expression tree for any valid - * ODATA unary operator in {@link UnaryOperatorKind} - */ -public interface Unary extends Expression { - - /** - * @return The used binary operator - * @see UnaryOperatorKind - */ - public Expression getOperand(); - - /** - * @return Expression sub tree to which the operator applies - */ - public UnaryOperatorKind getOperator(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/UnaryOperatorKind.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/UnaryOperatorKind.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/UnaryOperatorKind.java deleted file mode 100644 index 3e0907b..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/UnaryOperatorKind.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.expression; - -/** - * Enumeration of supported unary operators<br> - * For the semantic of these operators please see the ODATA specification for URL conventions - */ -public enum UnaryOperatorKind { - - /** - * Minus operator - */ - MINUS("-"), - - /** - * not operator - */ - NOT("not"); - - private String syntax; - - /** - * Constructor for enumeration value - * @param Syntax used in the URI - */ - private UnaryOperatorKind(final String syntax) { - this.syntax = syntax; - } - - /** - * @return URI syntax for that operator kind - */ - @Override - public String toString() { - return syntax; - } - - /** - * URI syntax to enumeration value - * @param operator Operator in the syntax used in the URI - * @return Operator kind which represents the given syntax - */ - public static UnaryOperatorKind get(final String operator) { - for (UnaryOperatorKind op : UnaryOperatorKind.values()) { - if (op.toString().equals(operator)) { - return op; - } - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java deleted file mode 100644 index 1588dcf..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/expression/VisitableExpression.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.expression; - -import org.apache.olingo.server.api.ODataApplicationException; - -/** - * Marks an expression node a visitable by an expression visitor - */ -public interface VisitableExpression { - - /** - * Method {@link #accept(ExpressionVisitor)} is called when traversing the expression tree. This method is invoked on - * each expression used as node in an expression tree. The implementations should - * behave as follows: - * <li>Call accept on all sub nodes and store the returned Objects which are of the generic type T - * <li>Call the appropriate method on the {@link ExpressionVisitor} instance and provide the stored return objects - * to that instance - * <li>Return the object which should be passed to the processing algorithm of the parent expression node - * <br> - * <br> - * @param visitor - * Visitor object (implementing {@link ExpressionVisitor}) whose methods are called during traversing a - * expression node of the expression tree. - * @return - * Object of type T which should be passed to the processing algorithm of the parent expression node - * @throws ExpressionVisitException - * Exception occurred in the OData library while traversing the tree - * @throws ODataApplicationException - * Exception thrown by the application who implemented the visitor - */ - <T> T accept(ExpressionVisitor<T> visitor) throws ExpressionVisitException, ODataApplicationException; - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinary.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinary.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinary.java deleted file mode 100644 index f24554d..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinary.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.search; - -public interface SearchBinary extends SearchExpression { - - SearchBinaryOperatorKind getOperator(); - - SearchExpression getLeftOperand(); - - SearchExpression getRightOperand(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinaryOperatorKind.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinaryOperatorKind.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinaryOperatorKind.java deleted file mode 100644 index 224d3c1..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchBinaryOperatorKind.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.search; - -public enum SearchBinaryOperatorKind { - // and/or - AND("and"), OR("or"); - - private String syntax; - - private SearchBinaryOperatorKind(final String syntax) { - this.syntax = syntax; - } - - @Override - public String toString() { - return syntax; - } - - public static SearchBinaryOperatorKind get(final String operator) { - for (SearchBinaryOperatorKind op : SearchBinaryOperatorKind.values()) { - if (op.toString().equals(operator)) { - return op; - } - } - return null; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchExpression.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchExpression.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchExpression.java deleted file mode 100644 index f471d27..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchExpression.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.search; - -public interface SearchExpression { - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchTerm.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchTerm.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchTerm.java deleted file mode 100644 index a3d69ad..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchTerm.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.search; - -public interface SearchTerm extends SearchExpression { - - String getSearchTerm(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnary.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnary.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnary.java deleted file mode 100644 index 2a424ce..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnary.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.search; - -public interface SearchUnary { - - SearchExpression getOperand(); - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnaryOperatorKind.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnaryOperatorKind.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnaryOperatorKind.java deleted file mode 100644 index 07d1302..0000000 --- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/search/SearchUnaryOperatorKind.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api.uri.queryoption.search; - -public enum SearchUnaryOperatorKind { - NOT("not"); - - private String syntax; - - private SearchUnaryOperatorKind(final String syntax) { - this.syntax = syntax; - } - - @Override - public String toString() { - return syntax; - } - - public static SearchUnaryOperatorKind get(final String operator) { - for (SearchUnaryOperatorKind op : SearchUnaryOperatorKind.values()) { - if (op.toString().equals(operator)) { - return op; - } - } - return null; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataRequestTest.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataRequestTest.java b/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataRequestTest.java deleted file mode 100644 index d2f9bef..0000000 --- a/lib/server-api/src/test/java/org/apache/olingo/server/api/ODataRequestTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api; - -import org.junit.Test; - -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; - -public class ODataRequestTest { - - @Test - public void testHeader() { - ODataRequest r = new ODataRequest(); - - r.addHeader("aa", Arrays.asList("cc")); - - assertEquals("cc", r.getHeaders("aa").get(0)); - assertEquals("cc", r.getHeaders("aA").get(0)); - assertEquals("cc", r.getHeaders("AA").get(0)); - - assertEquals("cc", r.getHeader("aa")); - assertEquals("cc", r.getHeader("aA")); - assertEquals("cc", r.getHeader("AA")); - - } - - @Test - public void testHeader2() { - ODataRequest r = new ODataRequest(); - r.addHeader("AA", Arrays.asList("dd")); - - assertEquals("dd", r.getHeaders("aa").get(0)); - assertEquals("dd", r.getHeaders("aA").get(0)); - assertEquals("dd", r.getHeaders("AA").get(0)); - } - - @Test - public void testMultiValueHeader() { - ODataRequest r = new ODataRequest(); - - r.addHeader("aa", Arrays.asList("a", "b")); - - assertEquals("a", r.getHeaders("aa").get(0)); - assertEquals("b", r.getHeaders("aA").get(1)); - - r.addHeader("Aa", Arrays.asList("c")); - - assertEquals("a", r.getHeaders("aa").get(0)); - assertEquals("b", r.getHeaders("aA").get(1)); - assertEquals("c", r.getHeaders("aA").get(2)); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/test/java/org/apache/olingo/server/api/TranslatedExceptionsTest.java ---------------------------------------------------------------------- diff --git a/lib/server-api/src/test/java/org/apache/olingo/server/api/TranslatedExceptionsTest.java b/lib/server-api/src/test/java/org/apache/olingo/server/api/TranslatedExceptionsTest.java deleted file mode 100644 index c22546b..0000000 --- a/lib/server-api/src/test/java/org/apache/olingo/server/api/TranslatedExceptionsTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.api; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - -import java.util.Locale; - -import org.apache.olingo.server.api.ODataTranslatedException.ODataErrorMessage; -import org.junit.Test; - -public class TranslatedExceptionsTest { - - private static final String DEV = "devMessage"; - - private static class TestException extends ODataTranslatedException { - private static final long serialVersionUID = -7199975861656921724L; - public static enum Keys implements MessageKey { - BASIC, ONEPARAM, TWOPARAM, NOMESSAGE, ONLY_ROOT, ONLY_GERMAN; - @Override - public String getKey() { - return name(); - } - } - protected TestException(final MessageKey messageKey, final String... parameters) { - super(DEV, messageKey, parameters); - } - @Override - protected String getBundleName() { - return "i18n"; - } - } - - @Test - public void basic() { - TestException exp = new TestException(TestException.Keys.BASIC); - assertEquals(DEV, exp.getMessage()); - assertEquals(DEV, exp.toString()); - assertEquals("Test Default", exp.getLocalizedMessage()); - assertEquals(TestException.Keys.BASIC, exp.getMessageKey()); - - checkTranslatedMessage(exp.getTranslatedMessage(null), "Test Default", Locale.ENGLISH); - checkTranslatedMessage(exp.getTranslatedMessage(Locale.ENGLISH), "Test Default", Locale.ENGLISH); - checkTranslatedMessage(exp.getTranslatedMessage(Locale.UK), "Test Default", Locale.ENGLISH); - checkTranslatedMessage(exp.getTranslatedMessage(Locale.GERMAN), "Test DE", Locale.GERMAN); - checkTranslatedMessage(exp.getTranslatedMessage(Locale.GERMANY), "Test DE", Locale.GERMAN); - } - - @Test - public void unusedParametersMustNotResultInAnException() { - TestException exp = new TestException(TestException.Keys.BASIC, "unusedParam1", "unusedParam2"); - assertEquals(DEV, exp.getMessage()); - checkTranslatedMessage(exp.getTranslatedMessage(null), "Test Default", Locale.ENGLISH); - } - - @Test - public void useOneParameter() { - TestException exp = new TestException(TestException.Keys.ONEPARAM, "usedParam1"); - assertEquals(DEV, exp.getMessage()); - checkTranslatedMessage(exp.getTranslatedMessage(null), "Param1: usedParam1", Locale.ENGLISH); - } - - @Test - public void useOneParameterExpectedButMultipleGiven() { - TestException exp = new TestException(TestException.Keys.ONEPARAM, "usedParam1", "unusedParam2"); - assertEquals(DEV, exp.getMessage()); - checkTranslatedMessage(exp.getTranslatedMessage(null), "Param1: usedParam1", Locale.ENGLISH); - } - - @Test - public void useTwoParameters() { - TestException exp = new TestException(TestException.Keys.TWOPARAM, "usedParam1", "usedParam2"); - assertEquals(DEV, exp.getMessage()); - checkTranslatedMessage(exp.getTranslatedMessage(null), "Param1: usedParam1 Param2: usedParam2", Locale.ENGLISH); - } - - @Test - public void parametersNotGivenAlthoughNeeded() { - TestException exp = new TestException(TestException.Keys.ONEPARAM); - assertEquals(DEV, exp.getMessage()); - - ODataErrorMessage translatedMessage = exp.getTranslatedMessage(null); - assertNotNull(translatedMessage); - assertThat(translatedMessage.getMessage(), containsString("Missing replacement for place holder in message")); - } - - @Test - public void noMessageKey() { - TestException exp = new TestException(null); - assertEquals(DEV, exp.getMessage()); - - ODataErrorMessage translatedMessage = exp.getTranslatedMessage(null); - assertNotNull(translatedMessage); - assertEquals(DEV, translatedMessage.getMessage()); - } - - @Test - public void noMessageForKey() { - TestException exp = new TestException(TestException.Keys.NOMESSAGE); - assertEquals(DEV, exp.getMessage()); - - ODataErrorMessage translatedMessage = exp.getTranslatedMessage(null); - assertNotNull(translatedMessage); - assertThat(translatedMessage.getMessage(), containsString("Missing message for key")); - } - - @Test - public void keyForRootBundleButNotPresentInDerivedBundle() { - TestException exp = new TestException(TestException.Keys.ONLY_ROOT); - assertEquals(DEV, exp.getMessage()); - - checkTranslatedMessage(exp.getTranslatedMessage(Locale.GERMAN), "Root message", Locale.GERMAN); - checkTranslatedMessage(exp.getTranslatedMessage(Locale.ROOT), "Root message", Locale.ENGLISH); - } - - @Test - public void defaultLocale() { - TestException exp = new TestException(TestException.Keys.ONLY_GERMAN); - assertEquals(DEV, exp.getMessage()); - - Locale.setDefault(Locale.GERMAN); - ODataErrorMessage translatedMessage = exp.getTranslatedMessage(null); - assertNotNull(translatedMessage); - assertThat(translatedMessage.getMessage(), containsString("Missing message for key")); - assertEquals(Locale.ENGLISH, translatedMessage.getLocale()); - - Locale.setDefault(Locale.ENGLISH); - translatedMessage = exp.getTranslatedMessage(null); - assertNotNull(translatedMessage); - assertThat(translatedMessage.getMessage(), containsString("Missing message for key")); - assertEquals(Locale.ENGLISH, translatedMessage.getLocale()); - } - - private void checkTranslatedMessage(final ODataErrorMessage translatedMessage, - final String expectedText, final Locale expectedLocale) { - assertNotNull(translatedMessage); - assertEquals(expectedText, translatedMessage.getMessage()); - assertEquals(expectedLocale, translatedMessage.getLocale()); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/test/resources/i18n.properties ---------------------------------------------------------------------- diff --git a/lib/server-api/src/test/resources/i18n.properties b/lib/server-api/src/test/resources/i18n.properties deleted file mode 100644 index 58c31b3..0000000 --- a/lib/server-api/src/test/resources/i18n.properties +++ /dev/null @@ -1,21 +0,0 @@ -#------------------------------------------------------------------------------- -# 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. -#------------------------------------------------------------------------------- -# Basic Apache Olingo exception messages -# -TestException.ONLY_ROOT=Root message \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/test/resources/i18n_de.properties ---------------------------------------------------------------------- diff --git a/lib/server-api/src/test/resources/i18n_de.properties b/lib/server-api/src/test/resources/i18n_de.properties deleted file mode 100644 index b919483..0000000 --- a/lib/server-api/src/test/resources/i18n_de.properties +++ /dev/null @@ -1,20 +0,0 @@ -#------------------------------------------------------------------------------- -# 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. -#------------------------------------------------------------------------------- -TestException.BASIC=Test DE -TestException.ONLY_GERMAN=Deutsche Nachricht \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-api/src/test/resources/i18n_en.properties ---------------------------------------------------------------------- diff --git a/lib/server-api/src/test/resources/i18n_en.properties b/lib/server-api/src/test/resources/i18n_en.properties deleted file mode 100644 index 84dd9d1..0000000 --- a/lib/server-api/src/test/resources/i18n_en.properties +++ /dev/null @@ -1,23 +0,0 @@ -#------------------------------------------------------------------------------- -# 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. -#------------------------------------------------------------------------------- -# Basic Apache Olingo exception messages -# -TestException.BASIC=Test Default -TestException.ONEPARAM=Param1: %1$s -TestException.TWOPARAM=Param1: %1$s Param2: %2$s \ No newline at end of file http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/pom.xml ---------------------------------------------------------------------- diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml deleted file mode 100644 index 92538ce..0000000 --- a/lib/server-core/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - 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. - ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <artifactId>odata-server-core</artifactId> - <packaging>jar</packaging> - <name>${project.artifactId}</name> - - <parent> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-lib</artifactId> - <version>4.0.0-beta-02</version> - <relativePath>..</relativePath> - </parent> - - <dependencies> - <dependency> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-server-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.olingo</groupId> - <artifactId>odata-commons-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.antlr</groupId> - <artifactId>antlr4-runtime</artifactId> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.5</version> - <scope>provided</scope> - </dependency> - - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>target/generated-sources/antlr4</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.antlr</groupId> - <artifactId>antlr4-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>antlr4</goal> - </goals> - </execution> - </executions> - <configuration> - <!--<arguments><argument>-atn</argument></arguments> --> - <listener>true</listener> - <visitor>true</visitor> - <!--maven antlr plugin has trouble with grammer import if the grammerfiles - are not directly inside src/main/antlr4, hence we have to set the libDirectory --> - <libDirectory>src/main/antlr4/org/apache/olingo/server/core/uri/antlr</libDirectory> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 deleted file mode 100644 index 13ed27a..0000000 --- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriLexer.g4 +++ /dev/null @@ -1,409 +0,0 @@ -/******************************************************************************* - * 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. - ******************************************************************************/ -lexer grammar UriLexer; - -//;============================================================================== -// Mode "DEFAULT_MODE": Processes everything before the first '?' char. -// On '?' the next mode "MODE_QUERY" is used. -// The percent encoding rules are defined in RFC3986; ABNF rule "path-rootless" applies. -//;============================================================================== -QM : '?' -> pushMode(MODE_QUERY); //first query parameter -AMP : '&' -> pushMode(MODE_QUERY); //more query parameters -STRING : '\'' -> more, pushMode(MODE_STRING); //reads up to next single ' -QUOTATION_MARK : ('\u0022' | '%22') -> more, pushMode(MODE_JSON_STRING); //reads up to next unescaped " -SEARCH_INLINE : '$search' -> pushMode(MODE_SYSTEM_QUERY_SEARCH); // -FRAGMENT : '#' -> pushMode(MODE_FRAGMENT); // - -GEOGRAPHY : G E O G R A P H Y SQUOTE -> pushMode(MODE_ODATA_GEO); //TODO make case insensitive -GEOMETRY : G E O M E T R Y SQUOTE -> pushMode(MODE_ODATA_GEO); - -//Letters for case insensitivity -fragment A : 'A'|'a'; -fragment B : 'B'|'b'; -fragment D : 'D'|'d'; -fragment E : 'E'|'e'; -fragment F : 'F'|'f'; -fragment G : 'G'|'g'; -fragment H : 'H'|'h'; -fragment I : 'I'|'i'; -fragment L : 'L'|'l'; -fragment M : 'M'|'m'; -fragment N : 'N'|'n'; -fragment O : 'O'|'o'; -fragment P : 'P'|'p'; -fragment R : 'R'|'r'; -fragment S : 'S'|'s'; -fragment T : 'T'|'t'; -fragment U : 'U'|'u'; -fragment Y : 'Y'|'y'; -fragment Z : 'Z'|'z'; - -//special chars -OPEN : '(' | '%28'; -CLOSE : ')' | '%29'; -COMMA : ',' | '%2C'; -SLASH : '/'; -POINT : '.'; -AT : '@'; -EQ : '=' ; -STAR : '*'; -SEMI : ';' | '%3b'; -COLON : ':'; - -EQ_sq : '=' -> type(EQ); -AMP_sq : '&' -> type(AMP), popMode; -fragment WS : ( ' ' | '%09' | '%20' | '%09' ); -WSP : WS+; - -//JSON support -BEGIN_OBJECT : WS* ( '{' / '%7B' ) WS*; -END_OBJECT : WS* ( '}' / '%7D' ) WS*; - -BEGIN_ARRAY : WS* ( '[' / '%5B' ) WS*; -END_ARRAY : WS* ( ']' / '%5D' ) WS*; - - -//alpha stuff -fragment ALPHA : 'a'..'z' | 'A'..'Z'; -fragment ALPHA_A_TO_F : 'a'..'f' | 'A'..'F'; -fragment DIGIT : '0'..'9'; -fragment DIGITS : DIGIT+; -fragment HEXDIG : DIGIT | ALPHA_A_TO_F; -fragment ODI_LEADINGCHARACTER : ALPHA | '_'; //TODO; add Unicode characters from the categories L or Nl -fragment ODI_CHARACTER : ALPHA | '_' | DIGIT; //TODO; add Unicode characters from the categories L, Nl, Nd, Mn, Mc, Pc, or Cf - -//helper for date/time values -fragment ONE_TO_NINE : '1'..'9'; -fragment ZERO_TO_FIFTYNINE : ('0'..'5') DIGIT; -fragment FRACTIONALSECONDS : DIGIT+; -fragment SECOND : ZERO_TO_FIFTYNINE; -fragment MINUTE : ZERO_TO_FIFTYNINE; -fragment HOUR : ('0' | '1') DIGIT | '2' ( '0'..'3'); -fragment DAY : '0' '1'..'9' | ('1'|'2') DIGIT | '3' ('0'|'1'); -fragment MONTH : '0' ONE_TO_NINE | '1' ( '0' | '1' | '2' ); -fragment YEAR : ('-')? ( '0' DIGIT DIGIT DIGIT | ONE_TO_NINE DIGIT DIGIT DIGIT ); - -//tags starting with $ -BATCH : '$batch'; -ENTITY : '$entity'; -METADATA : '$metadata'; - -ALL : '$all'; -CROSSJOIN : '$crossjoin'; - -VALUE : '$value'; -REF : '$ref'; -COUNT : '$count'; - -//inlined query parameters ( e.g. $skip) -TOP_I : '$top' -> type(TOP); -SKIP_I : '$skip' -> type(SKIP); -FILTER_I : '$filter' -> type(FILTER); -ORDERBY_I: '$orderby' -> type(ORDERBY); -SELECT_I : '$select' -> type(SELECT); -EXPAND_I : '$expand' -> type(EXPAND); -LEVELS_I : '$levels' -> type(LEVELS); -MAX: 'max'; - -ROOT : '$root/'; - -//rest -NULLVALUE : 'null'; - -TRUE : 'true'; -FALSE : 'false'; -BOOLEAN : T R U E | F A L S E; -PLUS : '+'; - -MINUS : '-'; -SIGN : PLUS | '%2B' | '-'; -INT : SIGN? DIGITS; -DECIMAL : INT '.' DIGITS (('e'|'E') SIGN? DIGITS)?; -NANINFINITY : 'NaN' | '-INF' | 'INF'; -//primary types -BINARY : B I N A R Y SQUOTE (HEXDIG HEXDIG)* SQUOTE; -DATE : YEAR '-' MONTH '-' DAY; -DATETIMEOFFSET : YEAR '-' MONTH '-' DAY T HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )? ( Z | SIGN HOUR ':' MINUTE ); -fragment DUSECONDFRAG : DIGITS ('.' DIGITS)? 'S'; -fragment DUTIMEFRAG : 'T' ( - ( DIGITS 'H' (DIGITS 'M')? DUSECONDFRAG?) - | (DIGITS 'M' DUSECONDFRAG?) - | DUSECONDFRAG - ); -fragment DUDAYTIMEFRAG : DIGITS 'D' DUTIMEFRAG? | DUTIMEFRAG; -DURATION : D U R A T I O N SQUOTE '-'? 'P' DUDAYTIMEFRAG SQUOTE; -TIMEOFDAY : HOUR ':' MINUTE ( ':' SECOND ( '.' FRACTIONALSECONDS )? )?; -fragment GUIDVALUE : HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG'-' - HEXDIG HEXDIG HEXDIG HEXDIG '-' - HEXDIG HEXDIG HEXDIG HEXDIG '-' - HEXDIG HEXDIG HEXDIG HEXDIG '-' - HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG HEXDIG; -GUID : GUIDVALUE; - -//expression tokens -ASC : 'asc'; -DESC : 'desc'; -MUL : 'mul'; -DIV : 'div'; -MOD : 'mod'; -HAS : 'has'; - -ADD : 'add'; -SUB : 'sub'; - -ANY_LAMDA : 'any'; -ALL_LAMDA : 'all'; - -GT : 'gt'; -GE : 'ge'; -LT : 'lt'; -LE : 'le'; -ISOF : 'isof'; - -EQ_ALPHA : 'eq'; -NE : 'ne'; - -AND : 'and'; -OR : 'or'; - - -NOT : 'not'; - - -IT : '$it'; -ITSLASH : '$it/'; -LEVELS : '$levels'; - -CONTAINS_WORD : 'contains('; -STARTSWITH_WORD : 'startswith('; -ENDSWITH_WORD : 'endswith('; -LENGTH_WORD : 'length('; -INDEXOF_WORD : 'indexof('; -SUBSTRING_WORD : 'substring('; -TOLOWER_WORD : 'tolower('; -TOUPPER_WORD : 'toupper('; -TRIM_WORD : 'trim('; -CONCAT_WORD : 'concat('; -YEAR_WORD : 'year('; -MONTH_WORD : 'month('; -DAY_WORD : 'day('; -HOUR_WORD : 'hour('; -MINUTE_WORD : 'minute('; -SECOND_WORD : 'second('; -FRACTIONALSECONDS_WORD : 'fractionalseconds('; -TOTALSECONDS_WORD : 'totalseconds('; -DATE_WORD : 'date('; -TIME_WORD : 'time('; -TOTALOFFSETMINUTES_WORD : 'totaloffsetminutes('; - -MINDATETIME_WORD : 'mindatetime('; -MAXDATETIME_WORD : 'maxdatetime('; -NOW_WORD : 'now('; - -ROUND_WORD : 'round('; -FLOOR_WORD : 'floor('; -CEILING_WORD : 'ceiling('; - -GEO_DISTANCE_WORD : 'geo.distance('; -GEO_LENGTH_WORD : 'geo.length('; -GEO_INTERSECTS_WORD : 'geo.intersects('; -ISOF_WORD : 'isof('; -CAST_WORD : 'cast('; - -COLLECTION_REF : 'Collection($ref)'; -COLLECTION_ENTITY_TYPE : 'Collection(Edm.EntityType)'; -COLLECTION_COMPLEX_TYPE : 'Collection(Edm.ComplexType)'; -COLLECTION : 'Collection(' -> type(COLLECTION); - -//used in fragment only -DELETED_ENTITY : '$deletedEntity'; -LINK : '$link'; -DELETED_LINK : '$deletedLink'; -DELTA : '$delta'; - -ODATAIDENTIFIER : ODI_LEADINGCHARACTER (ODI_CHARACTER)*; - -//handle characters that failed to match any other token -ERROR_CHARACTER : .; - -//;============================================================================== -// Mode "QUERY": Processes everything between the first '?' and the '#' char. -// On '?' the next mode "FRAGMENT" is used. -// The percent encoding rules are defined in RFC3986; ABNF rule "query" applies. -mode MODE_QUERY; -//;============================================================================== - -FRAGMENT_q : '#' -> type(FRAGMENT); -FILTER : '$filter' -> pushMode(DEFAULT_MODE); -ORDERBY : '$orderby' -> pushMode(DEFAULT_MODE); -EXPAND : '$expand' -> pushMode(DEFAULT_MODE); -SELECT : '$select' -> pushMode(DEFAULT_MODE); -SKIP : '$skip' -> pushMode(DEFAULT_MODE); -SKIPTOKEN : '$skiptoken' -> pushMode(MODE_SYSTEM_QUERY_REST); -TOP : '$top' -> pushMode(DEFAULT_MODE); -LEVELS_q : '$levels' -> type(LEVELS), pushMode(DEFAULT_MODE); -FORMAT : '$format' -> pushMode(MODE_SYSTEM_QUERY_PCHAR); -COUNT_q : '$count' -> type(COUNT), pushMode(DEFAULT_MODE); -REF_q : '$ref' -> type(REF); -VALUE_q : '$value' -> type(VALUE); -ID : '$id' -> pushMode(MODE_SYSTEM_QUERY_REST); -SEARCH : '$search' -> pushMode(MODE_SYSTEM_QUERY_SEARCH); - -EQ_q : '=' -> type(EQ); -AMP_q : '&' -> type(AMP); - -AT_Q : '@' -> pushMode(DEFAULT_MODE); - -CUSTOMNAME : ~[&=@$] ~[&=]* -> pushMode(MODE_SYSTEM_QUERY_REST); - -//handle characters that failed to match any other token -ERROR_CHARACTER_q : .; - -//;============================================================================== -mode MODE_SYSTEM_QUERY_PCHAR; -//;============================================================================== - -AMP_sqp : '&' -> type(AMP), popMode; - -fragment ALPHA_sqp : 'a'..'z'|'A'..'Z'; -fragment A_TO_F_sqp : 'a'..'f'|'A'..'F'; -fragment DIGIT_sqp : '0'..'9'; -fragment HEXDIG_sqp : DIGIT_sqp | A_TO_F_sqp; -fragment PCT_ENCODED_sqp : '%' HEXDIG_sqp HEXDIG_sqp; -fragment SUB_DELIMS_sqp : '$' | /*'&' |*/ '\'' | EQ_sqp | OTHER_DELIMS_sqp; -fragment OTHER_DELIMS_sqp : '!' | '(' | ')' | '*' | '+' | ',' | ';'; -fragment UNRESERVED_sqp : ALPHA_sqp | DIGIT_sqp | '-' |'.' | '_' | '~'; -fragment PCHAR : UNRESERVED_sqp | PCT_ENCODED_sqp | SUB_DELIMS_sqp | ':' | '@'; -fragment PCHARSTART : UNRESERVED_sqp | PCT_ENCODED_sqp | '$' | /*'&' |*/ '\'' | OTHER_DELIMS_sqp | ':' | '@'; - -ATOM : [Aa][Tt][Oo][Mm]; -JSON : [Jj][Ss][Oo][Nn]; -XML : [Xx][Mm][Ll]; - -PCHARS : PCHARSTART PCHAR*; - -SLASH_sqp : '/' -> type(SLASH); -EQ_sqp : '=' -> type(EQ); -FRAGMENT_sqp : '#' -> type(FRAGMENT), pushMode(MODE_FRAGMENT); - -//handle characters that failed to match any other token -ERROR_CHARACTER_sqp : .; - -//;============================================================================== -mode MODE_FRAGMENT; -// Read the remaining characters of a URI queryparameter up to an & or # -// character. -//;============================================================================== - -REST_F : ~('\r'|'\n')* -> type(REST), popMode; - -//;============================================================================== -mode MODE_SYSTEM_QUERY_REST; -// Read the remaining characters of a URI queryparameter up to an & or # -// character. -//;============================================================================== - -AMP_sqr : '&' -> type(AMP), popMode; -FRAGMENT_sqr : '#' -> type(FRAGMENT), popMode; - -EQ_sqr : '=' -> type(EQ); -REST : ~[&#=] ~[&#]*; - -//;============================================================================== -mode MODE_SYSTEM_QUERY_SEARCH; -//;============================================================================== - -NOT_sqc : 'NOT' -> type(NOT); -AND_sqc : 'AND' -> type(AND); -OR_sqc : 'OR' -> type(OR); -EQ_sqc : '=' -> type(EQ); - -fragment WS_sqc : ( ' ' | '\u0009' | '%20' | '%09' ); -WSP_sqc : WS_sqc+ -> type(WSP); - -QUOTATION_MARK_sqc : '\u0022' | '%22'; - -SEARCHWORD : ('a'..'z'|'A'..'Z')+; -SEARCHPHRASE : QUOTATION_MARK_sqc ~["]* QUOTATION_MARK_sqc -> popMode; - -//;============================================================================== -mode MODE_STRING; -// Reads the remaining characters up to an ' character. -// Any "'" characters inside a string are expressed as double "''". -//;============================================================================== - -STRING_s : ('\'\'' | ~[\u0027] )* '\'' -> type(STRING), popMode; - -//;============================================================================== -mode MODE_JSON_STRING; -// Reads the remaining characters up to an " character. -// Any """ characters inside a string are escaped with "\". -//;============================================================================== - -STRING_IN_JSON : ('\\"' | ~[\u0022] )* ('"' | '%22') -> popMode; - -//;============================================================================== -mode MODE_ODATA_GEO; -//;============================================================================== - -fragment C_ : 'c'|'C'; -fragment D_ : 'd'|'D'; -fragment E_ : 'e'|'E'; -fragment G_ : 'g'|'G'; -fragment H_ : 'h'|'H'; -fragment I_ : 'i'|'I'; -fragment L_ : 'l'|'L'; -fragment M_ : 'm'|'M'; -fragment N_ : 'n'|'N'; -fragment O_ : 'o'|'O'; -fragment P_ : 'p'|'P'; -fragment R_ : 'r'|'R'; -fragment S_ : 's'|'S'; -fragment T_ : 't'|'T'; -fragment U_ : 'u'|'U'; -fragment Y_ : 'y'|'Y'; - -fragment SP_g : ' ';//'\u0020'; // a simple space -fragment WS_g : ( ' ' | '%20' | '%09' ); - -OPEN_g : ('(' | '%28') -> type(OPEN); -CLOSE_g : (')' | '%29') -> type(CLOSE); -COMMA_g : (',' | '%2C') -> type(COMMA); -WSP_g : WS_g+ -> type(WSP); -POINT_g : '.' -> type(POINT); -AT_g : '@' -> type(AT); -SEMI_g : (';' | '%3B') -> type(SEMI); -EQ_g : '=' -> type(EQ); - -fragment DIGIT_g : '0'..'9'; -fragment DIGITS_g : DIGIT_g+; -SIGN_g : ('+' | '%2B' |'-') -> type(SIGN); -INT_g : SIGN_g? DIGITS_g -> type(INT); -DECIMAL_g : 'SS' INT_g '.' DIGITS_g (('e'|'E') SIGN_g? DIGITS_g)? -> type(DECIMAL); -COLLECTION_g : C_ O_ L_ L_ E_ C_ T_ I_ O_ N_ -> type(COLLECTION); -LINESTRING : L_ I_ N_ E_ S_ T_ R_ I_ N_ G_ ; -MULTILINESTRING : M_ U_ L_ T_ I_ L_ I_ N_ E_ S_ T_ R_ I_ N_ G_; -MULTIPOINT : M_ U_ L_ T_ I_ P_ O_ I_ N_ T_ ; -MULTIPOLYGON : M_ U_ L_ T_ I_ P_ O_ L_ Y_ G_ O_ N_; -GEO_POINT : P_ O_ I_ N_ T_; -POLYGON : P_ O_ L_ Y_ G_ O_ N_ ; - -SRID : S_ R_ I_ D_; - -SQUOTE : '\'' -> popMode; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4 ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4 b/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4 deleted file mode 100644 index 7efc14c..0000000 --- a/lib/server-core/src/main/antlr4/org/apache/olingo/server/core/uri/antlr/UriParser.g4 +++ /dev/null @@ -1,439 +0,0 @@ -/******************************************************************************* - * 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. - ******************************************************************************/ - -grammar UriParser; - -//------------------------------------------------------------------------------ -// This grammar refers to the "odata-abnf-construction-rules.txt" Revision 517. -// URL: https://tools.oasis-open.org/version-control/browse/wsvn/odata/trunk/spec/ABNF/odata-abnf-construction-rules.txt?rev=517 - -// While contructing this grammar we tried to keep it close to the ABNF. -// However this is not really possible in order to support -// - percent decoding -// - operator precedence -// - having a context free grammar ( without java snipplets to add context) -// - generating the parser in different target languages -// Currently not supported are -// - $search -// - geometry data -// - json data in url -//------------------------------------------------------------------------------ - - -options { - language = Java; - tokenVocab = UriLexer; -} - -//;------------------------------------------------------------------------------ -//; 0. URI -//;------------------------------------------------------------------------------ - -batchEOF : BATCH EOF; - -entityEOF : vNS=namespace vODI=odataIdentifier; - -metadataEOF : METADATA EOF; - -//;------------------------------------------------------------------------------ -//; 1. Resource Path -//;------------------------------------------------------------------------------ - -//resourcePathEOF : vlPS=pathSegments EOF; - -crossjoinEOF : CROSSJOIN OPEN WSP? vlODI+=odataIdentifier WSP? ( COMMA WSP? vlODI+=odataIdentifier WSP?)* CLOSE EOF; - -allEOF : ALL; - -pathSegmentEOF : (pathSegment | constSegment) EOF; - -pathSegments : vlPS+=pathSegment (SLASH vlPS+=pathSegment)* (SLASH vCS=constSegment)?; - -pathSegment : vNS=namespace? vODI=odataIdentifier vlNVO+=nameValueOptList*; - -nameValueOptList : OPEN (vVO=commonExpr | vNVL=nameValueList)? CLOSE; -nameValueList : WSP* vlNVP+=nameValuePair WSP* ( COMMA WSP* vlNVP+=nameValuePair WSP*)* ; -nameValuePair : vODI=odataIdentifier EQ (AT vALI=odataIdentifier | vCOM=commonExpr /*TODO | val2=enumX*/); - -constSegment : (vV=value | vC=count | vR=ref | vAll=allExpr | vAny=anyExpr); - -count : COUNT; -ref : REF; -value : VALUE; - -//;------------------------------------------------------------------------------ -//; 2. Query Options -//;------------------------------------------------------------------------------ - -queryOptions : vlQO+=queryOption ( AMP vlQO+=queryOption )*;//TODO can this be removed - -queryOption : systemQueryOption; - -systemQueryOption : expand - | filter - | inlinecount - | orderBy - | search - | select - | skip - | skiptoken - | top - ; - -skiptoken : SKIPTOKEN EQ REST; -expand : EXPAND EQ expandItems; - -expandItemsEOF : expandItems EOF; -expandItems : vlEI+=expandItem ( COMMA vlEI+=expandItem )*; - - -expandItem : vS=STAR ( SLASH vR=ref | OPEN LEVELS EQ ( vL=INT | vM=MAX) CLOSE )? - | vEP=expandPath vEPE=expandPathExtension?; - - -expandPath : vlPS+=pathSegment (SLASH vlPS+=pathSegment)*; - -expandPathExtension : OPEN vlEO+=expandOption ( SEMI vlEO+=expandOption )* CLOSE - | SLASH vR=ref ( OPEN vlEOR+=expandRefOption ( SEMI vlEOR+=expandRefOption )* CLOSE )? - | SLASH vC=count ( OPEN vlEOC+=expandCountOption ( SEMI vlEOC+=expandCountOption )* CLOSE )? - ; - -expandCountOption : filter - | search - ; - -expandRefOption : expandCountOption - | orderBy - | skip - | top - | inlinecount - ; - -expandOption : expandRefOption - | select - | expand - | levels; - -levels : LEVELS EQ ( INT | MAX ); - -filter : FILTER EQ commonExpr; - -filterExpressionEOF : commonExpr EOF; - -orderBy : ORDERBY EQ orderList; - -orderByEOF : orderList EOF; - -orderList : vlOI+=orderByItem ( WSP* COMMA WSP* vlOI+=orderByItem )*; - -orderByItem : vC=commonExpr ( WSP ( vA=ASC | vD=DESC ) )?; - -skip : SKIP EQ INT; -top : TOP EQ INT; -//format : FORMAT EQ ( ATOM | JSON | XML | PCHARS SLASH PCHARS); - -inlinecount : COUNT EQ booleanNonCase; - -search : SEARCH searchSpecialToken; -searchInline : SEARCH_INLINE searchSpecialToken; - -searchSpecialToken : EQ WSP? searchExpr; - -searchExpr : (NOT WSP) searchExpr - | searchExpr searchExpr - | searchExpr WSP searchExpr - | searchExpr ( WSP AND WSP) searchExpr - | searchExpr ( WSP OR WSP) searchExpr - | searchPhrase - | searchWord - ; - -searchPhrase : SEARCHPHRASE; -searchWord : SEARCHWORD; - -select : SELECT EQ vlSI+=selectItem ( COMMA vlSI+=selectItem )*; -selectEOF : vlSI+=selectItem ( COMMA vlSI+=selectItem )*; - -selectItem : vlSS+=selectSegment ( SLASH vlSS+=selectSegment ) *; -selectSegment : vNS=namespace? ( vODI=odataIdentifier | vS=STAR ); - -aliasAndValue : vODI=ODATAIDENTIFIER EQ vV=parameterValue; - -parameterValue : commonExpr //TODO json not supported arrayOrObject - ; - -//;------------------------------------------------------------------------------ -//; 3. Context URL Fragments -//;------------------------------------------------------------------------------ - -contextFragment : REST; // the context fragment is only required on the client side - -//;------------------------------------------------------------------------------ -//; 4. Expressions -//;------------------------------------------------------------------------------ - -commonExpr : OPEN commonExpr CLOSE #altPharenthesis - | vE1=commonExpr (WSP HAS WSP) vE2=commonExpr #altHas - | methodCallExpr #altMethod - | ( unary WSP? ) commonExpr #altUnary - | anyExpr #altAny - | allExpr #altAll - | memberExpr #altMember - | vE1=commonExpr (WSP vO=MUL WSP | WSP vO=DIV WSP | WSP vO=MOD WSP ) vE2=commonExpr #altMult - | vE1=commonExpr (WSP vO=ADD WSP | WSP vO=SUB WSP) vE2=commonExpr #altAdd - | vE1=commonExpr (WSP vO=GT WSP | WSP vO=GE WSP | WSP vO=LT WSP - | WSP vO=LE WSP ) vE2=commonExpr #altComparism - | vE1=commonExpr (WSP vO=EQ_ALPHA WSP | WSP vO=NE WSP) vE2=commonExpr #altEquality - | vE1=commonExpr (WSP AND WSP) vE2=commonExpr #altAnd - | vE1=commonExpr (WSP OR WSP) vE2=commonExpr #altOr - | rootExpr #altRoot // $... - | AT odataIdentifier #altAlias // @... - | primitiveLiteral #altLiteral // ... - ; - -unary : (MINUS| NOT) ; - -rootExpr : ROOT vPs=pathSegments; - -memberExpr : vIt=IT ( SLASH (vANY=anyExpr | vALL=allExpr))? - | vIts=ITSLASH? vPs=pathSegments ( SLASH (vANY=anyExpr | vALL=allExpr))?; - -anyExpr : ANY_LAMDA OPEN WSP? ( vLV=odataIdentifier WSP? COLON WSP? vLE=commonExpr WSP? )? CLOSE; -allExpr : ALL_LAMDA OPEN WSP? vLV=odataIdentifier WSP? COLON WSP? vLE=commonExpr WSP? CLOSE; - -methodCallExpr : indexOfMethodCallExpr - | toLowerMethodCallExpr - | toUpperMethodCallExpr - | trimMethodCallExpr - | substringMethodCallExpr - | concatMethodCallExpr - | lengthMethodCallExpr - | yearMethodCallExpr - | monthMethodCallExpr - | dayMethodCallExpr - | hourMethodCallExpr - | minuteMethodCallExpr - | secondMethodCallExpr - | fractionalsecondsMethodCallExpr - | totalsecondsMethodCallExpr - | dateMethodCallExpr - | timeMethodCallExpr - | roundMethodCallExpr - | floorMethodCallExpr - | ceilingMethodCallExpr - | geoDistanceMethodCallExpr - | geoLengthMethodCallExpr - | totalOffsetMinutesMethodCallExpr - | minDateTimeMethodCallExpr - | maxDateTimeMethodCallExpr - | nowMethodCallExpr - //from boolean - | isofExpr - | castExpr - | endsWithMethodCallExpr - | startsWithMethodCallExpr - | containsMethodCallExpr - | geoIntersectsMethodCallExpr - ; - - -containsMethodCallExpr : CONTAINS_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE; -startsWithMethodCallExpr : STARTSWITH_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE; -endsWithMethodCallExpr : ENDSWITH_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE; -lengthMethodCallExpr : LENGTH_WORD WSP? vE1=commonExpr WSP? CLOSE; -indexOfMethodCallExpr : INDEXOF_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE; -substringMethodCallExpr : SUBSTRING_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? ( COMMA WSP? vE3=commonExpr WSP? )? CLOSE; -toLowerMethodCallExpr : TOLOWER_WORD WSP? vE1=commonExpr WSP? CLOSE; -toUpperMethodCallExpr : TOUPPER_WORD WSP? vE1=commonExpr WSP? CLOSE; -trimMethodCallExpr : TRIM_WORD WSP? vE1=commonExpr WSP? CLOSE; -concatMethodCallExpr : CONCAT_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE; - -yearMethodCallExpr : YEAR_WORD WSP? vE1=commonExpr WSP? CLOSE; -monthMethodCallExpr : MONTH_WORD WSP? vE1=commonExpr WSP? CLOSE; -dayMethodCallExpr : DAY_WORD WSP? vE1=commonExpr WSP? CLOSE; -hourMethodCallExpr : HOUR_WORD WSP? vE1=commonExpr WSP? CLOSE; -minuteMethodCallExpr : MINUTE_WORD WSP? vE1=commonExpr WSP? CLOSE; -secondMethodCallExpr : SECOND_WORD WSP? vE1=commonExpr WSP? CLOSE; -fractionalsecondsMethodCallExpr : FRACTIONALSECONDS_WORD WSP? vE1=commonExpr WSP? CLOSE; -totalsecondsMethodCallExpr : TOTALSECONDS_WORD WSP? vE1=commonExpr WSP? CLOSE; -dateMethodCallExpr : DATE_WORD WSP? vE1=commonExpr WSP? CLOSE; -timeMethodCallExpr : TIME_WORD WSP? vE1=commonExpr WSP? CLOSE; -totalOffsetMinutesMethodCallExpr : TOTALOFFSETMINUTES_WORD WSP? vE1=commonExpr WSP? CLOSE; - -minDateTimeMethodCallExpr : MINDATETIME_WORD WSP? CLOSE; -maxDateTimeMethodCallExpr : MAXDATETIME_WORD WSP? CLOSE; -nowMethodCallExpr : NOW_WORD WSP? CLOSE; - -roundMethodCallExpr : ROUND_WORD WSP? vE1=commonExpr WSP? CLOSE; -floorMethodCallExpr : FLOOR_WORD WSP? vE1=commonExpr WSP? CLOSE; -ceilingMethodCallExpr : CEILING_WORD WSP? vE1=commonExpr WSP? CLOSE; - -geoDistanceMethodCallExpr : GEO_DISTANCE_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE; -geoLengthMethodCallExpr : GEO_LENGTH_WORD WSP? vE1=commonExpr WSP? CLOSE; -geoIntersectsMethodCallExpr : GEO_INTERSECTS_WORD WSP? vE1=commonExpr WSP? COMMA WSP? vE2=commonExpr WSP? CLOSE; - -isofExpr : ISOF_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE; -castExpr : CAST_WORD WSP? ( vE1=commonExpr WSP? COMMA WSP? )? vNS=namespace vODI=odataIdentifier WSP? CLOSE; - -//;------------------------------------------------------------------------------ -//; 5. JSON format for function parameters -//;------------------------------------------------------------------------------ -//; Note: the query part of a URI needs to be partially percent-decoded before -//; applying these rules, see comment at the top of this file -//;------------------------------------------------------------------------------ - -arrayOrObject : json_array - | json_object; - -json_array : BEGIN_ARRAY json_value ( WSP? COMMA WSP? json_value)* END_ARRAY; - -json_value : jsonPrimitiv - | rootExpr - | json_object - | json_array; - -json_object : BEGIN_OBJECT - STRING_IN_JSON - WSP? COLON WSP? - json_value - END_OBJECT; - - -//; JSON syntax: adapted to URI restrictions from [RFC4627] -jsonPrimitiv : STRING_IN_JSON - | number_in_json - | TRUE - | FALSE - | 'null' - ; - -number_in_json : INT | DECIMAL; - -//;------------------------------------------------------------------------------ -//; 6. Names and identifiers -//;------------------------------------------------------------------------------ - -qualifiedtypename : namespace odataIdentifier - | 'collection' OPEN ( namespace odataIdentifier ) CLOSE - ; - -namespace : (odataIdentifier POINT)+; - -odataIdentifier : ODATAIDENTIFIER; - -//;------------------------------------------------------------------------------ -//; 7. Literal Data Values -//;------------------------------------------------------------------------------ - - -primitiveLiteral : nullrule - | booleanNonCase - | DECIMAL //includes double and single literals - | naninfinity - | INT //includes int16/int32 and int64 literals - | BINARY - | DATE - | DATETIMEOFFSET - | DURATION - | GUID - | string - | TIMEOFDAY - | enumLit - | geographyCollection - | geographyLineString - | geographyMultilineString - | geographyMultipoint - | geographyMultipolygon - | geographyPoint - | geographyPolygon - | geometryCollection - | geometryLineString - | geometryMultilineString - | geometryMultipoint - | geometryMultipolygon - | geometryPoint - | geometryPolygon - ; - -naninfinity : NANINFINITY; - -nullrule : NULLVALUE; -booleanNonCase : BOOLEAN | TRUE | FALSE; -string : STRING; - -enumLit : vNS=namespace vODI=odataIdentifier vValues=STRING; -enumValues : vlODI+=odataIdentifier ( COMMA vlODI+=odataIdentifier )*; - -geographyCollection : GEOGRAPHY fullCollectionLiteral SQUOTE; -fullCollectionLiteral : sridLiteral collectionLiteral; - -collectionLiteral : (COLLECTION ) OPEN geoLiteral ( COMMA geoLiteral )* CLOSE; - -geoLiteral : collectionLiteral - | lineStringLiteral - | multipointLiteral - | multilineStringLiteral - | multipolygonLiteral - | pointLiteral - | polygonLiteral; - -geographyLineString : GEOGRAPHY fullLineStringLiteral SQUOTE; -fullLineStringLiteral : sridLiteral lineStringLiteral; -lineStringLiteral : LINESTRING lineStringData; -lineStringData : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE; - -geographyMultilineString : GEOGRAPHY fullMultilineStringLiteral SQUOTE; -fullMultilineStringLiteral : sridLiteral multilineStringLiteral; -multilineStringLiteral : MULTILINESTRING OPEN ( lineStringData ( COMMA lineStringData )* )? CLOSE; - -geographyMultipoint : GEOGRAPHY fullMultipointLiteral SQUOTE; -fullMultipointLiteral : sridLiteral multipointLiteral; -multipointLiteral : MULTIPOINT OPEN ( pointData ( COMMA pointData )* )? CLOSE ; - -geographyMultipolygon : GEOGRAPHY fullmultipolygonLiteral SQUOTE; -fullmultipolygonLiteral : sridLiteral multipolygonLiteral; -multipolygonLiteral : MULTIPOLYGON OPEN ( polygonData ( COMMA polygonData )* )? CLOSE; - -geographyPoint : GEOGRAPHY fullpointLiteral SQUOTE; -fullpointLiteral : sridLiteral pointLiteral; - -pointLiteral : GEO_POINT pointData; -pointData : OPEN positionLiteral CLOSE; - -positionLiteral : (DECIMAL | INT ) WSP (DECIMAL | INT ); //; longitude, then latitude - - -geographyPolygon : GEOGRAPHY fullPolygonLiteral SQUOTE; -fullPolygonLiteral : sridLiteral polygonLiteral; -polygonLiteral : POLYGON polygonData; -polygonData : OPEN ringLiteral ( COMMA ringLiteral )* CLOSE; -ringLiteral : OPEN positionLiteral ( COMMA positionLiteral )* CLOSE; - - -geometryCollection : GEOMETRY fullCollectionLiteral SQUOTE; -geometryLineString : GEOMETRY fullLineStringLiteral SQUOTE; -geometryMultilineString : GEOMETRY fullMultilineStringLiteral SQUOTE; -geometryMultipoint : GEOMETRY fullMultipointLiteral SQUOTE; -geometryMultipolygon : GEOMETRY fullmultipolygonLiteral SQUOTE; -geometryPoint : GEOMETRY fullpointLiteral SQUOTE; -geometryPolygon : GEOMETRY fullPolygonLiteral SQUOTE; - -sridLiteral : SRID EQ INT SEMI; - - http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f7a7b484/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java ---------------------------------------------------------------------- diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java deleted file mode 100644 index f0e3d2d..0000000 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ContentNegotiator.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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. - */ -package org.apache.olingo.server.core; - -import java.util.Arrays; -import java.util.List; - -import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion; -import org.apache.olingo.commons.api.format.AcceptType; -import org.apache.olingo.commons.api.format.ContentType; -import org.apache.olingo.commons.api.format.ODataFormat; -import org.apache.olingo.commons.api.http.HttpHeader; -import org.apache.olingo.server.api.ODataRequest; -import org.apache.olingo.server.api.serializer.CustomContentTypeSupport; -import org.apache.olingo.server.api.serializer.RepresentationType; -import org.apache.olingo.server.api.uri.queryoption.FormatOption; - -public class ContentNegotiator { - - private ContentNegotiator() {} - - private static List<ContentType> getDefaultSupportedContentTypes(final RepresentationType type) { - switch (type) { - case METADATA: - return Arrays.asList(ContentType.APPLICATION_XML); - case MEDIA: - case BINARY: - return Arrays.asList(ContentType.APPLICATION_OCTET_STREAM); - case VALUE: - case COUNT: - return Arrays.asList(ContentType.TEXT_PLAIN); - case BATCH: - return Arrays.asList(ContentType.MULTIPART_MIXED); - default: - return Arrays.asList( - ODataFormat.JSON.getContentType(ODataServiceVersion.V40), - ODataFormat.JSON_NO_METADATA.getContentType(ODataServiceVersion.V40)); - } - } - - private static List<ContentType> getSupportedContentTypes( - final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) - throws ContentNegotiatorException { - final List<ContentType> defaultSupportedContentTypes = getDefaultSupportedContentTypes(representationType); - final List<ContentType> result = customContentTypeSupport == null ? defaultSupportedContentTypes : - customContentTypeSupport.modifySupportedContentTypes(defaultSupportedContentTypes, representationType); - if (result == null || result.isEmpty()) { - throw new ContentNegotiatorException("No content type has been specified as supported.", - ContentNegotiatorException.MessageKeys.NO_CONTENT_TYPE_SUPPORTED); - } else { - return result; - } - } - - public static ContentType doContentNegotiation(final FormatOption formatOption, final ODataRequest request, - final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) - throws ContentNegotiatorException { - final List<ContentType> supportedContentTypes = - getSupportedContentTypes(customContentTypeSupport, representationType); - final String acceptHeaderValue = request.getHeader(HttpHeader.ACCEPT); - ContentType result = null; - - if (formatOption != null && formatOption.getFormat() != null) { - final String formatString = formatOption.getFormat().trim(); - final ODataFormat format = - ODataFormat.JSON.name().equalsIgnoreCase(formatString) ? ODataFormat.JSON : - ODataFormat.XML.name().equalsIgnoreCase(formatString) ? ODataFormat.XML : - ODataFormat.ATOM.name().equalsIgnoreCase(formatString) ? ODataFormat.ATOM : null; - try { - result = getAcceptedType( - AcceptType.fromContentType(format == null ? - ContentType.create(formatOption.getFormat()) : format.getContentType(ODataServiceVersion.V40)), - supportedContentTypes); - } catch (final IllegalArgumentException e) {} - if (result == null) { - throw new ContentNegotiatorException("Unsupported $format = " + formatString, - ContentNegotiatorException.MessageKeys.UNSUPPORTED_FORMAT_OPTION, formatString); - } - } else if (acceptHeaderValue != null) { - final List<AcceptType> acceptedContentTypes = AcceptType.create(acceptHeaderValue); - try { - result = getAcceptedType(acceptedContentTypes, supportedContentTypes); - } catch (final IllegalArgumentException e) { - throw new ContentNegotiatorException("charset in accept header not supported: " + acceptHeaderValue, e, - ContentNegotiatorException.MessageKeys.WRONG_CHARSET_IN_HEADER, HttpHeader.ACCEPT, acceptHeaderValue); - } - if (result == null) { - throw new ContentNegotiatorException( - "unsupported accept content type: " + acceptedContentTypes + " != " + supportedContentTypes, - ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPES, acceptedContentTypes.toString()); - } - } else { - final ContentType requestedContentType = getDefaultSupportedContentTypes(representationType).get(0); - result = getAcceptedType(AcceptType.fromContentType(requestedContentType), supportedContentTypes); - if (result == null) { - throw new ContentNegotiatorException( - "unsupported accept content type: " + requestedContentType + " != " + supportedContentTypes, - ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, - requestedContentType.toContentTypeString()); - } - } - return result; - } - - private static ContentType getAcceptedType(final List<AcceptType> acceptedContentTypes, - final List<ContentType> supportedContentTypes) { - for (final AcceptType acceptedType : acceptedContentTypes) { - for (final ContentType supportedContentType : supportedContentTypes) { - ContentType contentType = supportedContentType; - if (acceptedType.getParameters().containsKey("charset")) { - final String value = acceptedType.getParameters().get("charset"); - if ("utf8".equalsIgnoreCase(value) || "utf-8".equalsIgnoreCase(value)) { - contentType = ContentType.create(contentType, ContentType.PARAMETER_CHARSET_UTF8); - } else { - throw new IllegalArgumentException("charset not supported: " + acceptedType); - } - } - if (acceptedType.matches(contentType)) { - return contentType; - } - } - } - return null; - } - - public static void checkSupport(final ContentType contentType, - final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType) - throws ContentNegotiatorException { - for (final ContentType supportedContentType : - getSupportedContentTypes(customContentTypeSupport, representationType)) { - if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) { - return; - } - } - throw new ContentNegotiatorException("unsupported content type: " + contentType, - ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, contentType.toContentTypeString()); - } - - public static boolean isSupported(final ContentType contentType, - final CustomContentTypeSupport customContentTypeSupport, - final RepresentationType representationType) throws ContentNegotiatorException { - - for (final ContentType supportedContentType : - getSupportedContentTypes(customContentTypeSupport, representationType)) { - if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) { - return true; - } - } - return false; - } -}
