olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chri...@apache.org
Subject olingo-odata4 git commit: [Olingo-731] finalize debug supprt
Date Fri, 14 Aug 2015 11:45:12 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master 4a8140924 -> 179c46396


[Olingo-731] finalize debug supprt


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

Branch: refs/heads/master
Commit: 179c46396e41bb13897400ccf3a34cd14dfcf2b3
Parents: 4a81409
Author: Christian Amend <christian.amend@sap.com>
Authored: Fri Aug 14 13:25:36 2015 +0200
Committer: Christian Amend <christian.amend@sap.com>
Committed: Fri Aug 14 13:26:03 2015 +0200

----------------------------------------------------------------------
 .../olingo/commons/api/http/HttpHeaders.java    |  4 +--
 .../olingo/server/api/uri/UriInfoResource.java  |  1 +
 .../server/api/uri/queryoption/ExpandItem.java  |  1 +
 .../core/debug/DebugResponseHelperImpl.java     |  1 -
 .../olingo/server/core/debug/DebugTabBody.java  | 32 ++++++++------------
 5 files changed, 17 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/179c4639/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeaders.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeaders.java
b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeaders.java
index 54d0e30..59c07c2 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeaders.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/http/HttpHeaders.java
@@ -21,14 +21,14 @@ package org.apache.olingo.commons.api.http;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.Map;
-import java.util.TreeMap;
 
 /**
  * HttpHeader container
  */
 public class HttpHeaders {
-  private final Map<String, HttpHeader> headers = new TreeMap<String, HttpHeader>();
+  private final Map<String, HttpHeader> headers = new LinkedHashMap<String, HttpHeader>();
 
   /**
    * Add a header with given name and value.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/179c4639/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
index 20d4880..3ea1058 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/UriInfoResource.java
@@ -75,6 +75,7 @@ public interface UriInfoResource {
   OrderByOption getOrderByOption();
 
   /**
+   * <b>CURRENTLY NOT SUPPORTED. WILL ALWAYS RETURN NULL</b>
    * @return Object containing information of the $search option
    */
   SearchOption getSearchOption();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/179c4639/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ExpandItem.java
----------------------------------------------------------------------
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ExpandItem.java
b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ExpandItem.java
index fccf844..a16c137 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ExpandItem.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/uri/queryoption/ExpandItem.java
@@ -38,6 +38,7 @@ public interface ExpandItem {
   FilterOption getFilterOption();
 
   /**
+   * <b>CURRENTLY NOT SUPPORTED. WILL ALWAYS RETURN NULL</b>
    * @return Information of the option $search when used within $expand
    */
   SearchOption getSearchOption();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/179c4639/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
index 3a1c2e0..222bd0a 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugResponseHelperImpl.java
@@ -138,7 +138,6 @@ public class DebugResponseHelperImpl implements DebugResponseHelper {
 
     gen.writeStartObject();
     DebugTab requestInfo = parts.get(0);
-    // TODO: Should we really translate to lower case here?
     gen.writeFieldName(requestInfo.getName().toLowerCase(Locale.ROOT));
     requestInfo.appendJson(gen);
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/179c4639/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java
----------------------------------------------------------------------
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java
b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java
index e0330b8..317f376 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabBody.java
@@ -22,6 +22,7 @@ import java.io.IOException;
 import java.io.Writer;
 import java.util.regex.Pattern;
 
+import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.IOUtils;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.server.api.ODataResponse;
@@ -43,31 +44,27 @@ public class DebugTabBody implements DebugTab {
 
   private final String serviceRoot;
 
-//  private final boolean isXml;
-//  private final boolean isJson;
-//  private final boolean isText;
-//  private final boolean isImage;
-
   public DebugTabBody(final ODataResponse response, final String serviceRoot) {
     this.response = response;
     this.serviceRoot = serviceRoot == null ? "/" : serviceRoot;
     if (response != null) {
-      final String contentType = response.getHeader(HttpHeader.CONTENT_TYPE);
-      // TODO: Differentiate better
-      if (contentType != null) {
-        responseContent = ResponseContent.JSON;
+      final String contentTypeString = response.getHeader(HttpHeader.CONTENT_TYPE);
+      if (contentTypeString != null) {
+        if (contentTypeString.startsWith("application/json")) {
+          responseContent = ResponseContent.JSON;
+        } else if (contentTypeString.startsWith("image/")) {
+          responseContent = ResponseContent.IMAGE;
+        } else if (contentTypeString.contains("xml")) {
+          responseContent = ResponseContent.XML;
+        } else {
+          responseContent = ResponseContent.TEXT;
+        }
       } else {
         responseContent = ResponseContent.TEXT;
       }
     } else {
       responseContent = ResponseContent.TEXT;
     }
-//    isXml = contentType.contains("xml");
-//    isJson = !isXml && contentType.startsWith(HttpContentType.APPLICATION_JSON);
-//    isText = isXml || isJson || contentType.startsWith("text/")
-//        || contentType.startsWith(HttpContentType.APPLICATION_HTTP)
-//        || contentType.startsWith(HttpContentType.MULTIPART_MIXED);
-//    isImage = !isText && contentType.startsWith("image/");
   }
 
   @Override
@@ -90,14 +87,12 @@ public class DebugTabBody implements DebugTab {
       String contentString;
       switch (responseContent) {
       case IMAGE:
-        // TODO: DecodeString as base 64
-        contentString = "Currently not supported";
+        contentString = Base64.encodeBase64String(IOUtils.toString(response.getContent()).getBytes());
         break;
       case JSON:
       case XML:
       case TEXT:
       default:
-        // TODO: Remove IOUtils from core dependency
         contentString = IOUtils.toString(response.getContent(), "UTF-8");
         break;
       }
@@ -124,7 +119,6 @@ public class DebugTabBody implements DebugTab {
       writer.append("</pre>\n");
       break;
     case IMAGE:
-      // Make header query case insensitive
       writer.append("<img src=\"data:").append(response.getHeader(HttpHeader.CONTENT_TYPE)).append(";base64,")
           .append(body)
           .append("\" />\n");


Mime
View raw message