aem-core-wcm-components
aem-core-wcm-components copied to clipboard
Embeddable not included in Embed JSON export
Bug present as of version: 2.24.7-SNAPSHOT
When the Embed
component is used with an Embeddable
(e.g. YouTube) the JSON model export does not include the embeddable, and thus omits all relevant details required to render in a non-AEM system.
This can be remediated with the following steps:
- Update
Embeddable
interface to extendComponentExporter
- Update
YouTube
model to specify explicitresourceType
and then add adapters ofEmbeddable.class, ComponentExporter.class
- Add an
isConfigured
function to theEmbeddable
interface - Add the following code to
EmbedImpl
@Override
public @Nullable Embeddable getEmbeddable() {
if (embeddable == null && StringUtils.isNotBlank(embeddableResourceType)) {
Resource embeddableResource = new CoreResourceWrapper(resource, embeddableResourceType);
embeddable = modelFactory.getModelFromWrappedRequest(request, embeddableResource, Embeddable.class);
if (embeddable == null) {
LOGGER.warn("Unable to cast embed {} to embeddable type {}", resource.getPath(), embeddableResourceType);
}
}
return embeddable != null && embeddable.isConfigured() ? embeddable : null;
}