Search in sources :

Example 1 with MarketplaceUrlHandler

use of org.eclipse.epp.mpc.ui.MarketplaceUrlHandler 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 2 with MarketplaceUrlHandler

use of org.eclipse.epp.mpc.ui.MarketplaceUrlHandler in project epp.mpc by eclipse.

the class MarketplaceUrlHandlerTest method testHttpsVariants.

@Test
public void testHttpsVariants() {
    MarketplaceUrlHandler handler = new MarketplaceUrlHandler() {

        @Override
        protected boolean handleFeatured(CatalogDescriptor descriptor, String url, String category, String market) {
            assertEquals(eclipseMarketplace, descriptor);
            assertEquals("featured", url);
            return true;
        }
    };
    String url = "http://marketplace.eclipse.org/featured";
    assertTrue(handler.handleUri(url));
    url = "https://marketplace.eclipse.org/featured";
    assertTrue(handler.handleUri(url));
}
Also used : MarketplaceUrlHandler(org.eclipse.epp.mpc.ui.MarketplaceUrlHandler) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 3 with MarketplaceUrlHandler

use of org.eclipse.epp.mpc.ui.MarketplaceUrlHandler in project epp.mpc by eclipse.

the class MarketplaceUrlHandlerTest method testNodeUrls.

@Test
public void testNodeUrls() throws Exception {
    final INode[] testNode = new INode[1];
    MarketplaceUrlHandler handler = new MarketplaceUrlHandler() {

        @Override
        protected boolean handleNode(CatalogDescriptor descriptor, String url, INode node) {
            testNode[0] = node;
            return true;
        }
    };
    testNode[0] = null;
    String url = "http://marketplace.eclipse.org/content/test";
    assertTrue(handler.handleUri(url));
    assertNotNull(testNode[0]);
    assertEquals(url, testNode[0].getUrl());
    testNode[0] = null;
    String nodeId = "12345";
    url = "http://marketplace.eclipse.org/node/" + nodeId;
    assertTrue(handler.handleUri(url));
    assertNotNull(testNode[0]);
    assertEquals(nodeId, testNode[0].getId());
}
Also used : INode(org.eclipse.epp.mpc.core.model.INode) MarketplaceUrlHandler(org.eclipse.epp.mpc.ui.MarketplaceUrlHandler) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Aggregations

CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)3 MarketplaceUrlHandler (org.eclipse.epp.mpc.ui.MarketplaceUrlHandler)3 INode (org.eclipse.epp.mpc.core.model.INode)2 Test (org.junit.Test)2 Node (org.eclipse.epp.internal.mpc.core.model.Node)1 SearchResult (org.eclipse.epp.internal.mpc.core.model.SearchResult)1 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)1