use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class MarketplaceInfoTest method computeInstalledLegacy.
@Test
@SuppressWarnings("deprecation")
public void computeInstalledLegacy() throws Exception {
Node node = (Node) item.getData();
assertTrue(item.getInstallableUnits().size() > 1);
assertEquals(0, catalogRegistry.getNodeKeyToIU().size());
catalogRegistry.map(item.getMarketplaceUrl(), node);
assertEquals(1, catalogRegistry.getNodeKeyToIU().size());
URI updateUri = new URI("http://update.example.org");
node.setUpdateurl(updateUri.toString());
Set<String> installedIus = new HashSet<String>();
installedIus.addAll(item.getInstallableUnits());
boolean isInstalled = catalogRegistry.computeInstalled(installedIus, Collections.singleton(new URI("http://other.example.org")), node);
assertFalse(isInstalled);
isInstalled = catalogRegistry.computeInstalled(installedIus, Collections.singleton(updateUri), node);
assertTrue(isInstalled);
node.setUpdateurl(null);
isInstalled = catalogRegistry.computeInstalled(installedIus, Collections.singleton(updateUri), node);
assertFalse(isInstalled);
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method performNodeQuery.
public void performNodeQuery(IProgressMonitor monitor, Set<? extends INode> nodes) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_searchingMarketplace, 1001);
try {
MarketplaceCategory catalogCategory = findMarketplaceCategory(progress.newChild(1));
catalogCategory.setContents(Contents.QUERY);
SearchResult result = new SearchResult();
result.setNodes(new ArrayList<Node>());
if (!monitor.isCanceled()) {
if (!nodes.isEmpty()) {
List<INode> resolvedNodes = marketplaceService.getNodes(nodes, progress.newChild(500));
for (INode node : resolvedNodes) {
result.getNodes().add((Node) node);
}
} else {
progress.setWorkRemaining(500);
}
result.setMatchCount(result.getNodes().size());
handleSearchResult(catalogCategory, result, progress.newChild(500));
}
} finally {
monitor.done();
}
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method computeInstalled.
protected SearchResult computeInstalled(IProgressMonitor monitor) throws CoreException {
SearchResult result = new SearchResult();
result.setNodes(new ArrayList<Node>());
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_ComputingInstalled, 1000);
Map<String, IInstallableUnit> installedIUs = computeInstalledIUs(progress.newChild(500));
if (!monitor.isCanceled()) {
Set<INode> catalogNodes = marketplaceInfo.computeInstalledNodes(catalogDescriptor.getUrl(), installedIUs);
if (!catalogNodes.isEmpty()) {
List<INode> resolvedNodes = marketplaceService.getNodes(catalogNodes, progress.newChild(490));
SubMonitor nodeProgress = SubMonitor.convert(progress.newChild(10), resolvedNodes.size());
for (INode node : resolvedNodes) {
// compute real installed state based on optional/required state
if (marketplaceInfo.computeInstalled(installedIUs.keySet(), node)) {
result.getNodes().add((Node) node);
}
nodeProgress.worked(1);
}
} else {
monitor.worked(500);
}
}
return result;
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method performQuery.
public void performQuery(IProgressMonitor monitor, Set<String> nodeIds) throws CoreException {
Set<INode> nodes = new HashSet<INode>();
for (String nodeId : nodeIds) {
Node node = new Node();
node.setId(nodeId);
nodes.add(node);
}
performNodeQuery(monitor, nodes);
}
use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.
the class MarketplaceUrlHandler method handleNodeContent.
private boolean handleNodeContent(CatalogDescriptor descriptor, String url) {
Matcher matcher = CONTENT_URL_PATTERN.matcher(url);
String title = null;
if (matcher.find()) {
title = matcher.group(1);
}
Node node = new Node();
node.setUrl(url);
if (title != null) {
String base = descriptor.getUrl().toExternalForm();
if (!base.endsWith("/")) {
// $NON-NLS-1$
// $NON-NLS-1$
base += "/";
}
int titleEnd = matcher.end();
if (titleEnd > -1) {
// clean the url of other query parameters
node.setUrl(base + url.substring(0, titleEnd));
} else {
// unknown format, leave as-is
node.setUrl(base + url);
}
}
return handleNode(descriptor, url, node);
}
Aggregations