Hi all,

I just commited my enhancement of media resource handling. This commit makes it 
possible to specify an external resource for a media resource for example a 
picture which is not in the OData Server but elsewhere. I wanted to know of you 
what you think about this enhancement.

Here is how it works:
At the EntityProviderWriteProperties we have now two additional fields for a 
mediaResourceSourceKey and mediaResourceTypeKey. If set we will look into the 
data map with this key and use the String we find there as a source link for 
this media resource during serialization.
For example this: <content type="image/jpeg" src="Employees('1')/$value"/> can 
now look like this <content type="image/jpeg" 
src="http://localhost:8080/Image.jpeg"/> if the src key is set and the data map 
is filled accordingly. The content type is filled the same way.

If you want to have a look on how it works I recommend the unit tests which can 
be found here:
org.apache.olingo.odata2.core.ep.producer.AtomEntryProducerTest -> 
serializeWithCustomSrcAttributeOnEmployee
                                                                                
                                                             -> 
serializeWithCustomSrcAndTypeAttributeOnEmployee
org.apache.olingo.odata2.core.ep.producer. JsonEntryEntityProducerTest -> 
serializeWithCustomSrcAttributeOnEmployee
                                                                                
                                                                       -> 
serializeWithCustomSrcAndTypeAttributeOnEmployee

I think this is a good way to improve this and I will write a tutorial which 
shows the usage in detail.

WDYT? Any feedback is welcome :)

Best Regards,
Christian

Reply via email to