Frederic Souchu created OLINGO-615:
--------------------------------------

             Summary: Unable to serialize custom enum type
                 Key: OLINGO-615
                 URL: https://issues.apache.org/jira/browse/OLINGO-615
             Project: Olingo
          Issue Type: Bug
          Components: odata4-server
    Affects Versions: (Java) V4 4.0.0-beta-02
            Reporter: Frederic Souchu


The serializer code path is missing a fallback for enumerated values, similar 
to collection or complex types.

How to reproduce:
- declare an enumerated field in EDM
- add enum value in entity set:
{code:java}
EntitySet entitySet = new EntitySetImpl();
entitySet.getEntities().add(new EntityImpl()
                .addProperty(new PropertyImpl(null, "ID", ValueType.PRIMITIVE, 
4864))
                .addProperty(new PropertyImpl(null, "company.com.MyEnum", 
ValueType.ENUM, 2)));
{code}
- call serializer from servlet, an exception is raised: Property type not yet 
supported!

What is happening:
- EdmTypeInfo.java primitiveType member is null (as expected)
- enumType is correctly set to my custom enum type
- ODataJsonSerializer.java correctly evaluates the type as 'not primitive' and 
does not call the appriopriate writePropertyValue method (where enum 
serialization code is!!)
{code:java}
  private void writePropertyValue(final EdmProperty edmProperty,
      final Property property, final Set<List<String>> selectedPaths,
      final JsonGenerator json) throws IOException, SerializerException {
    try {
      if (edmProperty.isPrimitive()) {
        /* primitive handling code not executed for an enum !! */
      } else if (edmProperty.isCollection()) {
        writeComplexCollection((EdmComplexType) edmProperty.getType(), 
property, selectedPaths, json);
      } else if (property.isLinkedComplex()) {
        writeComplexValue((EdmComplexType) edmProperty.getType(), 
property.asLinkedComplex().getValue(),
            selectedPaths, json);
      } else if (property.isComplex()) {
        writeComplexValue((EdmComplexType) edmProperty.getType(), 
property.asComplex(), selectedPaths, json);
      } else {
        throw new SerializerException("Property type not yet supported!",
            SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, 
edmProperty.getName());
      }
    } catch (final EdmPrimitiveTypeException e) {
      /* error msg mgt */
    }
  }

{code}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to