* @return the widget instance, or null if there is no matching instance
* @throws UnsupportedEncodingException
*/
public static IWidgetInstance findWidgetInstance(String apiKey, String userId, String sharedDataKey, String widgetId, String serviceType) throws UnsupportedEncodingException{
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;
}