Search in sources :

Example 16 with IMarket

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

the class MarketplaceDiscoveryStrategy method resolveCategory.

private static ICategory resolveCategory(ICategory category, List<? extends IMarket> markets) throws IllegalArgumentException, NoSuchElementException {
    if (category != null && category.getId() == null) {
        // need to resolve
        if (category.getUrl() == null && category.getName() == null) {
            throw new IllegalArgumentException(NLS.bind(Messages.MarketplaceDiscoveryStrategy_unidentifiableItem, category));
        }
        for (IMarket market : markets) {
            List<? extends ICategory> categories = market.getCategory();
            ICategory resolved = resolve(category, categories);
            if (resolved != null) {
                return resolved;
            }
        }
        if (category.getUrl() != null) {
            throw new NoSuchElementException(NLS.bind(Messages.MarketplaceDiscoveryStrategy_noUrlMatch, category.getUrl()));
        } else {
            throw new NoSuchElementException(NLS.bind(Messages.MarketplaceDiscoveryStrategy_noNameMatch, category.getName()));
        }
    }
    return category;
}
Also used : ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarket(org.eclipse.epp.mpc.core.model.IMarket) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

IMarket (org.eclipse.epp.mpc.core.model.IMarket)16 ICategory (org.eclipse.epp.mpc.core.model.ICategory)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)3 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 NoSuchElementException (java.util.NoSuchElementException)2 DefaultMarketplaceService (org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService)2 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)2 CatalogFilter (org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter)2 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 HashSet (java.util.HashSet)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)1 Node (org.eclipse.epp.internal.mpc.core.model.Node)1 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)1