use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class DefaultMarketplaceServiceTest method search.
@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
public void search() throws CoreException {
ISearchResult result = search("Tools", "Editor", "snipmatch");
assertNotNull(result);
assertNotNull(result.getNodes());
assertEquals(Integer.valueOf(1), result.getMatchCount());
assertEquals(1, result.getNodes().size());
INode node = result.getNodes().get(0);
assertTrue(node.getName().startsWith("Snipmatch"));
assertEquals("1743547", node.getId());
}
use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class DefaultMarketplaceServiceTest method featured.
@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
public void featured() throws CoreException {
ISearchResult result = marketplaceService.featured(new NullProgressMonitor());
assertSearchResultSanity(result);
}
use of org.eclipse.epp.mpc.core.model.ISearchResult in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method performQuery.
public void performQuery(IMarket market, ICategory category, String queryText, IProgressMonitor monitor) throws CoreException {
final int totalWork = 1001;
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_searchingMarketplace, totalWork);
try {
ISearchResult result;
MarketplaceCategory catalogCategory = findMarketplaceCategory(progress.newChild(1));
catalogCategory.setContents(Contents.QUERY);
SubMonitor nodeQueryProgress = progress.newChild(500);
try {
// check if the query matches a node url and just retrieve that node
result = performNodeQuery(queryText, nodeQueryProgress);
} catch (CoreException ex) {
// node not found, continue with regular query
result = null;
// no work was done
nodeQueryProgress.setWorkRemaining(0);
}
if (result == null) {
// regular query
// resolve market and category if necessary
IMarket resolvedMarket;
ICategory resolvedCategory;
try {
resolvedMarket = resolve(market, catalogCategory.getMarkets());
resolvedCategory = resolveCategory(category, catalogCategory.getMarkets());
} catch (IllegalArgumentException ex) {
throw new CoreException(MarketplaceClientCore.computeStatus(ex, Messages.MarketplaceDiscoveryStrategy_invalidFilter));
} catch (NoSuchElementException ex) {
throw new CoreException(MarketplaceClientCore.computeStatus(ex, Messages.MarketplaceDiscoveryStrategy_unknownFilter));
}
progress.setWorkRemaining(totalWork - 1);
result = marketplaceService.search(resolvedMarket, resolvedCategory, queryText, progress.newChild(500));
}
handleSearchResult(catalogCategory, result, progress.newChild(500));
if (result.getNodes().isEmpty()) {
catalogCategory.setMatchCount(0);
addCatalogItem(catalogCategory);
}
} finally {
progress.done();
}
}
use of org.eclipse.epp.mpc.core.model.ISearchResult 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.core.model.ISearchResult in project epp.mpc by eclipse.
the class DiscoverNatureSupportJob method run.
@Override
protected IStatus run(IProgressMonitor monitor) {
BundleContext bundleContext = MarketplaceClientUiPlugin.getBundleContext();
ServiceReference<IMarketplaceServiceLocator> locatorReference = bundleContext.getServiceReference(IMarketplaceServiceLocator.class);
IMarketplaceServiceLocator locator = bundleContext.getService(locatorReference);
IMarketplaceService marketplaceService = locator.getDefaultMarketplaceService();
// $NON-NLS-1$]
String fileExtensionTag = "nature_" + natureId;
try {
ISearchResult searchResult = marketplaceService.tagged(fileExtensionTag, monitor);
nodes = searchResult.getNodes();
} catch (CoreException ex) {
IStatus status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.LookupByNatureJob_discoveryFailed, natureId), ex);
MarketplaceClientUi.getLog().log(status);
// Do not return this status as it would show an error
return Status.CANCEL_STATUS;
}
return Status.OK_STATUS;
}
Aggregations