Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
V2 2.0.13
-
None
-
None
Description
When reading from OData 2.0 services that use syndication fields in Atom format, such as the example service's "Products" collection at https://services.odata.org/V2/OData/OData.svc/Products, we can see the title and summary syndication fields used for entity properties Name and Description:
<Property Name="Name" Type="Edm.String" Nullable="true" m:FC_TargetPath="SyndicationTitle" m:FC_ContentKind="text" m:FC_KeepInContent="false"/> <Property Name="Description" Type="Edm.String" Nullable="true" m:FC_TargetPath="SyndicationSummary" m:FC_ContentKind="text" m:FC_KeepInContent="false"/>
And when calling the service, indeed we get data like:
<title type="text">Bread</title> <summary type="text">Whole grain bread</summary>
But the current version of olingo-odata2 (2.0.13) is unable to read these fields, reading them as null instead.
The reason seems be a mismatch when trying to translate the field name: The XmlEntryConsumer class uses EntityInfoAggregator at the beginning of its readCustomElement(...) method in order to obtain possible targetPathInfo for the field being read:
private void readCustomElement(..., final EntityInfoAggregator eia,...) { EntityPropertyInfo targetPathInfo = eia.getTargetPathInfo(tagName); ... }
Note that, for the data XML above, tagName will have value "title".
Inside EntityInfoAggregator, all that the getTargetPathInfo(...) method does is attempt translation by using a map called targetPath2EntityPropertyInfo:
public EntityPropertyInfo getTargetPathInfo(final String targetPath) { return targetPath2EntityPropertyInfo.get(targetPath); }
But unfortunately, the targetPath2EntityPropertyInfo map has not been initialized with "title" as key, but instead with EdmTargetPath.SYNDICATION_TITLE, which value is "SyndicationTitle".
This causes the map to never map any syndication field, and therefore olingo-odata2 reads all syndication fields as null.
I could provide a PR for this if necessary, but I see this targetPath2EntityPropertyInfo map is also used when producing Atom, not only consuming it, and I fear that applying a normalisation operation on the name of the tag that simply allows "title" to match "SyndicationTitle" may break other things.
Any indications on the preferred way this should be fixed and in which class?