You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/05/13 13:47:49 UTC
[05/31] Various small improvements,
added test for instance annotations
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8720a30e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
index 50fa1f9..36818a9 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDeserializer.java
@@ -24,17 +24,12 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
-
import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
import org.apache.olingo.commons.api.domain.ODataErrorDetail;
@@ -65,29 +60,25 @@ public class JSONODataErrorDeserializer extends AbstractJsonDeserializer<JSONODa
error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
}
if (errorNode.hasNonNull(Constants.ERROR_DETAILS)) {
- List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
- for (final Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
- details.add(
- itor.next().traverse(parser.getCodec()).<ResWrap<JSONODataErrorDetailImpl>>readValueAs(
- new TypeReference<JSONODataErrorDetailImpl>() {
- }).getPayload());
- }
-
- error.setDetails(details);
+ final List<ODataErrorDetail> details = new ArrayList<ODataErrorDetail>();
+ for (final Iterator<JsonNode> itor = errorNode.get(Constants.ERROR_DETAILS).iterator(); itor.hasNext();) {
+ details.add(itor.next().traverse(parser.getCodec()).<ResWrap<JSONODataErrorDetailImpl>>readValueAs(
+ new TypeReference<JSONODataErrorDetailImpl>() {
+ }).getPayload());
+ }
+
+ error.setDetails(details);
}
if (errorNode.hasNonNull(Constants.ERROR_INNERERROR)) {
- JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
- Dictionary<String, Object> innerErr = new Hashtable<String, Object>();
- for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
- String keyTmp = itor.next();
- String val = innerError.get(keyTmp).toString();
- innerErr.put(keyTmp,val);
- }
-
- error.setInnerError(innerErr);
+ final JsonNode innerError = errorNode.get(Constants.ERROR_INNERERROR);
+ for (final Iterator<String> itor = innerError.fieldNames(); itor.hasNext();) {
+ final String keyTmp = itor.next();
+ final String val = innerError.get(keyTmp).toString();
+ error.getInnerError().put(keyTmp, val);
+ }
}
}
-
+
return new ResWrap<JSONODataErrorImpl>((URI) null, null, error);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8720a30e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
index 9c2ce7b..38ea043 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailDeserializer.java
@@ -20,47 +20,37 @@ package org.apache.olingo.commons.core.data;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
import java.io.IOException;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.olingo.commons.api.Constants;
-import org.apache.olingo.commons.api.data.Entity;
import org.apache.olingo.commons.api.data.ResWrap;
-import org.apache.olingo.commons.api.domain.ODataErrorDetail;
-public class JSONODataErrorDetailDeserializer extends
- AbstractJsonDeserializer<JSONODataErrorDetailImpl> {
+public class JSONODataErrorDetailDeserializer extends AbstractJsonDeserializer<JSONODataErrorDetailImpl> {
- @Override
- protected ResWrap<JSONODataErrorDetailImpl> doDeserialize(
- final JsonParser parser, final DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
+ @Override
+ protected ResWrap<JSONODataErrorDetailImpl> doDeserialize(
+ final JsonParser parser, final DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
- final JSONODataErrorDetailImpl error = new JSONODataErrorDetailImpl();
- final JsonNode errorNode = parser.getCodec().readTree(parser);
- if (errorNode.has(Constants.ERROR_CODE)) {
- error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
- }
- if (errorNode.has(Constants.ERROR_MESSAGE)) {
- final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
- if (message.isValueNode()) {
- error.setMessage(message.textValue());
- } else if (message.isObject()) {
- error.setMessage(message.get(Constants.VALUE).asText());
- }
- }
- if (errorNode.has(Constants.ERROR_TARGET)) {
- error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
- }
+ final JSONODataErrorDetailImpl error = new JSONODataErrorDetailImpl();
+ final JsonNode errorNode = parser.getCodec().readTree(parser);
+ if (errorNode.has(Constants.ERROR_CODE)) {
+ error.setCode(errorNode.get(Constants.ERROR_CODE).textValue());
+ }
+ if (errorNode.has(Constants.ERROR_MESSAGE)) {
+ final JsonNode message = errorNode.get(Constants.ERROR_MESSAGE);
+ if (message.isValueNode()) {
+ error.setMessage(message.textValue());
+ } else if (message.isObject()) {
+ error.setMessage(message.get(Constants.VALUE).asText());
+ }
+ }
+ if (errorNode.has(Constants.ERROR_TARGET)) {
+ error.setTarget(errorNode.get(Constants.ERROR_TARGET).textValue());
+ }
- return new ResWrap<JSONODataErrorDetailImpl>((URI) null, null, error);
- }
+ return new ResWrap<JSONODataErrorDetailImpl>((URI) null, null, error);
+ }
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8720a30e/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
index 2f4585a..49f3159 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONODataErrorDetailImpl.java
@@ -27,36 +27,36 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonDeserialize(using = JSONODataErrorDetailDeserializer.class)
public class JSONODataErrorDetailImpl implements ODataErrorDetail {
- private String code;
+ private String code;
- private String message;
+ private String message;
- private String target;
+ private String target;
- @Override
- public String getCode() {
- return code;
- }
+ @Override
+ public String getCode() {
+ return code;
+ }
- public void setCode(final String code) {
- this.code = code;
- }
+ public void setCode(final String code) {
+ this.code = code;
+ }
- @Override
- public String getMessage() {
- return message;
- }
+ @Override
+ public String getMessage() {
+ return message;
+ }
- public void setMessage(final String message) {
- this.message = message;
- }
+ public void setMessage(final String message) {
+ this.message = message;
+ }
- @Override
- public String getTarget() {
- return target;
- }
+ @Override
+ public String getTarget() {
+ return target;
+ }
- public void setTarget(final String target) {
- this.target = target;
- }
-}
\ No newline at end of file
+ public void setTarget(final String target) {
+ this.target = target;
+ }
+}