Search in sources :

Example 1 with Node

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);
}
Also used : Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) URI(java.net.URI) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with Node

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();
    }
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) SubMonitor(org.eclipse.core.runtime.SubMonitor) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) SearchResult(org.eclipse.epp.internal.mpc.core.model.SearchResult)

Example 3 with Node

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;
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) SubMonitor(org.eclipse.core.runtime.SubMonitor) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) SearchResult(org.eclipse.epp.internal.mpc.core.model.SearchResult) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 4 with Node

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);
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) HashSet(java.util.HashSet)

Example 5 with Node

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);
}
Also used : Matcher(java.util.regex.Matcher) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode)

Aggregations

Node (org.eclipse.epp.internal.mpc.core.model.Node)20 INode (org.eclipse.epp.mpc.core.model.INode)19 SubMonitor (org.eclipse.core.runtime.SubMonitor)5 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)5 HashSet (java.util.HashSet)4 CoreException (org.eclipse.core.runtime.CoreException)4 SearchResult (org.eclipse.epp.internal.mpc.core.model.SearchResult)4 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)3 FileNotFoundException (java.io.FileNotFoundException)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 Matcher (java.util.regex.Matcher)2 Ius (org.eclipse.epp.internal.mpc.core.model.Ius)2 ICategory (org.eclipse.epp.mpc.core.model.ICategory)2 IMarketplaceService (org.eclipse.epp.mpc.core.service.IMarketplaceService)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1