use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method addLoginListener.
public synchronized void addLoginListener(LoginListener loginListener) {
IUserFavoritesService favoritesService = marketplaceService.getUserFavoritesService();
if (favoritesService != null) {
if (loginListeners == null) {
loginListeners = new CopyOnWriteArrayList<LoginListener>();
}
if (!loginListeners.contains(loginListener)) {
loginListeners.add(loginListener);
IMarketplaceStorageService storageService = favoritesService.getStorageService();
storageService.addLoginListener(loginListener);
}
}
}
use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method applyShellProvider.
protected void applyShellProvider() {
IUserFavoritesService userFavoritesService = marketplaceService.getUserFavoritesService();
if (userFavoritesService == null) {
return;
}
IMarketplaceStorageService storageService = userFavoritesService.getStorageService();
if (storageService == null) {
return;
}
IStorage storage = storageService.getStorage();
ICredentialsProvider credentialsProvider = storage.getCredentialsProvider();
if (credentialsProvider instanceof EclipseOAuthCredentialsProvider) {
((EclipseOAuthCredentialsProvider) credentialsProvider).setShell(shellProvider);
}
}
use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method dispose.
@Override
public void dispose() {
List<LoginListener> loginListeners = this.loginListeners;
this.loginListeners = null;
if (loginListeners != null) {
IUserFavoritesService favoritesService = marketplaceService.getUserFavoritesService();
if (favoritesService != null) {
IMarketplaceStorageService storageService = favoritesService.getStorageService();
for (LoginListener loginListener : loginListeners) {
storageService.removeLoginListener(loginListener);
}
}
}
if (source != null) {
source.dispose();
source = null;
}
if (marketplaceInfo != null) {
final MarketplaceInfo fMarketplaceInfo = marketplaceInfo;
new Job(Messages.MarketplaceDiscoveryStrategy_saveMarketplaceInfoJobName) {
{
setSystem(true);
setPriority(SHORT);
setUser(false);
}
@Override
public boolean belongsTo(Object family) {
BundleContext bundleContext = MarketplaceClientUiPlugin.getBundleContext();
MarketplaceClientUiPlugin plugin = MarketplaceClientUiPlugin.getInstance();
return (bundleContext != null && (family == bundleContext || family == bundleContext.getBundle())) || (plugin != null && family == plugin);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
fMarketplaceInfo.save();
} catch (Exception e) {
return MarketplaceClientCore.computeStatus(e, Messages.MarketplaceDiscoveryStrategy_failedToSaveMarketplaceInfo);
}
return Status.OK_STATUS;
}
}.schedule();
marketplaceInfo = null;
}
super.dispose();
}
use of org.eclipse.epp.mpc.core.service.IMarketplaceStorageService 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