comparison rdf/PluginRDFIndexer.cpp @ 1272:6a7ea3bd0e10

Send RDF-indexer warnings to debug rather than cerr
author Chris Cannam
date Mon, 21 Nov 2016 16:32:58 +0000
parents f5cd33909744
children 70e172e6cc59
comparison
equal deleted inserted replaced
1205:16955f929d37 1272:6a7ea3bd0e10
19 #include "data/fileio/FileSource.h" 19 #include "data/fileio/FileSource.h"
20 #include "data/fileio/PlaylistFileReader.h" 20 #include "data/fileio/PlaylistFileReader.h"
21 #include "plugin/PluginIdentifier.h" 21 #include "plugin/PluginIdentifier.h"
22 22
23 #include "base/Profiler.h" 23 #include "base/Profiler.h"
24 #include "base/Debug.h"
24 25
25 #include <vamp-hostsdk/PluginHostAdapter.h> 26 #include <vamp-hostsdk/PluginHostAdapter.h>
26 27
27 #include <dataquay/BasicStore.h> 28 #include <dataquay/BasicStore.h>
28 #include <dataquay/RDFException.h> 29 #include <dataquay/RDFException.h>
82 void 83 void
83 PluginRDFIndexer::indexInstalledURLs() 84 PluginRDFIndexer::indexInstalledURLs()
84 { 85 {
85 vector<string> paths = PluginHostAdapter::getPluginPath(); 86 vector<string> paths = PluginHostAdapter::getPluginPath();
86 87
87 // cerr << "\nPluginRDFIndexer::indexInstalledURLs: pid is " << getpid() << endl; 88 // SVDEBUG << "\nPluginRDFIndexer::indexInstalledURLs: pid is " << getpid() << endl;
88 89
89 QStringList filters; 90 QStringList filters;
90 filters << "*.ttl"; 91 filters << "*.ttl";
91 filters << "*.TTL"; 92 filters << "*.TTL";
92 filters << "*.n3"; 93 filters << "*.n3";
206 // the uri as a document URL and reading that if possible. 207 // the uri as a document URL and reading that if possible.
207 208
208 // Because we may want to refer to this document again, we 209 // Because we may want to refer to this document again, we
209 // cache it locally if it turns out to exist. 210 // cache it locally if it turns out to exist.
210 211
211 cerr << "PluginRDFIndexer::getIdForPluginURI: NOTE: Failed to find a local RDF document describing plugin <" << uri << ">: attempting to retrieve one remotely by guesswork" << endl; 212 SVDEBUG << "PluginRDFIndexer::getIdForPluginURI: NOTE: Failed to find a local RDF document describing plugin <" << uri << ">: attempting to retrieve one remotely by guesswork" << endl;
212 213
213 QString baseUrl = QUrl(uri).toString(QUrl::RemoveFragment); 214 QString baseUrl = QUrl(uri).toString(QUrl::RemoveFragment);
214 215
215 indexURL(baseUrl); 216 indexURL(baseUrl);
216 217
259 bool 260 bool
260 PluginRDFIndexer::pullURL(QString urlString) 261 PluginRDFIndexer::pullURL(QString urlString)
261 { 262 {
262 Profiler profiler("PluginRDFIndexer::indexURL"); 263 Profiler profiler("PluginRDFIndexer::indexURL");
263 264
264 // cerr << "PluginRDFIndexer::indexURL(" << urlString << ")" << endl; 265 // SVDEBUG << "PluginRDFIndexer::indexURL(" << urlString << ")" << endl;
265 266
266 QMutexLocker locker(&m_mutex); 267 QMutexLocker locker(&m_mutex);
267 268
268 QUrl local = urlString; 269 QUrl local = urlString;
269 270
287 } 288 }
288 289
289 try { 290 try {
290 m_index->import(local, BasicStore::ImportFailOnDuplicates); 291 m_index->import(local, BasicStore::ImportFailOnDuplicates);
291 } catch (RDFDuplicateImportException &e) { 292 } catch (RDFDuplicateImportException &e) {
292 cerr << e.what() << endl; 293 SVDEBUG << e.what() << endl;
293 cerr << "PluginRDFIndexer::pullURL: Document at " << urlString 294 SVDEBUG << "PluginRDFIndexer::pullURL: Document at " << urlString
294 << " duplicates triples found in earlier loaded document -- skipping it" << endl; 295 << " duplicates triples found in earlier loaded document -- skipping it" << endl;
295 return false; 296 return false;
296 } catch (RDFException &e) { 297 } catch (RDFException &e) {
297 cerr << e.what() << endl; 298 SVDEBUG << e.what() << endl;
298 cerr << "PluginRDFIndexer::pullURL: Failed to import document from " 299 SVDEBUG << "PluginRDFIndexer::pullURL: Failed to import document from "
299 << urlString << ": " << e.what() << endl; 300 << urlString << ": " << e.what() << endl;
300 return false; 301 return false;
301 } 302 }
302 return true; 303 return true;
303 } 304 }
304 305
313 bool addedSomething = false; 314 bool addedSomething = false;
314 315
315 foreach (Node plugin, plugins) { 316 foreach (Node plugin, plugins) {
316 317
317 if (plugin.type != Node::URI) { 318 if (plugin.type != Node::URI) {
318 cerr << "PluginRDFIndexer::reindex: Plugin has no URI: node is " 319 SVDEBUG << "PluginRDFIndexer::reindex: Plugin has no URI: node is "
319 << plugin << endl; 320 << plugin << endl;
320 continue; 321 continue;
321 } 322 }
322 323
323 Node idn = m_index->complete 324 Node idn = m_index->complete
324 (Triple(plugin, m_index->expand("vamp:identifier"), Node())); 325 (Triple(plugin, m_index->expand("vamp:identifier"), Node()));
325 326
326 if (idn.type != Node::Literal) { 327 if (idn.type != Node::Literal) {
327 cerr << "PluginRDFIndexer::reindex: Plugin " << plugin 328 SVDEBUG << "PluginRDFIndexer::reindex: Plugin " << plugin
328 << " lacks vamp:identifier literal" << endl; 329 << " lacks vamp:identifier literal" << endl;
329 continue; 330 continue;
330 } 331 }
331 332
332 Node libn = m_index->complete 333 Node libn = m_index->complete
333 (Triple(Node(), m_index->expand("vamp:available_plugin"), plugin)); 334 (Triple(Node(), m_index->expand("vamp:available_plugin"), plugin));
334 335
335 if (libn.type != Node::URI) { 336 if (libn.type != Node::URI) {
336 cerr << "PluginRDFIndexer::reindex: Plugin " << plugin 337 SVDEBUG << "PluginRDFIndexer::reindex: Plugin " << plugin
337 << " is not vamp:available_plugin in any library" << endl; 338 << " is not vamp:available_plugin in any library" << endl;
338 continue; 339 continue;
339 } 340 }
340 341
341 Node son = m_index->complete 342 Node son = m_index->complete
342 (Triple(libn, m_index->expand("vamp:identifier"), Node())); 343 (Triple(libn, m_index->expand("vamp:identifier"), Node()));
343 344
344 if (son.type != Node::Literal) { 345 if (son.type != Node::Literal) {
345 cerr << "PluginRDFIndexer::reindex: Library " << libn 346 SVDEBUG << "PluginRDFIndexer::reindex: Library " << libn
346 << " lacks vamp:identifier for soname" << endl; 347 << " lacks vamp:identifier for soname" << endl;
347 continue; 348 continue;
348 } 349 }
349 350
350 QString pluginUri = plugin.value; 351 QString pluginUri = plugin.value;
364 365
365 addedSomething = true; 366 addedSomething = true;
366 367
367 if (pluginUri != "") { 368 if (pluginUri != "") {
368 if (m_uriToIdMap.find(pluginUri) != m_uriToIdMap.end()) { 369 if (m_uriToIdMap.find(pluginUri) != m_uriToIdMap.end()) {
369 cerr << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl; 370 SVDEBUG << "PluginRDFIndexer::reindex: WARNING: Found multiple plugins with the same URI:" << endl;
370 cerr << " 1. Plugin id \"" << m_uriToIdMap[pluginUri] << "\"" << endl; 371 SVDEBUG << " 1. Plugin id \"" << m_uriToIdMap[pluginUri] << "\"" << endl;
371 cerr << " 2. Plugin id \"" << pluginId << "\"" << endl; 372 SVDEBUG << " 2. Plugin id \"" << pluginId << "\"" << endl;
372 cerr << "both claim URI <" << pluginUri << ">" << endl; 373 SVDEBUG << "both claim URI <" << pluginUri << ">" << endl;
373 } else { 374 } else {
374 m_uriToIdMap[pluginUri] = pluginId; 375 m_uriToIdMap[pluginUri] = pluginId;
375 } 376 }
376 } 377 }
377 } 378 }
378 379
379 if (!foundSomething) { 380 if (!foundSomething) {
380 cerr << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl; 381 SVDEBUG << "PluginRDFIndexer::reindex: NOTE: Plugins found, but none sufficiently described" << endl;
381 } 382 }
382 383
383 return addedSomething; 384 return addedSomething;
384 } 385 }