Search in sources :

Example 1 with ICategories

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

the class UnmarshallerTest method search.

@Test
public void search() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/api/v2/search/apachesolr_search/test?filters=tid:16%20tid:31
    Object model = processResource("resources/search.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    Search search = marketplace.getSearch();
    assertNotNull(search);
    assertEquals("test", search.getTerm());
    assertEquals("http://www.eclipseplugincentral.net/search/apachesolr/test?filters=tid%3A16%20tid%3A31", search.getUrl());
    assertEquals(Integer.valueOf(62), search.getCount());
    assertEquals(7, search.getNode().size());
    INode node = search.getNode().get(0);
    assertEquals("983", node.getId());
    assertEquals("Run All Tests", node.getName());
    assertEquals("http://www.eclipseplugincentral.net/content/run-all-tests", node.getUrl());
    assertEquals("resource", node.getType());
    ICategories categories = node.getCategories();
    assertNotNull(categories);
    assertEquals(1, categories.getCategory().size());
    ICategory category = categories.getCategory().get(0);
    assertEquals("16", category.getId());
    assertEquals("Testing", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/16", category.getUrl());
    assertEquals("ipreuss", node.getOwner());
    assertNotNull(node.getBody());
    assertEquals("Allows the execution of JUnit tests for several projects at once.", node.getBody());
    assertTrue(!node.getFoundationmember());
    assertEquals("https://sourceforge.net/projects/e-rat/", node.getHomepageurl());
    assertNull(node.getImage());
    assertEquals("1.0.1", node.getVersion());
    assertEquals("Other", node.getLicense());
    assertEquals("Ilja Preu\u00DF", node.getCompanyname());
    assertEquals("Production/Stable", node.getStatus());
    assertEquals("3.5", node.getEclipseversion());
    assertEquals("https://sourceforge.net/projects/e-rat/support", node.getSupporturl());
    assertEquals("http://e-rat.sf.net/updatesite", node.getUpdateurl());
    assertEquals(Integer.valueOf(136), node.getFavorited());
    assertEquals(Integer.valueOf(299995), node.getInstallsTotal());
    assertEquals(Integer.valueOf(34540), node.getInstallsRecent());
    INode lastNode = search.getNode().get(search.getNode().size() - 1);
    assertEquals("1011", lastNode.getId());
    assertEquals("JUnit Flux", lastNode.getName());
    assertNull(lastNode.getFavorited());
    assertNull(lastNode.getInstallsTotal());
    assertNull(lastNode.getInstallsRecent());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) INode(org.eclipse.epp.mpc.core.model.INode) ICategories(org.eclipse.epp.mpc.core.model.ICategories) Search(org.eclipse.epp.internal.mpc.core.model.Search) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Test(org.junit.Test)

Example 2 with ICategories

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

the class UnmarshallerTest method recent.

@Test
public void recent() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/featured/top/api/p
    Object model = processResource("resources/recent.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    Recent recent = marketplace.getRecent();
    assertNotNull(recent);
    assertEquals(Integer.valueOf(6), recent.getCount());
    assertEquals(6, recent.getNode().size());
    INode node = recent.getNode().get(0);
    assertEquals("1091", node.getId());
    assertEquals("API Demonstration Listing", node.getName());
    assertEquals("http://www.eclipseplugincentral.net/content/api-demonstration-listing", node.getUrl());
    assertEquals("resource", node.getType());
    ICategories categories = node.getCategories();
    assertNotNull(categories);
    assertEquals(6, categories.getCategory().size());
    ICategory category = categories.getCategory().get(0);
    assertEquals("3", category.getId());
    assertEquals("Database", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/3", category.getUrl());
    category = categories.getCategory().get(5);
    assertEquals("38", category.getId());
    assertEquals("Mylyn Connectors", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/category/categories/mylyn-connectors", category.getUrl());
    assertEquals("admin", node.getOwner());
    assertEquals(Integer.valueOf(0), node.getFavorited());
    assertNotNull(node.getBody());
    assertTrue(node.getBody().startsWith("Lorem ipsum dolor"));
    assertTrue(node.getBody().endsWith("vitae aliquam lectus."));
    assertTrue(node.getFoundationmember());
    assertEquals("http://marketplace.eclipse.org/xmlapi", node.getHomepageurl());
    assertEquals("http://marketplace.eclipse.org/sites/default/files/equinox.png", node.getImage());
    assertEquals("1.0", node.getVersion());
    assertEquals("EPL", node.getLicense());
    assertEquals("Eclipse Foundation Inc.", node.getCompanyname());
    assertEquals("Mature", node.getStatus());
    assertEquals("3.5", node.getEclipseversion());
    assertEquals("http://marketplace.eclipse.org/support", node.getSupporturl());
    assertEquals("http://update.eclipse.org/marketplace", node.getUpdateurl());
    {
        String[] expectedIus = new String[] { "org.eclipse.one.one", "org.eclipse.one.two", "org.eclipse.two.one", "org.eclipse.three.one" };
        assertNotNull(node.getIus());
        assertEquals(expectedIus.length, node.getIus().getIu().size());
        for (int x = 0; x < expectedIus.length; ++x) {
            assertEquals(expectedIus[x], node.getIus().getIu().get(x));
        }
    }
    {
        String[] expectedPlatforms = new String[] { "Windows", "Mac", "Linux/GTK" };
        assertNotNull(node.getPlatforms());
        assertEquals(expectedPlatforms.length, node.getPlatforms().getPlatform().size());
        for (int x = 0; x < expectedPlatforms.length; ++x) {
            assertEquals(expectedPlatforms[x], node.getPlatforms().getPlatform().get(x));
        }
    }
}
Also used : Recent(org.eclipse.epp.internal.mpc.core.model.Recent) Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) INode(org.eclipse.epp.mpc.core.model.INode) ICategories(org.eclipse.epp.mpc.core.model.ICategories) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Test(org.junit.Test)

Example 3 with ICategories

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

the class UnmarshallerTest method favorites.

@Test
public void favorites() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/favorites/top/api/p
    Object model = processResource("resources/favorites.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    Favorites favorites = marketplace.getFavorites();
    assertNotNull(favorites);
    assertEquals(Integer.valueOf(6), favorites.getCount());
    assertEquals(6, favorites.getNode().size());
    INode node = favorites.getNode().get(0);
    assertEquals("206", node.getId());
    assertEquals("Mylyn", node.getName());
    assertEquals("http://www.eclipseplugincentral.net/content/mylyn", node.getUrl());
    assertEquals("resource", node.getType());
    ICategories categories = node.getCategories();
    assertNotNull(categories);
    assertEquals(1, categories.getCategory().size());
    ICategory category = categories.getCategory().get(0);
    assertEquals("18", category.getId());
    assertEquals("UI", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/18", category.getUrl());
    assertEquals("Robert Elves", node.getOwner());
    assertEquals(Integer.valueOf(16), node.getFavorited());
    assertNotNull(node.getBody());
    assertEquals("Mylyn is a task-focused interface for Eclipse that reduces information overload and makes multi-tasking easy. It does this by making tasks a first class part of Eclipse, and integrating rich and offline editing for repositories such as Bugzilla, Trac, and JIRA. Once your tasks are integrated, Mylyn monitors your work activity to identify information relevant to the task-at-hand, and uses this task context to focus the Eclipse UI on the interesting information, hide the uninteresting, and automatically find what&#039;s related. This puts the information you need to get work done at your fingertips and improves productivity by reducing searching, scrolling, and navigation. By making task context explicit Mylyn also facilitates multitasking, planning, reusing past efforts, and sharing expertise. ", node.getBody());
    assertTrue(node.getFoundationmember());
    assertEquals("http://eclipse.org/mylyn", node.getHomepageurl());
    assertEquals("http://www.eclipse.org/mylyn/images/image-epic.gif", node.getImage());
    assertEquals("3.3", node.getVersion());
    assertEquals("EPL", node.getLicense());
    assertEquals("Eclipse.org", node.getCompanyname());
    assertEquals("Production/Stable", node.getStatus());
    assertEquals("3.5, 3.4 and 3.3", node.getEclipseversion());
    assertEquals("http://eclipse.org/mylyn/community/", node.getSupporturl());
    assertEquals("http://download.eclipse.org/tools/mylyn/update/e3.4", node.getUpdateurl());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) INode(org.eclipse.epp.mpc.core.model.INode) ICategories(org.eclipse.epp.mpc.core.model.ICategories) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Favorites(org.eclipse.epp.internal.mpc.core.model.Favorites) Test(org.junit.Test)

Example 4 with ICategories

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

the class UnmarshallerTest method featured.

@Test
public void featured() throws IOException, UnmarshalException {
    // from http://www.eclipseplugincentral.net/api/v2/featured
    Object model = processResource("resources/featured.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    Featured featured = marketplace.getFeatured();
    assertNotNull(featured);
    assertEquals(Integer.valueOf(6), featured.getCount());
    assertEquals(6, featured.getNode().size());
    INode node = featured.getNode().get(0);
    assertEquals("248", node.getId());
    assertEquals("eUML2 free edition", node.getName());
    assertEquals("http://www.eclipseplugincentral.net/content/euml2-free-edition", node.getUrl());
    assertEquals("resource", node.getType());
    ICategories categories = node.getCategories();
    assertNotNull(categories);
    assertEquals(1, categories.getCategory().size());
    ICategory category = categories.getCategory().get(0);
    assertEquals("19", category.getId());
    assertEquals("UML", category.getName());
    assertEquals("http://www.eclipseplugincentral.net/taxonomy/term/19", category.getUrl());
    assertEquals("Yves YANG", node.getOwner());
    assertEquals(Integer.valueOf(0), node.getFavorited());
    assertNotNull(node.getBody());
    // bug 303149		assertTrue(node.getBody().startsWith("<P><STRONG>eUML2 for Java<"));
    // bug 303149		assertTrue(node.getBody().endsWith("</LI></UL>"));
    assertTrue(node.getFoundationmember());
    assertEquals("http://www.soyatec.com/", node.getHomepageurl());
    assertEquals("http://www.soyatec.com/euml2/images/product_euml2_110x80.png", node.getImage());
    assertEquals("3.4", node.getVersion());
    assertEquals("Free for non-commercial use", node.getLicense());
    assertEquals("Soyatec", node.getCompanyname());
    assertEquals("Mature", node.getStatus());
    assertEquals("3.4.x/3.5.x", node.getEclipseversion());
    assertEquals("http://www.soyatec.com/forum", node.getSupporturl());
    assertEquals("http://www.soyatec.com/update", node.getUpdateurl());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) INode(org.eclipse.epp.mpc.core.model.INode) ICategories(org.eclipse.epp.mpc.core.model.ICategories) ICategory(org.eclipse.epp.mpc.core.model.ICategory) Featured(org.eclipse.epp.internal.mpc.core.model.Featured) Test(org.junit.Test)

Example 5 with ICategories

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

the class MarketplaceDiscoveryStrategy method handleSearchResult.

protected void handleSearchResult(MarketplaceCategory catalogCategory, ISearchResult result, final IProgressMonitor monitor) {
    List<CatalogItem> items = getItems();
    if (items != null && !result.getNodes().isEmpty()) {
        int nodeWork = 1000;
        int favoritesWork = catalogCategory.getContents() == Contents.USER_FAVORITES ? 0 : 1000;
        SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_loadingResources, result.getNodes().size() * nodeWork + favoritesWork);
        try {
            boolean userFavoritesSupported = false;
            if (catalogCategory.getContents() == Contents.USER_FAVORITES) {
                userFavoritesSupported = true;
            } else if (hasUserFavoritesService()) {
                try {
                    applyShellProvider();
                    marketplaceService.userFavorites(result.getNodes(), progress.newChild(favoritesWork));
                    userFavoritesSupported = true;
                } catch (NotAuthorizedException e1) {
                // user is not logged in. we just ignore this.
                } catch (UnsupportedOperationException e1) {
                // ignore
                } catch (Exception e1) {
                    // something went wrong. log and proceed.
                    MarketplaceClientCore.error(Messages.MarketplaceDiscoveryStrategy_FavoritesRetrieveError, e1);
                }
            }
            for (final INode node : result.getNodes()) {
                String id = node.getId();
                try {
                    final MarketplaceNodeCatalogItem catalogItem = new MarketplaceNodeCatalogItem();
                    catalogItem.setMarketplaceUrl(catalogDescriptor.getUrl());
                    catalogItem.setId(id);
                    catalogItem.setName(getCatalogItemName(node));
                    catalogItem.setCategoryId(catalogCategory.getId());
                    ICategories categories = node.getCategories();
                    if (categories != null) {
                        for (ICategory category : categories.getCategory()) {
                            catalogItem.addTag(new Tag(ICategory.class, category.getId(), category.getName()));
                        }
                    }
                    catalogItem.setData(node);
                    catalogItem.setSource(source);
                    catalogItem.setLicense(node.getLicense());
                    catalogItem.setUserFavorite(userFavoritesSupported ? node.getUserFavorite() : null);
                    IIus ius = node.getIus();
                    if (ius != null) {
                        List<MarketplaceNodeInstallableUnitItem> installableUnitItems = new ArrayList<MarketplaceNodeInstallableUnitItem>();
                        for (IIu iu : ius.getIuElements()) {
                            MarketplaceNodeInstallableUnitItem iuItem = new MarketplaceNodeInstallableUnitItem();
                            iuItem.init(iu);
                            installableUnitItems.add(iuItem);
                        }
                        catalogItem.setInstallableUnitItems(installableUnitItems);
                    }
                    if (node.getShortdescription() == null && node.getBody() != null) {
                        // bug 306653 <!--break--> marks the end of the short description.
                        String descriptionText = node.getBody();
                        Matcher matcher = BREAK_PATTERN.matcher(node.getBody());
                        if (matcher.find()) {
                            int start = matcher.start();
                            if (start > 0) {
                                String shortDescriptionText = descriptionText.substring(0, start).trim();
                                if (shortDescriptionText.length() > 0) {
                                    descriptionText = shortDescriptionText;
                                }
                            }
                        }
                        catalogItem.setDescription(descriptionText);
                    } else {
                        catalogItem.setDescription(node.getShortdescription());
                    }
                    catalogItem.setProvider(node.getCompanyname());
                    String updateurl = node.getUpdateurl();
                    if (updateurl != null) {
                        try {
                            // trim is important!
                            updateurl = updateurl.trim();
                            URLUtil.toURL(updateurl);
                            catalogItem.setSiteUrl(updateurl);
                        } catch (MalformedURLException e) {
                        // don't use malformed URLs
                        }
                    }
                    if (catalogItem.getInstallableUnits() == null || catalogItem.getInstallableUnits().isEmpty() || catalogItem.getSiteUrl() == null) {
                        catalogItem.setAvailable(false);
                    }
                    if (node.getImage() != null) {
                        if (!source.getResourceProvider().containsResource(node.getImage())) {
                            cacheResource(source.getResourceProvider(), catalogItem, node.getImage());
                        }
                        createIcon(catalogItem, node);
                    }
                    if (node.getBody() != null || node.getScreenshot() != null) {
                        final Overview overview = new Overview();
                        overview.setItem(catalogItem);
                        overview.setSummary(node.getBody());
                        overview.setUrl(node.getUrl());
                        catalogItem.setOverview(overview);
                        if (node.getScreenshot() != null) {
                            if (!source.getResourceProvider().containsResource(node.getScreenshot())) {
                                cacheResource(source.getResourceProvider(), catalogItem, node.getScreenshot());
                            }
                            overview.setScreenshot(node.getScreenshot());
                        }
                    }
                    items.add(catalogItem);
                    marketplaceInfo.map(catalogItem.getMarketplaceUrl(), node);
                    marketplaceInfo.computeInstalled(computeInstalledFeatures(progress.newChild(nodeWork)), catalogItem);
                } catch (RuntimeException ex) {
                    MarketplaceClientUi.error(NLS.bind(Messages.MarketplaceDiscoveryStrategy_ParseError, // $NON-NLS-1$
                    node == null ? "null" : id), ex);
                }
            }
        } finally {
            progress.done();
        }
        if (result.getMatchCount() != null) {
            catalogCategory.setMatchCount(result.getMatchCount());
            if (result.getMatchCount() > result.getNodes().size()) {
                // add an item here to indicate that the search matched more items than were returned by the server
                addCatalogItem(catalogCategory);
            }
        }
    }
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) MalformedURLException(java.net.MalformedURLException) Matcher(java.util.regex.Matcher) ICategory(org.eclipse.epp.mpc.core.model.ICategory) SubMonitor(org.eclipse.core.runtime.SubMonitor) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Overview(org.eclipse.equinox.internal.p2.discovery.model.Overview) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) NotAuthorizedException(org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException) NoSuchElementException(java.util.NoSuchElementException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) IIu(org.eclipse.epp.mpc.core.model.IIu) ICategories(org.eclipse.epp.mpc.core.model.ICategories) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) IIus(org.eclipse.epp.mpc.core.model.IIus)

Aggregations

ICategories (org.eclipse.epp.mpc.core.model.ICategories)5 ICategory (org.eclipse.epp.mpc.core.model.ICategory)5 INode (org.eclipse.epp.mpc.core.model.INode)5 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)4 Test (org.junit.Test)4 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 NoSuchElementException (java.util.NoSuchElementException)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Matcher (java.util.regex.Matcher)1 CoreException (org.eclipse.core.runtime.CoreException)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 Favorites (org.eclipse.epp.internal.mpc.core.model.Favorites)1 Featured (org.eclipse.epp.internal.mpc.core.model.Featured)1 Recent (org.eclipse.epp.internal.mpc.core.model.Recent)1 Search (org.eclipse.epp.internal.mpc.core.model.Search)1 NotAuthorizedException (org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException)1 IIu (org.eclipse.epp.mpc.core.model.IIu)1