[Olingo-731] finalize debug supprt

This commit is contained in:
Christian Amend 2015-08-14 13:25:36 +02:00
parent 4a81409246
commit 179c46396e
5 changed files with 17 additions and 22 deletions

View File

@ -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.

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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");