diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java index edd60581c..f61c6eea0 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParseTreeVisitor.java @@ -662,9 +662,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor { // do a check for bound functions (which requires a parameter list) if (ctx.vlNVO.size() == 0) { - throw wrap(new UriParserSemanticException("Expected function parameters for '" + fullBindingTypeName.toString() - + "'", - UriParserSemanticException.MessageKeys.FUNCTION_PARAMETERS_EXPECTED, fullBindingTypeName.toString())); + throw wrap(new UriParserSemanticException("Unknown type for type cast " + fullFilterName.toString() + + " not found", UriParserSemanticException.MessageKeys.UNKNOWN_TYPE , fullFilterName.toString())); } context.contextReadingFunctionParameters = true; diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java index 75744c9ec..672d093f9 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/UriParserSemanticException.java @@ -48,6 +48,8 @@ public class UriParserSemanticException extends UriParserException { FUNCTION_PARAMETERS_EXPECTED, /** parameter: resource part */ UNKNOWN_PART, + /** parameter: type */ + UNKNOWN_TYPE, /** parameter: expression */ ONLY_FOR_TYPED_PARTS, /** parameter: entity type name */ diff --git a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties index de14eb04f..3484ab352 100644 --- a/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties +++ b/lib/server-core/src/main/resources/server-core-exceptions-i18n.properties @@ -50,6 +50,7 @@ UriParserSemanticException.FUNCTION_PARAMETERS_EXPECTED=Function parameters expe UriParserSemanticException.UNKNOWN_PART=The part '%1$s' is not defined. UriParserSemanticException.ONLY_FOR_TYPED_PARTS='%1$s' is only allowed for typed parts. UriParserSemanticException.UNKNOWN_ENTITY_TYPE=The entity type '%1$s' is not defined. +UriParserSemanticException.UNKNOWN_TYPE=The type of the type cast '%1$s' is not defined. UriParserSemanticException.ONLY_FOR_COLLECTIONS='%1$s' is only allowed for collections. UriParserSemanticException.ONLY_FOR_ENTITY_TYPES='%1$s' is only allowed for entity types. UriParserSemanticException.ONLY_FOR_STRUCTURAL_TYPES='%1$s' is only allowed for structural types. diff --git a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java index 5c06e2c91..3b2ff1454 100644 --- a/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java +++ b/lib/server-test/src/test/java/org/apache/olingo/server/core/uri/antlr/TestFullResourcePath.java @@ -5442,7 +5442,7 @@ public class TestFullResourcePath { .isExSemantic(UriParserSemanticException.MessageKeys.TYPE_FILTER_NOT_CHAINABLE); testUri.runEx("ESTwoKeyNav/olingo.odata.test1.BFCESTwoKeyNavRTESTwoKeyNav") - .isExSemantic(UriParserSemanticException.MessageKeys.FUNCTION_PARAMETERS_EXPECTED); + .isExSemantic(UriParserSemanticException.MessageKeys.UNKNOWN_TYPE); // $ref testUri.runEx("ESTwoKeyNav(PropertyInt16=1,PropertyString='2')/PropertyCompTwoPrim/$ref") @@ -5563,7 +5563,13 @@ public class TestFullResourcePath { testUri.runEx("AIRTESAllPrimParam/FICRTString()").isExSemantic(MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS); testUri.runEx("AIRTESAllPrimParam/AIRTString").isExSemantic(MessageKeys.RESOURCE_PART_ONLY_FOR_TYPED_PARTS); } - + + @Test + public void invalidTypeCast() { + testUri.runEx("ESAllPrim/namespace.Invalid").isExSemantic(MessageKeys.UNKNOWN_TYPE); + testUri.runEx("ESAllPrim(0)/namespace.Invalid").isExSemantic(MessageKeys.UNKNOWN_TYPE); + } + @Test public void navPropertySameNameAsEntitySet() throws Exception { testUri.run("ESNavProp(1)/ESNavProp(2)/ESNavProp(3)/ESNavProp")