olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject olingo-odata2 git commit: [OLINGO-732] Changed relative to absolute media_src url
Date Thu, 23 Jul 2015 06:55:13 GMT
Repository: olingo-odata2
Updated Branches:
  refs/heads/master e0e6a773b -> d6fe9bf6e


[OLINGO-732] Changed relative to absolute media_src url


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

Branch: refs/heads/master
Commit: d6fe9bf6eaa6fc006a6e147cf3ca99a1403898a0
Parents: e0e6a77
Author: Michael Bolz <michael.bolz@sap.com>
Authored: Thu Jul 23 08:50:10 2015 +0200
Committer: Michael Bolz <michael.bolz@sap.com>
Committed: Thu Jul 23 08:50:10 2015 +0200

----------------------------------------------------------------------
 .../core/ep/producer/JsonEntryEntityProducer.java      | 13 +++++++++----
 .../core/ep/producer/JsonEntryEntityProducerTest.java  |  4 ++--
 .../core/ep/producer/JsonFunctionImportTest.java       |  2 +-
 .../olingo/odata2/fit/ref/EntryJsonReadOnlyTest.java   | 10 +++++-----
 .../olingo/odata2/fit/ref/FeedJsonReadOnlyTest.java    |  6 ++++--
 5 files changed, 21 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/d6fe9bf6/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
index fea6a49..63d3704 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducer.java
@@ -200,10 +200,15 @@ public class JsonEntryEntityProducer {
 
   private void writeMetadata(final EntityInfoAggregator entityInfo, final Map<String,
Object> data,
       final EdmEntityType type) throws IOException, EntityProviderException, EdmException
{
+    if (properties.getServiceRoot() == null) {
+      location =  "";
+    } else {
+      location = properties.getServiceRoot().toASCIIString() +
+          AtomEntryEntityProducer.createSelfLink(entityInfo, data, null);
+    }
+
     jsonStreamWriter.name(FormatJson.METADATA);
     jsonStreamWriter.beginObject();
-    final String self = AtomEntryEntityProducer.createSelfLink(entityInfo, data, null);
-    location = (properties.getServiceRoot() == null ? "" : properties.getServiceRoot().toASCIIString())
+ self;
     jsonStreamWriter.namedStringValue(FormatJson.ID, location);
     jsonStreamWriter.separator();
     jsonStreamWriter.namedStringValue(FormatJson.URI, location);
@@ -229,7 +234,7 @@ public class JsonEntryEntityProducer {
           mediaSrc = (String) data.get(mediaResourceSourceKey);
         }
         if (mediaSrc == null) {
-          mediaSrc = self + "/$value";
+          mediaSrc = location + "/$value";
         }
         String mediaResourceMimeTypeKey = entityTypeMapping.getMediaResourceMimeTypeKey();
         if (mediaResourceMimeTypeKey != null) {
@@ -239,7 +244,7 @@ public class JsonEntryEntityProducer {
           mediaResourceMimeType = ContentType.APPLICATION_OCTET_STREAM.toString();
         }
       } else {
-        mediaSrc = self + "/$value";
+        mediaSrc = location + "/$value";
         mediaResourceMimeType = ContentType.APPLICATION_OCTET_STREAM.toString();
       }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/d6fe9bf6/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducerTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducerTest.java
b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducerTest.java
index 7845b6d..069457b 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducerTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonEntryEntityProducerTest.java
@@ -364,7 +364,7 @@ public class JsonEntryEntityProducerTest extends BaseTest {
         + "\"id\":\"" + BASE_URI + "Container2.Photos(Id=1,Type='image%2Fpng')\","
         + "\"uri\":\"" + BASE_URI + "Container2.Photos(Id=1,Type='image%2Fpng')\","
         + "\"type\":\"RefScenario2.Photo\",\"etag\":\"W/\\\"1\\\"\",\"content_type\":\"image/png\","
-        + "\"media_src\":\"Container2.Photos(Id=1,Type='image%2Fpng')/$value\","
+        + "\"media_src\":\"" + BASE_URI + "Container2.Photos(Id=1,Type='image%2Fpng')/$value\","
         + "\"edit_media\":\"" + BASE_URI + "Container2.Photos(Id=1,Type='image%2Fpng')/$value\"},"
         + "\"Id\":1,\"Name\":null,\"Type\":\"image/png\",\"Image\":null,"
         + "\"BinaryData\":\"/wABAg==\",\"Содержание\":null,\"CustomProperty\":null}}",
@@ -394,7 +394,7 @@ public class JsonEntryEntityProducerTest extends BaseTest {
         + "\"id\":\"" + BASE_URI + "Employees('1')\","
         + "\"uri\":\"" + BASE_URI + "Employees('1')\","
         + "\"type\":\"RefScenario.Employee\",\"content_type\":\"image/jpeg\","
-        + "\"media_src\":\"Employees('1')/$value\","
+        + "\"media_src\":\"" + BASE_URI + "Employees('1')/$value\","
         + "\"edit_media\":\"" + BASE_URI + "Employees('1')/$value\"},"
         + "\"EntryDate\":\"\\/Date(0)\\/\"}}",
         json);

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/d6fe9bf6/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonFunctionImportTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonFunctionImportTest.java
b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonFunctionImportTest.java
index 001e7f1..69177f1 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonFunctionImportTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/ep/producer/JsonFunctionImportTest.java
@@ -148,7 +148,7 @@ public class JsonFunctionImportTest extends BaseTest {
         + "\"id\":\"" + uri + "Employees('1')\","
         + "\"uri\":\"" + uri + "Employees('1')\","
         + "\"type\":\"RefScenario.Employee\",\"content_type\":\"image/jpeg\","
-        + "\"media_src\":\"Employees('1')/$value\","
+        + "\"media_src\":\"" + uri + "Employees('1')/$value\","
         + "\"edit_media\":\"" + uri + "Employees('1')/$value\"},"
         + "\"EmployeeId\":\"1\",\"EmployeeName\":null,"
         + "\"ManagerId\":null,\"RoomId\":null,\"TeamId\":null,"

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/d6fe9bf6/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/EntryJsonReadOnlyTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/EntryJsonReadOnlyTest.java
b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/EntryJsonReadOnlyTest.java
index 0f42b97..87f1b07 100644
--- a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/EntryJsonReadOnlyTest.java
+++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/EntryJsonReadOnlyTest.java
@@ -55,7 +55,7 @@ public class EntryJsonReadOnlyTest extends AbstractRefTest {
     checkMediaType(response, HttpContentType.APPLICATION_JSON);
     assertEquals("{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Employees('3')\","
         + "\"uri\":\"" + getEndpoint() + "Employees('3')\",\"type\":\"RefScenario.Employee\","
-        + "\"content_type\":\"image/jpeg\",\"media_src\":\"Employees('3')/$value\","
+        + "\"content_type\":\"image/jpeg\",\"media_src\":\"" + getEndpoint() + "Employees('3')/$value\","
         + "\"edit_media\":\"" + getEndpoint() + "Employees('3')/$value\"},"
         + "\"Age\":56,\"EntryDate\":null,"
         + "\"ne_Team\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Employees('3')/ne_Team\"}}}}",
@@ -68,7 +68,7 @@ public class EntryJsonReadOnlyTest extends AbstractRefTest {
     checkMediaType(response, HttpContentType.APPLICATION_JSON);
     assertEquals("{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Employees('3')\","
         + "\"uri\":\"" + getEndpoint() + "Employees('3')\",\"type\":\"RefScenario.Employee\","
-        + "\"content_type\":\"image/jpeg\",\"media_src\":\"Employees('3')/$value\","
+        + "\"content_type\":\"image/jpeg\",\"media_src\":\"" + getEndpoint() + "Employees('3')/$value\","
         + "\"edit_media\":\"" + getEndpoint() + "Employees('3')/$value\"},"
         + "\"Age\":56,\"EntryDate\":null,"
         + "\"ne_Team\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Employees('3')/ne_Team\"}}}}",
@@ -83,7 +83,7 @@ public class EntryJsonReadOnlyTest extends AbstractRefTest {
     assertEquals("{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Container2.Photos(Id=1,Type='image%2Fpng')\","
         + "\"uri\":\"" + getEndpoint() + "Container2.Photos(Id=1,Type='image%2Fpng')\","
         + "\"type\":\"RefScenario2.Photo\",\"etag\":\"W/\\\"1\\\"\",\"content_type\":\"image/png\","
-        + "\"media_src\":\"Container2.Photos(Id=1,Type='image%2Fpng')/$value\","
+        + "\"media_src\":\"" + getEndpoint() + "Container2.Photos(Id=1,Type='image%2Fpng')/$value\","
         + "\"edit_media\":\"" + getEndpoint() + "Container2.Photos(Id=1,Type='image%2Fpng')/$value\"},"
         + "\"Id\":1,\"Name\":\"Photo 1\",\"Type\":\"image/png\","
         + "\"ImageUrl\":\"http://localhost/Employee_1.png\","
@@ -140,7 +140,7 @@ public class EntryJsonReadOnlyTest extends AbstractRefTest {
         + "\"id\":\"" + getEndpoint() + "Employees('5')\","
         + "\"uri\":\"" + getEndpoint() + "Employees('5')\","
         + "\"type\":\"RefScenario.Employee\",\"content_type\":\"image/jpeg\","
-        + "\"media_src\":\"Employees('5')/$value\","
+        + "\"media_src\":\"" + getEndpoint() + "Employees('5')/$value\","
         + "\"edit_media\":\"" + getEndpoint() + "Employees('5')/$value\"},"
         + "\"Age\":42,"
         + "\"ne_Room\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('3')\","
@@ -160,7 +160,7 @@ public class EntryJsonReadOnlyTest extends AbstractRefTest {
         + "\"id\":\"" + getEndpoint() + "Employees('1')\","
         + "\"uri\":\"" + getEndpoint() + "Employees('1')\","
         + "\"type\":\"RefScenario.Employee\",\"content_type\":\"image/jpeg\","
-        + "\"media_src\":\"Employees('1')/$value\","
+        + "\"media_src\":\"" + getEndpoint() + "Employees('1')/$value\","
         + "\"edit_media\":\"" + getEndpoint() + "Employees('1')/$value\"},"
         + "\"EntryDate\":\"\\/Date(915148800000)\\/\","
         + "\"ne_Manager\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Employees('1')/ne_Manager\"}},"

http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/d6fe9bf6/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FeedJsonReadOnlyTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FeedJsonReadOnlyTest.java
b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FeedJsonReadOnlyTest.java
index 9271912..57ad9cf 100644
--- a/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FeedJsonReadOnlyTest.java
+++ b/odata2-lib/odata-fit/src/test/java/org/apache/olingo/odata2/fit/ref/FeedJsonReadOnlyTest.java
@@ -133,7 +133,8 @@ public class FeedJsonReadOnlyTest extends AbstractRefTest {
     assertEquals("{\"d\":{\"results\":[{\"__metadata\":{"
         + "\"id\":\"" + getEndpoint() + "Employees('1')\","
         + "\"uri\":\"" + getEndpoint() + "Employees('1')\",\"type\":\"RefScenario.Employee\","
-        + "\"content_type\":\"image/jpeg\",\"media_src\":\"Employees('1')/$value\","
+        + "\"content_type\":\"image/jpeg\","
+        + "\"media_src\":\"" + getEndpoint() + "Employees('1')/$value\","
         + "\"edit_media\":\"" + getEndpoint() + "Employees('1')/$value\"},"
         + "\"Age\":52,"
         + "\"ne_Room\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
@@ -145,7 +146,8 @@ public class FeedJsonReadOnlyTest extends AbstractRefTest {
         + "\"type\":\"RefScenario.Building\"},\"Name\":\"Building 1\"}}},"
         + "{\"__metadata\":{\"id\":\"" + getEndpoint() + "Employees('2')\","
         + "\"uri\":\"" + getEndpoint() + "Employees('2')\",\"type\":\"RefScenario.Employee\","
-        + "\"content_type\":\"image/jpeg\",\"media_src\":\"Employees('2')/$value\","
+        + "\"content_type\":\"image/jpeg\","
+        + "\"media_src\":\"" + getEndpoint() + "Employees('2')/$value\","
         + "\"edit_media\":\"" + getEndpoint() + "Employees('2')/$value\"},"
         + "\"Age\":32,"
         + "\"ne_Room\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('2')\","


Mime
View raw message