in remoting/ide/jumpto/src/org/netbeans/modules/jackpot30/jumpto/RemoteQuery.java [121:166]
private void compute(String text, SearchType searchType, AtomicBoolean cancel) {
Set<FileObject> sources = GlobalPathRegistry.getDefault().getSourceRoots();
for (RemoteIndex ri : RemoteIndex.loadIndices()) {
URL localFolder = ri.getLocalFolder();
FileObject originFolder = localFolder != null ? URLMapper.findFileObject(localFolder) : null;
URI url = computeURL(ri, text, searchType);
if (url == null) continue;
String response = WebUtilities.requestStringResponse(url, cancel);
if (cancel.get()) return;
if (response == null) continue;
Reader r = new StringReader(response);
Collection<R> decoded = new ArrayList<R>();
try {
@SuppressWarnings("unchecked") //XXX: should not trust something got from the network!
Map<String, Collection<P>> objectized = Pojson.load(LinkedHashMap.class, r);
for (Entry<String, Collection<P>> e : objectized.entrySet()) {
if (originFolder != null && sources.contains(originFolder.getFileObject(e.getKey()))) continue;
for (P data : e.getValue()) {
decoded.add(decode(ri, e.getKey(), data));
}
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
continue;
} finally {
try {
r.close();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
synchronized (this) {
if (cancel.get()) return;
results.addAll(decoded);
}
}
}