[1/2] olingo-odata4 git commit: [OLINGO-935] $apply as option for $expand should be possible

2016-10-07 Thread chrisam
Repository: olingo-odata4
Updated Branches:
  refs/heads/master 72fcaa1a5 -> 9e67d0e3e


[OLINGO-935] $apply as option for $expand should be possible

Signed-off-by: Christian Amend 


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

Branch: refs/heads/master
Commit: 1600684d4f7dab8db570d02212f4bd12bb73a1a0
Parents: 72fcaa1
Author: Klaus Straubinger 
Authored: Fri Oct 7 14:36:51 2016 +0200
Committer: Christian Amend 
Committed: Fri Oct 7 14:51:57 2016 +0200

--
 .../server/api/uri/queryoption/ExpandItem.java  |   5 +
 .../server/core/uri/parser/ExpandParser.java|   7 +
 .../core/uri/queryoption/ExpandItemImpl.java|  12 +-
 .../core/uri/queryoption/ExpandOptionImpl.java  |   3 +-
 .../core/uri/queryoption/OrderByItemImpl.java   |   4 +-
 .../core/uri/queryoption/SearchOptionImpl.java  |   3 +-
 .../olingo/server/core/uri/UriInfoImplTest.java |   6 +-
 .../core/uri/parser/ExpandParserTest.java   | 491 ---
 .../server/core/uri/parser/UriParserTest.java   |  24 +-
 .../core/uri/testutil/ExpandValidator.java  |  37 +-
 .../core/uri/testutil/FilterTreeToText.java |  12 +-
 .../core/uri/testutil/TestUriValidator.java |  28 +-
 12 files changed, 284 insertions(+), 348 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1600684d/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 4e71157..8ae8898 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
@@ -73,6 +73,11 @@ public interface ExpandItem {
   ExpandOption getExpandOption();
 
   /**
+   * @return Information on the option $apply when used within $expand
+   */
+  ApplyOption getApplyOption();
+
+  /**
* @return A {@link UriInfoResource} object containing the resource path 
segments to be expanded
*/
   UriInfoResource getResourcePath();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1600684d/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
--
diff --git 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
index 8a493ff..53a14d7 100644
--- 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
+++ 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/parser/ExpandParser.java
@@ -50,6 +50,7 @@ import 
org.apache.olingo.server.core.uri.queryoption.ExpandOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.LevelsOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
 import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl;
+import 
org.apache.olingo.server.core.uri.queryoption.apply.DynamicStructuredType;
 import org.apache.olingo.server.core.uri.validator.UriValidationException;
 
 public class ExpandParser {
@@ -276,6 +277,12 @@ public class ExpandParser {
   topOption.setValue(value);
   systemQueryOption = topOption;
 
+} else if (!forRef && !forCount && tokenizer.next(TokenKind.APPLY)) {
+  ParserHelper.requireNext(tokenizer, TokenKind.EQ);
+  systemQueryOption = new ApplyParser(edm, odata).parse(tokenizer,
+  // Data aggregation may change the structure of the result, so 
we create a new dynamic type.
+  new DynamicStructuredType(referencedType), null, aliases);
+
 } else {
   throw new UriParserSyntaxException("Allowed query option expected.",
   UriParserSyntaxException.MessageKeys.SYNTAX);

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/1600684d/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java
--
diff --git 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/uri/queryoption/ExpandItemImpl.java
index 

[2/2] olingo-odata4 git commit: [OLINGO-935] improved debug support

2016-10-07 Thread chrisam
[OLINGO-935] improved debug support

including more unit tests

Signed-off-by: Christian Amend 


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

Branch: refs/heads/master
Commit: 9e67d0e3e8ae71ea15098ba24fd22bf74c2faaa4
Parents: 1600684
Author: Klaus Straubinger 
Authored: Fri Oct 7 14:41:17 2016 +0200
Committer: Christian Amend 
Committed: Fri Oct 7 14:52:41 2016 +0200

--
 .../olingo/server/core/debug/DebugTabBody.java  |  43 +-
 .../server/core/debug/DebugTabRuntime.java  |   8 +-
 .../server/core/debug/DebugTabStacktrace.java   |   2 +-
 .../olingo/server/core/debug/DebugTabUri.java   |  49 ++-
 .../core/debug/ExpressionJsonVisitor.java   |  78 +++-
 .../server/core/debug/AbstractDebugTabTest.java |  28 +-
 .../server/core/debug/DebugTabBodyTest.java |  67 +++
 .../server/core/debug/DebugTabRuntimeTest.java  |  73 
 .../core/debug/DebugTabStacktraceTest.java  | 107 +
 .../server/core/debug/DebugTabUriTest.java  | 405 +++
 .../core/debug/ServerCoreDebuggerTest.java  |  37 +-
 11 files changed, 832 insertions(+), 65 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e67d0e3/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 b0c5314..9bca8eb 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
@@ -23,7 +23,6 @@ import java.io.InputStream;
 import java.io.Writer;
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.olingo.commons.api.ex.ODataRuntimeException;
 import org.apache.olingo.commons.api.http.HttpHeader;
 import org.apache.olingo.server.api.ODataResponse;
 import org.apache.olingo.server.api.deserializer.DeserializerException;
@@ -70,33 +69,12 @@ public class DebugTabBody implements DebugTab {
 return "Body";
   }
 
-  //
   @Override
-  public void appendJson(final JsonGenerator gen) throws IOException {
+  public void appendJson(final JsonGenerator json) throws IOException {
 if (response == null || response.getContent() == null) {
-  gen.writeNull();
+  json.writeNull();
 } else {
-  gen.writeString(getContentString());
-}
-  }
-
-  private String getContentString() {
-try {
-  String contentString;
-  switch (responseContent) {
-  case IMAGE:
-contentString = 
Base64.encodeBase64String(streamToBytes(response.getContent()));
-break;
-  case JSON:
-  case XML:
-  case TEXT:
-  default:
-contentString = new String(streamToBytes(response.getContent()), 
"UTF-8");
-break;
-  }
-  return contentString;
-} catch (IOException e) {
-  return "Could not parse Body for Debug Output";
+  json.writeString(getContentString());
 }
   }
 
@@ -130,12 +108,23 @@ public class DebugTabBody implements DebugTab {
 }
   }
 
-  private byte[] streamToBytes(final InputStream input) {
+  private String getContentString() {
+try {
+  final byte[] content = streamToBytes(response.getContent());
+  return responseContent == ResponseContent.IMAGE ?
+  Base64.encodeBase64String(content) :
+  new String(content, "UTF-8");
+} catch (final IOException e) {
+  return "Could not parse Body for Debug Output";
+}
+  }
+
+  private byte[] streamToBytes(final InputStream input) throws IOException {
 if (input != null) {
   try {
 return new FixedFormatDeserializerImpl().binary(input);
   } catch (final DeserializerException e) {
-throw new ODataRuntimeException("Error on reading request content", e);
+throw new IOException("Error on reading request content", e);
   }
 }
 return null;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9e67d0e3/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRuntime.java
--
diff --git 
a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRuntime.java
 
b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/DebugTabRuntime.java
index 4214050..7416594 100644
---