Search in sources :

Example 16 with Node

use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategy method installErrorReport.

public void installErrorReport(IProgressMonitor monitor, IStatus result, Set<CatalogItem> items, IInstallableUnit[] operationIUs, String resolutionDetails) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_sendingErrorNotification, 100);
    try {
        Set<Node> nodes = new HashSet<Node>();
        for (CatalogItem item : items) {
            Object data = item.getData();
            if (data instanceof INode) {
                nodes.add((Node) data);
            }
        }
        Set<String> iuIdsAndVersions = new HashSet<String>();
        for (IInstallableUnit iu : operationIUs) {
            String id = iu.getId();
            String version = iu.getVersion() == null ? null : iu.getVersion().toString();
            // $NON-NLS-1$
            iuIdsAndVersions.add(id + "," + version);
        }
        marketplaceService.reportInstallError(result, nodes, iuIdsAndVersions, resolutionDetails, progress);
    } finally {
        progress.done();
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) 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) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Example 17 with Node

use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategy method performNodeQuery.

private ISearchResult performNodeQuery(String nodeUrl, IProgressMonitor progress) throws CoreException {
    final INode[] queryNode = new INode[1];
    MarketplaceUrlHandler urlHandler = new MarketplaceUrlHandler() {

        @Override
        protected boolean handleNode(CatalogDescriptor descriptor, String url, INode node) {
            queryNode[0] = node;
            return true;
        }
    };
    if (urlHandler.handleUri(nodeUrl) && queryNode[0] != null) {
        INode node = marketplaceService.getNode(queryNode[0], progress);
        SearchResult result = new SearchResult();
        result.setMatchCount(1);
        result.setNodes(Collections.singletonList((Node) node));
        return result;
    }
    return null;
}
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) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) SearchResult(org.eclipse.epp.internal.mpc.core.model.SearchResult) MarketplaceUrlHandler(org.eclipse.epp.mpc.ui.MarketplaceUrlHandler) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 18 with Node

use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.

the class MarketplaceInfo method computeInstalledNodes.

/**
 * Calculate the known catalog nodes that might be installed. Since no remote query should happen, this only checks
 * if any one of the IUs for a node are installed.
 *
 * @param repositoryUrl
 *            the catalog url for which installed nodes should be computed
 * @param installedIus
 *            all of the currently installed IUs
 * @return a set of node ids, or an empty set if there are no known installed nodes
 * @deprecated use {@link #computeInstalledNodes(URL, Map)} instead
 */
@Deprecated
public synchronized Set<INode> computeInstalledNodes(URL repositoryUrl, Set<String> installedIus) {
    Set<INode> nodes = new HashSet<INode>();
    String keyPrefix = computeUrlKey(repositoryUrl) + '#';
    for (Map.Entry<String, List<String>> entry : nodeKeyToIU.entrySet()) {
        if (entry.getKey().startsWith(keyPrefix)) {
            List<String> ius = nodeKeyToIU.get(entry.getKey());
            if (computeInstalled(installedIus, ius, false)) {
                String nodeId = entry.getKey().substring(keyPrefix.length());
                Node node = new Node();
                node.setId(nodeId);
                nodes.add(node);
            }
        }
    }
    return 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) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 19 with Node

use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.

the class MarketplaceInfoTest method createTestItem.

public static MarketplaceNodeCatalogItem createTestItem() throws Exception {
    MarketplaceNodeCatalogItem item = new MarketplaceNodeCatalogItem();
    item.setMarketplaceUrl(new URL("http://marketplace.eclipse.org"));
    item.setId("123");
    Node node = new Node();
    node.setId(item.getId());
    node.setUrl("http://marketplace.eclipse.org/node/" + node.getId());
    node.setIus(new Ius());
    addIu(node, "com.example.test.a1");
    addIu(node, "com.example.test.a2");
    item.setData(node);
    item.setInstallableUnits(node.getIus().getIu());
    return item;
}
Also used : Ius(org.eclipse.epp.internal.mpc.core.model.Ius) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) URL(java.net.URL)

Example 20 with Node

use of org.eclipse.epp.internal.mpc.core.model.Node in project epp.mpc by eclipse.

the class MarketplaceCatalogTest method setupNodes.

protected void setupNodes() {
    Node node = new Node();
    node.setName("Not installed");
    node.setId("1001");
    node.setIus(new Ius());
    node.getIus().getIuElements().add(new Iu("org.example.notinstalled.iu"));
    discoveryNodes.add(node);
    node = new Node();
    node.setName("Up to date");
    node.setId("1002");
    node.setIus(new Ius());
    node.getIus().getIuElements().add(new Iu("org.example.installed.iu"));
    discoveryNodes.add(node);
    installedNodes.add(node);
    node = new Node();
    node.setName("Update available");
    node.setId("1003");
    node.setIus(new Ius());
    node.getIus().getIuElements().add(new Iu("org.example.updateable.iu"));
    discoveryNodes.add(node);
    installedNodes.add(node);
    updateAvailable.add(node);
}
Also used : Ius(org.eclipse.epp.internal.mpc.core.model.Ius) IIus(org.eclipse.epp.mpc.core.model.IIus) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) Iu(org.eclipse.epp.internal.mpc.core.model.Iu) IIu(org.eclipse.epp.mpc.core.model.IIu)

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