}
return page;
}
private void populateRegionWidgets(Page page, List<OmdlWidgetReference> widgetReferences, String regionId ){
Widget raveWidget = null;
for (OmdlWidgetReference widgetReference : widgetReferences){
// try to find if the widget is already installed in rave by its identifier (should be the rave widget url)
logger.info("Found OMDL widget reference ("+widgetReference.getWidgetIdentifier()+")");
raveWidget = widgetService.getWidgetByUrl(widgetReference.getWidgetIdentifier());
// If not found download and install to widget container, then to rave.
if(raveWidget==null){
String providerType = widgetReference.getRaveWidgetTypeFromFormatType();
if(!providerType.equals(null)){
try {
Widget resolvedWidget = widgetResolverService.resolveAndDownloadWidgetMetadata(widgetReference.getWidgetLink(), providerType);
if(resolvedWidget!=null){
// Check again in case the OMDL id attribute is not the same as the one found in the href attribute
if(widgetService.getWidgetByUrl(resolvedWidget.getUrl())==null){
raveWidget = widgetResolverService.addWidget(resolvedWidget);
logger.info("Widget added to rave. ("+raveWidget.getUrl()+")");
}else{
logger.info("Widget was already added to rave. ("+resolvedWidget.getUrl()+")");
}
}
} catch (Exception e) {
logger.error("Problem installing widget: "+ e.getMessage());
throw new RuntimeException(e);