From 8a10f47b8955f7c4b60b8f3bdcdc8fbf5240199d Mon Sep 17 00:00:00 2001 From: Jacek Milaczewski Date: Mon, 30 May 2016 09:46:38 +0200 Subject: [PATCH] [OLINGO-964] fix proposal for cast type not taken into account while expanding a collection Signed-off-by: Christian Amend --- .../apache/olingo/server/core/uri/parser/ExpandParser.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java index 1da143a1b..8a493fff6 100644 --- a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java +++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java @@ -136,13 +136,13 @@ public class ExpandParser { UriResourcePartTyped lastPart = (UriResourcePartTyped) resource.getLastResourcePart(); boolean hasSlash = false; + EdmStructuredType typeCastSuffix = null; if (tokenizer.next(TokenKind.SLASH)) { hasSlash = true; if (lastPart instanceof UriResourceNavigation) { UriResourceNavigationPropertyImpl navigationResource = (UriResourceNavigationPropertyImpl) lastPart; final EdmNavigationProperty navigationProperty = navigationResource.getProperty(); - final EdmStructuredType typeCastSuffix = ParserHelper.parseTypeCast(tokenizer, edm, - navigationProperty.getType()); + typeCastSuffix = ParserHelper.parseTypeCast(tokenizer, edm, navigationProperty.getType()); if (typeCastSuffix != null) { if (navigationProperty.isCollection()) { navigationResource.setCollectionTypeFilter(typeCastSuffix); @@ -154,7 +154,8 @@ public class ExpandParser { } } - final EdmStructuredType newReferencedType = (EdmStructuredType) lastPart.getType(); + final EdmStructuredType newReferencedType = typeCastSuffix != null ? typeCastSuffix + : (EdmStructuredType) lastPart.getType(); final boolean newReferencedIsCollection = lastPart.isCollection(); if (hasSlash || tokenizer.next(TokenKind.SLASH)) { if (tokenizer.next(TokenKind.REF)) {