Search in sources :

Example 1 with IUserFavoritesService

use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.

the class MarketplacePage method hasFavoritedTab.

private boolean hasFavoritedTab(ICatalogBranding branding) {
    if (branding.hasFavoritesTab()) {
        return true;
    }
    CatalogDescriptor catalogDescriptor = this.configuration.getCatalogDescriptor();
    if (catalogDescriptor == null) {
        return false;
    }
    URL url = catalogDescriptor.getUrl();
    IUserFavoritesService favoritesService = url == null ? null : ServiceHelper.getMarketplaceServiceLocator().getFavoritesService(url.toString());
    return favoritesService != null;
}
Also used : IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 2 with IUserFavoritesService

use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategy method removeLoginListener.

public synchronized void removeLoginListener(LoginListener loginListener) {
    if (loginListeners != null) {
        loginListeners.remove(loginListener);
    }
    IUserFavoritesService favoritesService = marketplaceService.getUserFavoritesService();
    if (favoritesService != null) {
        IMarketplaceStorageService storageService = favoritesService.getStorageService();
        storageService.removeLoginListener(loginListener);
    }
}
Also used : IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) IMarketplaceStorageService(org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)

Example 3 with IUserFavoritesService

use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.

the class ImportFavoritesPage method performImport.

public void performImport() {
    setErrorMessage(null);
    saveInstallSelected();
    List<MarketplaceNodeCatalogItem> importFavorites = getSelection();
    if (importFavorites.isEmpty()) {
        return;
    }
    final IUserFavoritesService userFavoritesService = findUserFavoritesService();
    if (userFavoritesService == null) {
        return;
    }
    final List<INode> importNodes = new ArrayList<INode>();
    for (MarketplaceNodeCatalogItem item : importFavorites) {
        importNodes.add(item.getData());
    }
    try {
        getContainer().run(true, false, new IRunnableWithProgress() {

            public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    userFavoritesService.getStorageService().runWithLogin(new Callable<Void>() {

                        public Void call() throws Exception {
                            try {
                                userFavoritesService.addFavorites(importNodes, monitor);
                            } catch (NotAuthorizedException e) {
                                setErrorMessage(Messages.ImportFavoritesPage_unauthorizedErrorMessage);
                            } catch (ConflictException e) {
                                setErrorMessage(Messages.ImportFavoritesPage_conflictErrorMessage);
                            }
                            return null;
                        }
                    });
                } catch (Exception e) {
                    throw new InvocationTargetException(e);
                }
            }
        });
    } catch (InvocationTargetException e) {
        Throwable cause = e.getCause();
        MarketplaceClientCore.error(cause);
        setErrorMessage(NLS.bind(Messages.ImportFavoritesPage_unknownErrorMessage, cause));
    } catch (InterruptedException e) {
    // ignore
    }
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) ConflictException(org.eclipse.userstorage.util.ConflictException) ArrayList(java.util.ArrayList) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Callable(java.util.concurrent.Callable) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) ConflictException(org.eclipse.userstorage.util.ConflictException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)

Example 4 with IUserFavoritesService

use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.

the class DefaultMarketplaceService method userFavorites.

public void userFavorites(List<? extends INode> nodes, IProgressMonitor monitor) throws NotAuthorizedException, CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.DefaultMarketplaceService_FavoritesUpdate, 10000);
    IUserFavoritesService userFavoritesService = getUserFavoritesService();
    if (userFavoritesService == null) {
        throw new UnsupportedOperationException();
    }
    if (nodes == null || nodes.isEmpty()) {
        return;
    }
    Set<String> favorites = null;
    try {
        favorites = userFavoritesService == null ? null : userFavoritesService.getFavoriteIds(progress);
    } catch (NotAuthorizedException e) {
        throw e;
    } catch (Exception e) {
        throw new CoreException(MarketplaceClientCore.computeStatus(e, Messages.DefaultMarketplaceService_FavoritesErrorRetrieving));
    } finally {
        for (INode node : nodes) {
            ((Node) node).setUserFavorite(favorites == null ? null : favorites.contains(node.getId()));
        }
    }
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) CoreException(org.eclipse.core.runtime.CoreException) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) SubMonitor(org.eclipse.core.runtime.SubMonitor) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 5 with IUserFavoritesService

use of org.eclipse.epp.mpc.core.service.IUserFavoritesService in project epp.mpc by eclipse.

the class DefaultMarketplaceService method userFavorites.

public ISearchResult userFavorites(URI favoritesUri, IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.DefaultMarketplaceService_FavoritesRetrieve, 10000);
    IUserFavoritesService userFavoritesService = getUserFavoritesService();
    if (userFavoritesService == null) {
        throw new UnsupportedOperationException();
    }
    final List<INode> favorites;
    try {
        favorites = userFavoritesService.getFavorites(favoritesUri, progress.newChild(1000));
    } catch (Exception e) {
        throw new CoreException(MarketplaceClientCore.computeStatus(e, Messages.DefaultMarketplaceService_FavoritesErrorRetrieving));
    }
    progress.setWorkRemaining(9000);
    return resolveFavoriteNodes(favorites, progress.newChild(9000), false);
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) CoreException(org.eclipse.core.runtime.CoreException) SubMonitor(org.eclipse.core.runtime.SubMonitor) IUserFavoritesService(org.eclipse.epp.mpc.core.service.IUserFavoritesService) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) FileNotFoundException(java.io.FileNotFoundException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)20 NotAuthorizedException (org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException)7 IMarketplaceStorageService (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService)7 MalformedURLException (java.net.MalformedURLException)6 INode (org.eclipse.epp.mpc.core.model.INode)6 IOException (java.io.IOException)5 URISyntaxException (java.net.URISyntaxException)5 CoreException (org.eclipse.core.runtime.CoreException)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)4 FileNotFoundException (java.io.FileNotFoundException)3 URL (java.net.URL)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)3 UserFavoritesService (org.eclipse.epp.internal.mpc.core.service.UserFavoritesService)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 NoSuchElementException (java.util.NoSuchElementException)2 Callable (java.util.concurrent.Callable)2 IStatus (org.eclipse.core.runtime.IStatus)2 IMarketplaceService (org.eclipse.epp.mpc.core.service.IMarketplaceService)2 LoginListener (org.eclipse.epp.mpc.core.service.IMarketplaceStorageService.LoginListener)2