You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/07/04 14:23:10 UTC

olingo-odata2 git commit: [OLINGO-677] The absolute path is replaced with relative path. The service root is stripped from the absolute path.

Repository: olingo-odata2
Updated Branches:
  refs/heads/master 06c5ec322 -> 9a7e91357


[OLINGO-677] The absolute path is replaced with relative path. The
service root is stripped from the absolute path.

Signed-off-by: Chandan V A <ch...@sap.com>

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

Branch: refs/heads/master
Commit: 9a7e913579d434f7a751305207252ccfc583bca3
Parents: 06c5ec3
Author: Chandan V A <ch...@sap.com>
Authored: Sat Jul 4 17:52:47 2015 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Sat Jul 4 17:52:47 2015 +0530

----------------------------------------------------------------------
 .../odata2/jpa/processor/core/ODataEntityParser.java  |  8 +++++++-
 .../jpa/processor/core/access/data/JPAEntityTest.java | 14 +++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/9a7e9135/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 78bd1bc..a6ec241 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
@@ -44,9 +44,15 @@ public final class ODataEntityParser {
 
   private ODataJPAContext context;
   private Edm edm;
+  private String serviceRoot = null;
 
   public ODataEntityParser(final ODataJPAContext context) {
     this.context = context;
+    try {
+      serviceRoot = context.getODataContext().getPathInfo().getServiceRoot().toString();
+    } catch (ODataException e) {
+      serviceRoot = "";
+    }
   }
 
   public final ODataEntry parseEntry(final EdmEntitySet entitySet,
@@ -160,7 +166,7 @@ public final class ODataEntityParser {
 
       @Override
       public String getPath() {
-        return path;
+        return path.replace(serviceRoot, "");
       }
 
       @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/9a7e9135/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
index 46d967e..e904564 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAEntityTest.java
@@ -23,6 +23,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.net.URISyntaxException;
+
 import org.apache.olingo.odata2.api.edm.EdmEntitySet;
 import org.apache.olingo.odata2.api.edm.EdmEntityType;
 import org.apache.olingo.odata2.api.edm.EdmException;
@@ -33,6 +35,7 @@ import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeExcep
 import org.apache.olingo.odata2.jpa.processor.core.common.ODataJPATestConstants;
 import org.apache.olingo.odata2.jpa.processor.core.mock.ODataContextMock;
 import org.apache.olingo.odata2.jpa.processor.core.mock.ODataJPAContextMock;
+import org.apache.olingo.odata2.jpa.processor.core.mock.PathInfoMock;
 import org.apache.olingo.odata2.jpa.processor.core.mock.data.EdmMockUtilV2;
 import org.apache.olingo.odata2.jpa.processor.core.mock.data.JPATypeMock;
 import org.apache.olingo.odata2.jpa.processor.core.mock.data.JPATypeMock.JPARelatedTypeMock;
@@ -235,7 +238,16 @@ public class JPAEntityTest {
   }
 
   private ODataJPAContext mockODataJPAContext() throws ODataException {
-    ODataContext context = new ODataContextMock().mock();
+    PathInfoMock pathInfoMock = new PathInfoMock();
+    try {
+      pathInfoMock.setServiceRootURI("http://olingo.apache.org/service.svc");
+    } catch (URISyntaxException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
+          + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    }
+    ODataContextMock contextMock = new ODataContextMock();
+    contextMock.setPathInfo(pathInfoMock.mock());
+    ODataContext context = contextMock.mock();
     ODataJPAContext jpaContext = ODataJPAContextMock.mockODataJPAContext(context);
     return jpaContext;
   }