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 2014/01/15 11:39:38 UTC

git commit: [OLINGO-119] Handle Exception in Expand Callbacks

Updated Branches:
  refs/heads/master 0bb29313f -> 0244da6d2


[OLINGO-119] Handle Exception in Expand Callbacks


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

Branch: refs/heads/master
Commit: 0244da6d2aa9ab7adbd97933e25051538c6f3cdd
Parents: 0bb2931
Author: Chandan V A <ch...@sap.com>
Authored: Wed Jan 15 16:09:20 2014 +0530
Committer: Chandan V A <ch...@sap.com>
Committed: Wed Jan 15 16:09:20 2014 +0530

----------------------------------------------------------------------
 .../core/access/data/JPAExpandCallBack.java         | 16 ++++++++++------
 .../core/access/data/JPAExpandCallBackTest.java     |  5 +++++
 2 files changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/0244da6d/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBack.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBack.java b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBack.java
index 1cf74b3..7383081 100644
--- a/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBack.java
+++ b/odata2-jpa-processor/jpa-core/src/main/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBack.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.olingo.odata2.api.ODataCallback;
@@ -39,6 +40,7 @@ import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
 import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult;
 import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
 import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult;
+import org.apache.olingo.odata2.api.exception.ODataApplicationException;
 import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
 import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
 import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException;
@@ -56,7 +58,8 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
   }
 
   @Override
-  public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context) {
+  public WriteEntryCallbackResult retrieveEntryResult(final WriteEntryCallbackContext context)
+      throws ODataApplicationException {
     WriteEntryCallbackResult result = new WriteEntryCallbackResult();
     Map<String, Object> entry = context.getEntryData();
     Map<String, Object> edmPropertyValueMap = null;
@@ -86,16 +89,17 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
       }
       result.setInlineProperties(getInlineEntityProviderProperties(context));
     } catch (EdmException e) {
-
+      throw new ODataApplicationException(e.getMessage(), Locale.getDefault(), e);
     } catch (ODataJPARuntimeException e) {
-
+      throw new ODataApplicationException(e.getMessage(), Locale.getDefault(), e);
     }
 
     return result;
   }
 
   @Override
-  public WriteFeedCallbackResult retrieveFeedResult(final WriteFeedCallbackContext context) {
+  public WriteFeedCallbackResult retrieveFeedResult(final WriteFeedCallbackContext context)
+      throws ODataApplicationException {
     WriteFeedCallbackResult result = new WriteFeedCallbackResult();
     HashMap<String, Object> inlinedEntry = (HashMap<String, Object>) context.getEntryData();
     List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
@@ -132,9 +136,9 @@ public class JPAExpandCallBack implements OnWriteFeedContent, OnWriteEntryConten
       }
       result.setInlineProperties(getInlineEntityProviderProperties(context));
     } catch (EdmException e) {
-
+      throw new ODataApplicationException(e.getMessage(), Locale.getDefault(), e);
     } catch (ODataJPARuntimeException e) {
-
+      throw new ODataApplicationException(e.getMessage(), Locale.getDefault(), e);
     }
     return result;
   }

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/0244da6d/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBackTest.java
----------------------------------------------------------------------
diff --git a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBackTest.java b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBackTest.java
index efa230c..634df6e 100644
--- a/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBackTest.java
+++ b/odata2-jpa-processor/jpa-core/src/test/java/org/apache/olingo/odata2/jpa/processor/core/access/data/JPAExpandCallBackTest.java
@@ -38,6 +38,7 @@ import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackContext;
 import org.apache.olingo.odata2.api.ep.callback.WriteEntryCallbackResult;
 import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackContext;
 import org.apache.olingo.odata2.api.ep.callback.WriteFeedCallbackResult;
+import org.apache.olingo.odata2.api.exception.ODataApplicationException;
 import org.apache.olingo.odata2.api.uri.ExpandSelectTreeNode;
 import org.apache.olingo.odata2.api.uri.NavigationPropertySegment;
 import org.apache.olingo.odata2.jpa.processor.core.common.ODataJPATestConstants;
@@ -64,6 +65,8 @@ public class JPAExpandCallBackTest {
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     } catch (IllegalAccessException e) {
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataApplicationException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     }
   }
 
@@ -85,6 +88,8 @@ public class JPAExpandCallBackTest {
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     } catch (IllegalAccessException e) {
       fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
+    } catch (ODataApplicationException e) {
+      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
     }
   }