use of org.eclipse.epp.internal.mpc.core.model.SearchResult in project epp.mpc by eclipse.
the class DefaultMarketplaceService method createSearchResult.
protected SearchResult createSearchResult(NodeListing nodeList) throws CoreException {
if (nodeList == null) {
throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_unexpectedResponse, Messages.DefaultMarketplaceService_nullResultNodes));
}
SearchResult result = new SearchResult();
result.setMatchCount(nodeList.getCount());
result.setNodes(nodeList.getNode());
return result;
}
use of org.eclipse.epp.internal.mpc.core.model.SearchResult in project epp.mpc by eclipse.
the class DefaultMarketplaceService method processSearchRequest.
private SearchResult processSearchRequest(String relativeUrl, String queryText, IProgressMonitor monitor) throws CoreException {
SearchResult result = new SearchResult();
if (relativeUrl == null) {
// empty search
result.setMatchCount(0);
result.setNodes(new ArrayList<Node>());
} else {
Marketplace marketplace;
try {
marketplace = processRequest(relativeUrl, monitor);
} catch (CoreException ex) {
Throwable cause = ex.getCause();
if (cause instanceof FileNotFoundException) {
throw new CoreException(createErrorStatus(NLS.bind(Messages.DefaultMarketplaceService_UnsupportedSearchString, queryText), cause));
}
throw ex;
}
Search search = marketplace.getSearch();
if (search != null) {
result.setMatchCount(search.getCount());
result.setNodes(search.getNode());
} else if (marketplace.getCategory().size() == 1) {
Category category = marketplace.getCategory().get(0);
result.setMatchCount(category.getNode().size());
result.setNodes(category.getNode());
} else {
throw new CoreException(createErrorStatus(Messages.DefaultMarketplaceService_unexpectedResponse, relativeUrl));
}
}
return result;
}
use of org.eclipse.epp.internal.mpc.core.model.SearchResult 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;
}
Aggregations