// attempt to get specific widget by id
IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
IWidget widget = persistenceManager.findById(IWidget.class, resourceId);
// support queries by type
if (widget == null) {
IWidgetService[] services = persistenceManager.findByValue(IWidgetService.class, "serviceName", resourceId);
if (services != null && services.length == 1) {
IWidget[] widgets = persistenceManager.findWidgetsByType(resourceId);
returnXml(WidgetHelper.createXMLWidgetsDocument(widgets, getLocalPath(request), getLocales(request)),response);
return;
}