[OLINGO-328] Merge remote-tracking branch 'origin/master' into olingo328

This commit is contained in:
Stephan Klevenz 2014-06-30 14:10:55 +02:00
commit bf96839818
4 changed files with 14 additions and 20 deletions

View File

@ -24,7 +24,6 @@ import java.lang.reflect.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -44,8 +43,6 @@ import org.apache.olingo.ext.proxy.utils.CoreUtils;
public class ComplexInvocationHandler extends AbstractStructuredInvocationHandler { public class ComplexInvocationHandler extends AbstractStructuredInvocationHandler {
private static final long serialVersionUID = 2629912294765040037L;
private static Pair<ODataComplexValue<? extends CommonODataProperty>, Class<?>> init( private static Pair<ODataComplexValue<? extends CommonODataProperty>, Class<?>> init(
final CommonEdmEnabledODataClient<?> client, final CommonEdmEnabledODataClient<?> client,
final Class<?> reference) { final Class<?> reference) {
@ -151,8 +148,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
} }
} }
for (final Iterator<? extends CommonODataProperty> itor = getComplex().iterator(); itor.hasNext();) { for (final CommonODataProperty property : getComplex()) {
final CommonODataProperty property = itor.next();
if (!propertyNames.contains(property.getName())) { if (!propertyNames.contains(property.getName())) {
res.add(property.getName()); res.add(property.getName());
} }
@ -180,10 +176,7 @@ public class ComplexInvocationHandler extends AbstractStructuredInvocationHandle
if (value == null) { if (value == null) {
toBeAdded = null; toBeAdded = null;
} else if (Collection.class.isAssignableFrom(value.getClass())) { } else if (Collection.class.isAssignableFrom(value.getClass())) {
toBeAdded = new ArrayList<Object>(); toBeAdded = new ArrayList<Object>((Collection<? extends Object>) value);
for (Object obj : (Collection) value) {
Collection.class.cast(toBeAdded).add(obj);
}
} else { } else {
toBeAdded = value; toBeAdded = value;
} }

View File

@ -216,6 +216,7 @@ public class ODataBinderImpl extends AbstractODataBinder implements ODataBinder
} }
@Override @Override
@SuppressWarnings("unchecked")
protected Object getValue(final ODataValue value) { protected Object getValue(final ODataValue value) {
Object valueResource; Object valueResource;
if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue if (value instanceof org.apache.olingo.commons.api.domain.v4.ODataValue

View File

@ -122,6 +122,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria
return value; return value;
} }
@SuppressWarnings("unchecked")
private Object fromComplexOrEnum(final XMLEventReader reader, final StartElement start) private Object fromComplexOrEnum(final XMLEventReader reader, final StartElement start)
throws XMLStreamException, EdmPrimitiveTypeException { throws XMLStreamException, EdmPrimitiveTypeException {

View File

@ -145,7 +145,7 @@ public class JsonDeserializer implements ODataDeserializer {
link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString()); link.setType(ODataLinkType.ENTITY_SET_NAVIGATION.toString());
EntitySet entitySet = new EntitySetImpl(); EntitySet entitySet = new EntitySetImpl();
Iterator<JsonNode> entries = ((ArrayNode) inline).elements(); Iterator<JsonNode> entries = inline.elements();
while (entries.hasNext()) { while (entries.hasNext()) {
entitySet.getEntities().add( entitySet.getEntities().add(
entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload()); entityDeserializer.doDeserialize(entries.next().traverse(codec)).getPayload());
@ -326,25 +326,24 @@ public class JsonDeserializer implements ODataDeserializer {
private Object fromComplex(final ObjectNode node, final ObjectCodec codec) private Object fromComplex(final ObjectNode node, final ObjectCodec codec)
throws IOException, EdmPrimitiveTypeException { throws IOException, EdmPrimitiveTypeException {
final Object value = version.compareTo(ODataServiceVersion.V40) < 0 ?
new ArrayList<Property>() :
new LinkedComplexValueImpl();
if (value instanceof LinkedComplexValue) { if (version.compareTo(ODataServiceVersion.V40) < 0) {
List<Property> properties = new ArrayList<Property>();
populate(null, properties, node, codec);
return properties;
} else {
LinkedComplexValue linkComplexValue = new LinkedComplexValueImpl();
final Set<String> toRemove = new HashSet<String>(); final Set<String> toRemove = new HashSet<String>();
for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) { for (final Iterator<Map.Entry<String, JsonNode>> itor = node.fields(); itor.hasNext();) {
final Map.Entry<String, JsonNode> field = itor.next(); final Map.Entry<String, JsonNode> field = itor.next();
links(field, (LinkedComplexValue) value, toRemove, node, codec); links(field, linkComplexValue, toRemove, node, codec);
} }
node.remove(toRemove); node.remove(toRemove);
populate((LinkedComplexValue) value, ((LinkedComplexValue) value).getValue(), node, codec); populate(linkComplexValue, linkComplexValue.getValue(), node, codec);
} else { return linkComplexValue;
populate(null, (List<Property>) value, node, codec);
} }
return value;
} }
private void fromCollection(Valuable valuable, final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo, private void fromCollection(Valuable valuable, final Iterator<JsonNode> nodeItor, final EdmTypeInfo typeInfo,