You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2016/02/22 08:54:41 UTC

[17/21] olingo-odata4 git commit: [OLINGO-832] Merge branch 'master' into OLINGO-832_StreamSerializerPoC

[OLINGO-832] Merge branch 'master' into OLINGO-832_StreamSerializerPoC


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

Branch: refs/heads/master
Commit: 396a39baec9539249dcfa4b111e87c037cb6fb64
Parents: 5b6cccf d040afe
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Feb 19 09:39:49 2016 +0100
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Feb 19 09:39:49 2016 +0100

----------------------------------------------------------------------
 .../core/edm/annotation/EdmRecordImpl.java      |  16 +-
 .../core/edm/annotations/EdmRecordImplTest.java |   6 -
 .../core/edm/primitivetype/EdmDateTest.java     |  16 +-
 .../serializer/ComplexSerializerOptions.java    |  14 +-
 .../EntityCollectionSerializerOptions.java      |  11 +
 .../api/serializer/EntitySerializerOptions.java |  14 +-
 .../serializer/PrimitiveSerializerOptions.java  |  13 +
 .../PrimitiveValueSerializerOptions.java        |  14 +-
 .../olingo/server/core/MetadataParser.java      | 262 ++++++++++++++-----
 .../server/core/SchemaBasedEdmProvider.java     | 117 ++++-----
 .../olingo/server/core/ServiceRequest.java      |  50 +++-
 .../server/core/requests/DataRequest.java       |  13 +-
 .../src/main/resources/org.apache.olingo.v1.xml |  40 +++
 .../core/MetadataParserAnnotationsTest.java     |  10 +-
 .../olingo/server/core/MetadataParserTest.java  |   1 -
 .../server/core/ServiceDispatcherTest.java      |   3 +
 .../olingo/server/example/TripPinHandler.java   |   1 +
 .../server/example/TripPinServiceTest.java      |  30 ++-
 .../olingo/server/example/TripPinServlet.java   |   3 +-
 .../src/test/resources/airlines.json            |   2 +-
 .../src/test/resources/annotations.xml          |  17 ++
 .../src/test/resources/trippin.xml              |   6 +-
 .../xml/MetadataDocumentXmlSerializer.java      |   5 +-
 .../core/serializer/xml/ODataXmlSerializer.java | 138 ++++++----
 .../serializer/xml/ODataXmlSerializerTest.java  |  27 +-
 25 files changed, 606 insertions(+), 223 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/396a39ba/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
----------------------------------------------------------------------
diff --cc lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
index 6f4ed2d,9ee7d24..9335829
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/serializer/EntityCollectionSerializerOptions.java
@@@ -33,7 -32,7 +33,8 @@@ public class EntityCollectionSerializer
    private SelectOption select;
    private boolean writeOnlyReferences;
    private String id;
 +  private WriteContentErrorCallback writeContentErrorCallback;
+   private String xml10InvalidCharReplacement;
  
    /** Gets the {@link ContextURL}. */
    public ContextURL getContextURL() {
@@@ -65,17 -64,10 +66,21 @@@
      return id;
    }
  
 +  /**
 +   * Gets the callback which is used in case of an exception during
 +   * write of the content (in case the content will be written/streamed
 +   * in the future)
 +   * @return callback which is used in case of an exception during
 +   * write of the content
 +   *
 +   */
 +  public WriteContentErrorCallback getWriteContentErrorCallback() {
 +    return writeContentErrorCallback;
 +  }
+   /** Gets the replacement string for unicode characters, that is not allowed in XML 1.0 */
+   public String xml10InvalidCharReplacement() {
+     return xml10InvalidCharReplacement;
+   }  
  
    /** Initializes the options builder. */
    public static Builder with() {
@@@ -126,19 -118,13 +131,25 @@@
        options.id = id;
        return this;
      }
 -    
 +
 +    /**
 +     * Set the callback which is used in case of an exception during
 +     * write of the content.
 +     *
 +     * @param writeContentErrorCallback the callback
 +     * @return the builder
 +     */
 +    public Builder writeContentErrorCallback(WriteContentErrorCallback writeContentErrorCallback) {
 +      options.writeContentErrorCallback = writeContentErrorCallback;
 +      return this;
 +    }
 +
+     /** set the replacement String for xml 1.0 unicode controlled characters that are not allowed */
+     public Builder xml10InvalidCharReplacement(final String replacement) {
+       options.xml10InvalidCharReplacement = replacement;
+       return this;
+     } 
+     
      /** Builds the OData serializer options. */
      public EntityCollectionSerializerOptions build() {
        return options;

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/396a39ba/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
----------------------------------------------------------------------
diff --cc lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
index 1a07faa,a72e096..a42e3df
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/serializer/xml/ODataXmlSerializer.java
@@@ -53,8 -51,8 +53,9 @@@ import org.apache.olingo.commons.api.ed
  import org.apache.olingo.commons.api.edm.FullQualifiedName;
  import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
  import org.apache.olingo.commons.api.ex.ODataErrorDetail;
 +import org.apache.olingo.commons.api.ex.ODataRuntimeException;
  import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+ import org.apache.olingo.commons.core.edm.primitivetype.EdmString;
  import org.apache.olingo.server.api.ODataServerError;
  import org.apache.olingo.server.api.ServiceMetadata;
  import org.apache.olingo.server.api.serializer.ComplexSerializerOptions;
@@@ -345,10 -338,11 +348,11 @@@ public class ODataXmlSerializer extend
    }
  
    protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
 -      final EntityCollection entitySet, final ExpandOption expand, final SelectOption select,
 +      final AbstractEntityCollection entitySet, final ExpandOption expand, final SelectOption select,
-       final XMLStreamWriter writer) throws XMLStreamException, SerializerException {
+       final String xml10InvalidCharReplacement,final XMLStreamWriter writer) 
+           throws XMLStreamException, SerializerException {
 -    for (final Entity entity : entitySet.getEntities()) {
 +    for (final Entity entity : entitySet) {
-       writeEntity(metadata, entityType, entity, null, expand, select, writer, false);
+       writeEntity(metadata, entityType, entity, null, expand, select, xml10InvalidCharReplacement, writer, false);
      }
    }