In our DXA (2.0, Java) implementation we have a couple of scenarios where there are component links to items that can be from more than one schema.
Firstly we have a generic Link embedded schema (and corresponding Link model) which, can link to both normal and multimedia components. If its a normal component, we show the link URL, but if its a multimedia component (in this case a Download) then we also want to show the file size and an icon for the type by the link. In order to achieve this we added a
MediaItem linkedMedia property on the Link model, which works fine if the linked item is indeed a multimedia component, but gives exceptions in the logs if it is not. Is there some way to suppress this exception?
Secondly we give the editor the ability to 'embed' linked content. The linked content can be from one of a number of different normal content or multimedia schemas (image, video, data table etc.). For Multimedia content I can create a
MediaItem embeddedMedia property which the DXA will make the appropriate subclass model (Image or Video), but I don't seem to be able to do the same with an abstract
EmbedItem embbededContent superclass for the non-multimedia content types. Is this possible?
I was thinking of making a custom model builder for both cases, but this seems a bit like overkill, and it seems like these are pretty normal scenarios which should be covered by standard model mapping so maybe I am missing something.