You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2016/04/20 21:59:36 UTC

olingo-odata2 git commit: [OLINGO-929] Fix for deferred link in update

Repository: olingo-odata2
Updated Branches:
  refs/heads/OLINGO-929_FixForDeferredLink [created] f87b681cf


[OLINGO-929] Fix for deferred link in update


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/f87b681c
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/f87b681c
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/f87b681c

Branch: refs/heads/OLINGO-929_FixForDeferredLink
Commit: f87b681cf068f484fa6a6ec83327be422f0fe6c5
Parents: 0a00f19
Author: mibo <mi...@mirb.de>
Authored: Wed Apr 20 21:55:10 2016 +0200
Committer: mibo <mi...@mirb.de>
Committed: Wed Apr 20 21:55:10 2016 +0200

----------------------------------------------------------------------
 .../jpa/processor/core/ODataEntityParser.java   | 45 +++++++++++---------
 1 file changed, 26 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/f87b681c/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataEntityParser.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataEntityParser.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataEntityParser.java
index a6ec241..9977219 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataEntityParser.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/ODataEntityParser.java
@@ -115,9 +115,9 @@ public final class ODataEntityParser {
       final String serviceRoot = odataContext.getPathInfo().getServiceRoot().toString();
       final String path =
           uriString.startsWith(serviceRoot.toString()) ? uriString.substring(serviceRoot.length()) : uriString;
-      final PathSegment pathSegment = getPathSegment(path);
+      final List<PathSegment> pathSegment = getPathSegment(path);
       edm = getEdm();
-      uri = UriParser.parse(edm, Arrays.asList(pathSegment), Collections.<String, String> emptyMap());
+      uri = UriParser.parse(edm, pathSegment, Collections.<String, String> emptyMap());
     } catch (ODataException e) {
       throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
     }
@@ -128,8 +128,8 @@ public final class ODataEntityParser {
       throws ODataJPARuntimeException {
     List<PathSegment> pathSegments = new ArrayList<PathSegment>();
     for (String link : linkSegments) {
-      PathSegment pathSegment = getPathSegment(link);
-      pathSegments.add(pathSegment);
+      List<PathSegment> pathSegment = getPathSegment(link);
+      pathSegments.addAll(pathSegment);
     }
     UriInfo uriInfo = null;
     try {
@@ -143,11 +143,11 @@ public final class ODataEntityParser {
 
   public UriInfo parseBindingLink(final String link, final Map<String, String> options)
       throws ODataJPARuntimeException {
-    final PathSegment pathSegment = getPathSegment(link);
+    final List<PathSegment> pathSegment = getPathSegment(link);
     UriInfo uriInfo = null;
     try {
       edm = getEdm();
-      uriInfo = UriParser.parse(edm, Arrays.asList(pathSegment), options);
+      uriInfo = UriParser.parse(edm, pathSegment, options);
     } catch (ODataException e) {
       throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
     }
@@ -161,19 +161,26 @@ public final class ODataEntityParser {
     return edm;
   }
 
-  private PathSegment getPathSegment(final String path) {
-    final PathSegment pathSegment = new PathSegment() {
-
-      @Override
-      public String getPath() {
-        return path.replace(serviceRoot, "");
-      }
+  private List<PathSegment> getPathSegment(final String path) {
+    String trimmedPath = path.replace(serviceRoot, "");
+
+    final String[] splittedPath = trimmedPath.split("/");
+    final List<PathSegment> pathSegments = new ArrayList<PathSegment>();
+
+    for (final String pathSegmentString : splittedPath) {
+      final PathSegment pathSegment = new PathSegment() {
+        @Override
+        public String getPath() {
+          return pathSegmentString;
+        }
+        @Override
+        public Map<String, List<String>> getMatrixParameters() {
+          return null;
+        }
+      };
+      pathSegments.add(pathSegment);
+    }
 
-      @Override
-      public Map<String, List<String>> getMatrixParameters() {
-        return null;
-      }
-    };
-    return pathSegment;
+    return pathSegments;
   }
 }