IWidgetInstance instance;
IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
if (widgetId != null){
widgetId = URLDecoder.decode(widgetId, "UTF-8"); //$NON-NLS-1$
_logger.debug("Looking for widget instance with widgetid of " + widgetId);
instance = persistenceManager.findWidgetInstanceByGuid(apiKey, userId, sharedDataKey, widgetId);
} else {
_logger.debug("Looking for widget instance of service type " + serviceType);
instance = persistenceManager.findWidgetInstance(apiKey, userId, sharedDataKey, serviceType);
}
return instance;