[20/24] olingo-odata2 git commit: [OLINGO-1253]Client Module for Olingo v2

2018-04-08 Thread archanarai
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/4261deb7/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
--
diff --git 
a/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
 
b/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
new file mode 100644
index 000..06bae41
--- /dev/null
+++ 
b/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
@@ -0,0 +1,596 @@
+/***
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ 
**/
+package org.apache.olingo.odata2.client.core.ep.deserializer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.exception.ODataApplicationException;
+import org.apache.olingo.odata2.client.api.ep.DeserializerProperties;
+import 
org.apache.olingo.odata2.client.api.ep.callback.OnDeserializeInlineContent;
+import org.apache.olingo.odata2.core.commons.ContentType;
+import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
+import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
+import org.apache.olingo.odata2.core.ep.aggregator.EntityTypeMapping;
+import org.apache.olingo.odata2.core.ep.entry.EntryMetadataImpl;
+import org.apache.olingo.odata2.core.ep.entry.MediaMetadataImpl;
+import org.apache.olingo.odata2.core.ep.entry.ODataEntryImpl;
+import org.apache.olingo.odata2.core.ep.feed.FeedMetadataImpl;
+import org.apache.olingo.odata2.core.ep.feed.ODataDeltaFeedImpl;
+import org.apache.olingo.odata2.core.ep.util.FormatXml;
+
+/**
+ * Atom/XML format reader/consumer for entries.
+ * 
+ * {@link XmlEntryDeserializer} instance can be reused for several
+ * {@link #readEntry(XMLStreamReader, EntityInfoAggregator, 
EntityProviderReadProperties)} calls
+ * but be aware that the instance and their readEntry* methods 
are NOT THREAD SAFE.
+ * 
+ */
+public class XmlEntryDeserializer {
+
+  private ODataEntryImpl readEntryResult;
+  private Map properties;
+  private MediaMetadataImpl mediaMetadata;
+  private EntryMetadataImpl entryMetadata;
+  private EntityTypeMapping typeMappings;
+  private String currentHandledStartTagName;
+
+  /**
+   * Deserializes payload entry
+   * @param reader
+   * @param eia
+   * @param readProperties
+   * @param isInline
+   * @return ODataEntry
+   * @throws EntityProviderException
+   */
+  public ODataEntry readEntry(final XMLStreamReader reader, final 
EntityInfoAggregator eia,
+  final DeserializerProperties readProperties, final boolean isInline) 
throws EntityProviderException {
+try {
+  initialize(readProperties);
+
+  if (isInline) {
+setETag(reader);
+  }
+
+  while (reader.hasNext() && !isEntryEndTag(reader)) {
+reader.nextTag();
+if (reader.isStartElement()) {
+  handleStartedTag(reader, eia, readProperties);
+}
+  }
+
+  return readEntryResult;
+} catch (XMLStreamException e) {
+  throw new 
EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+  .getSimpleName()), e);
+ 

[20/24] olingo-odata2 git commit: [OLINGO-1253]Client Module for Olingo v2

2018-04-02 Thread archanarai
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/9e949e40/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
--
diff --git 
a/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
 
b/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
new file mode 100644
index 000..06bae41
--- /dev/null
+++ 
b/odata2-lib/odata-client-core/src/main/java/org/apache/olingo/odata2/client/core/ep/deserializer/XmlEntryDeserializer.java
@@ -0,0 +1,596 @@
+/***
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ 
**/
+package org.apache.olingo.odata2.client.core.ep.deserializer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.olingo.odata2.api.edm.Edm;
+import org.apache.olingo.odata2.api.edm.EdmEntitySet;
+import org.apache.olingo.odata2.api.edm.EdmException;
+import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
+import org.apache.olingo.odata2.api.edm.EdmMultiplicity;
+import org.apache.olingo.odata2.api.edm.EdmNavigationProperty;
+import org.apache.olingo.odata2.api.edm.EdmSimpleType;
+import org.apache.olingo.odata2.api.ep.EntityProviderException;
+import org.apache.olingo.odata2.api.ep.entry.ODataEntry;
+import org.apache.olingo.odata2.api.exception.ODataApplicationException;
+import org.apache.olingo.odata2.client.api.ep.DeserializerProperties;
+import 
org.apache.olingo.odata2.client.api.ep.callback.OnDeserializeInlineContent;
+import org.apache.olingo.odata2.core.commons.ContentType;
+import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
+import org.apache.olingo.odata2.core.ep.aggregator.EntityPropertyInfo;
+import org.apache.olingo.odata2.core.ep.aggregator.EntityTypeMapping;
+import org.apache.olingo.odata2.core.ep.entry.EntryMetadataImpl;
+import org.apache.olingo.odata2.core.ep.entry.MediaMetadataImpl;
+import org.apache.olingo.odata2.core.ep.entry.ODataEntryImpl;
+import org.apache.olingo.odata2.core.ep.feed.FeedMetadataImpl;
+import org.apache.olingo.odata2.core.ep.feed.ODataDeltaFeedImpl;
+import org.apache.olingo.odata2.core.ep.util.FormatXml;
+
+/**
+ * Atom/XML format reader/consumer for entries.
+ * 
+ * {@link XmlEntryDeserializer} instance can be reused for several
+ * {@link #readEntry(XMLStreamReader, EntityInfoAggregator, 
EntityProviderReadProperties)} calls
+ * but be aware that the instance and their readEntry* methods 
are NOT THREAD SAFE.
+ * 
+ */
+public class XmlEntryDeserializer {
+
+  private ODataEntryImpl readEntryResult;
+  private Map properties;
+  private MediaMetadataImpl mediaMetadata;
+  private EntryMetadataImpl entryMetadata;
+  private EntityTypeMapping typeMappings;
+  private String currentHandledStartTagName;
+
+  /**
+   * Deserializes payload entry
+   * @param reader
+   * @param eia
+   * @param readProperties
+   * @param isInline
+   * @return ODataEntry
+   * @throws EntityProviderException
+   */
+  public ODataEntry readEntry(final XMLStreamReader reader, final 
EntityInfoAggregator eia,
+  final DeserializerProperties readProperties, final boolean isInline) 
throws EntityProviderException {
+try {
+  initialize(readProperties);
+
+  if (isInline) {
+setETag(reader);
+  }
+
+  while (reader.hasNext() && !isEntryEndTag(reader)) {
+reader.nextTag();
+if (reader.isStartElement()) {
+  handleStartedTag(reader, eia, readProperties);
+}
+  }
+
+  return readEntryResult;
+} catch (XMLStreamException e) {
+  throw new 
EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+  .getSimpleName()), e);
+