use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method userFavorites.
public void userFavorites(boolean promptLogin, IProgressMonitor monitor) throws CoreException {
final SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_FavoritesRetrieve, 1001);
try {
MarketplaceCategory catalogCategory = findMarketplaceCategory(progress.newChild(1));
catalogCategory.setContents(Contents.USER_FAVORITES);
IUserFavoritesService userFavoritesService = marketplaceService.getUserFavoritesService();
if (userFavoritesService != null) {
try {
applyShellProvider();
ISearchResult result;
if (promptLogin) {
IMarketplaceStorageService storageService = userFavoritesService.getStorageService();
result = storageService.runWithLogin(new Callable<ISearchResult>() {
public ISearchResult call() throws Exception {
return marketplaceService.userFavorites(progress.newChild(500));
}
});
} else {
result = marketplaceService.userFavorites(progress.newChild(500));
}
if (result.getNodes().isEmpty()) {
catalogCategory = addPopularItems(progress.newChild(500));
addNoFavoritesItem(catalogCategory);
} else {
handleSearchResult(catalogCategory, result, progress.newChild(500));
}
} catch (NotAuthorizedException e) {
catalogCategory = addPopularItems(progress.newChild(500));
addUserStorageLoginItem(catalogCategory, e.getLocalizedMessage());
} catch (UnsupportedOperationException ex) {
catalogCategory = addPopularItems(progress.newChild(500));
addFavoritesNotSupportedItem(catalogCategory);
} catch (Exception ex) {
// FIXME we should use the wizard page's status line to show errors, but that's unreachable from here...
MarketplaceClientCore.error(Messages.MarketplaceDiscoveryStrategy_FavoritesRetrieveError, ex);
addRetryErrorItem(catalogCategory, ex);
}
} else {
catalogCategory = addPopularItems(progress.newChild(1000));
addFavoritesNotSupportedItem(catalogCategory);
}
} finally {
monitor.done();
}
}
Aggregations