.getPreferenceStore().getString(PreferenceConstants.P_RESULTS));
supplInf.put("NumResults", "#" + numResults);
try {
WSConnection ws = new WSConnection(serverLocation);
String session = "";
try {
logger.debug("Initialize search for " + numResults
+ " components at " + serverLocation + ".");
session = ws.initComponentSearch(query.getMqlQuery(), username,
password, numResults);
logger.debug("Received session id: " + session);
} catch (IOException_Exception e) {
CrashReporter.reportException(e);
logger.debug("Problem initializing search: "
+ e.getLocalizedMessage());
}
if (session.equals("Invalid Username or Password")) {
notifySearchEventListeners(SearchEvent.INVALID_USER);
return Status.CANCEL_STATUS;
}
notifySearchEventListeners(SearchEvent.STARTED);
// Wait for results
int loop = 0;
while (!ws.isFinished()) {
if (monitor.isCanceled()) {
logger.debug("Enable searching again.");
notifySearchEventListeners(SearchEvent.CANCELLED);
return Status.CANCEL_STATUS;
}
logger.debug("Search still in progress... #" + result.size());
// Sleep timer increases with every iteration to a 10s maximum.
int sleep = Math.min(500 * loop++, 10000);
logger.debug("Sleep for " + ((double) sleep / 1000)
+ " seconds.");
Thread.sleep(sleep);
}
// Store results
ArrayList<ResultBean> results = ws.getResults(session);
logger.debug("Webservice returned " + results.size()
+ " results from Merobase.");
result.addResultList(results);
notifySearchEventListeners(SearchEvent.RESULT_ADDED);
monitor.beginTask("Fetch Sourcecode", result.size());
logger.debug("Beginn fetching sourcecode for " + result.size()
+ " results.");
for (ResultItem r : result.getResultItems()) {
String source = null;
try {
source = ws.componentSource(
r.getProperty(ResultProperty.SHORT_URL), username,
password, 10);
} catch (Exception e) {
CrashReporter.reportException(e, supplInf);
logger.debug(e.getLocalizedMessage());