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;
}
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));
}
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());
}
Aggregations