use of org.eclipse.epp.mpc.core.model.INode 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()));
}
}
}
use of org.eclipse.epp.mpc.core.model.INode 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);
}
use of org.eclipse.epp.mpc.core.model.INode in project epp.mpc by eclipse.
the class CachingMarketplaceService method getNodes.
public List<INode> getNodes(Collection<? extends INode> nodes, IProgressMonitor monitor) throws CoreException {
Map<INode, INode> resolvedNodes = new LinkedHashMap<INode, INode>();
List<INode> unresolvedNodes = new ArrayList<INode>();
for (INode node : nodes) {
if (!mapCachedNode(node, resolvedNodes)) {
unresolvedNodes.add(node);
}
}
if (!unresolvedNodes.isEmpty()) {
List<INode> newResolvedNodes = delegate.getNodes(unresolvedNodes, monitor);
for (INode node : newResolvedNodes) {
cacheNode(node);
}
for (INode node : unresolvedNodes) {
mapCachedNode(node, resolvedNodes);
}
}
List<INode> result = new ArrayList<INode>(nodes.size());
for (INode node : nodes) {
INode resolvedNode = resolvedNodes.get(node);
if (resolvedNode != null) {
result.add(resolvedNode);
}
}
return result;
}
use of org.eclipse.epp.mpc.core.model.INode in project epp.mpc by eclipse.
the class CachingMarketplaceService method getNode.
public INode getNode(INode node, IProgressMonitor monitor) throws CoreException {
String nodeKey = computeNodeKey(node);
INode nodeResult = null;
if (nodeKey != null) {
nodeResult = getCached(nodeKey, INode.class);
}
if (nodeResult == null) {
String nodeUrlKey = computeNodeUrlKey(node);
if (nodeUrlKey != null) {
nodeResult = getCached(nodeUrlKey, INode.class);
}
}
if (nodeResult == null) {
nodeResult = delegate.getNode(node, monitor);
if (nodeResult != null) {
cacheNode(nodeResult);
}
}
return nodeResult;
}
use of org.eclipse.epp.mpc.core.model.INode in project epp.mpc by eclipse.
the class CachingMarketplaceService method related.
public ISearchResult related(final List<? extends INode> basedOn, IProgressMonitor monitor) throws CoreException {
String searchKey = null;
if (basedOn != null && !basedOn.isEmpty()) {
StringBuilder searchKeyBldr = new StringBuilder();
for (INode node : basedOn) {
searchKeyBldr.append(node.getId()).append('+');
}
searchKey = searchKeyBldr.substring(0, searchKeyBldr.length() - 1);
}
// $NON-NLS-1$
String key = computeSearchKey("related", null, null, searchKey);
return performSearch(monitor, key, new SearchOperation() {
public ISearchResult doSearch(IProgressMonitor monitor) throws CoreException {
return delegate.related(basedOn, monitor);
}
});
}
Aggregations