Search in sources :

Example 6 with SearchResult

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;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) SearchResult(org.eclipse.epp.internal.mpc.core.model.SearchResult)

Example 7 with SearchResult

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;
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) Category(org.eclipse.epp.internal.mpc.core.model.Category) ICategory(org.eclipse.epp.mpc.core.model.ICategory) CoreException(org.eclipse.core.runtime.CoreException) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) Search(org.eclipse.epp.internal.mpc.core.model.Search) FileNotFoundException(java.io.FileNotFoundException) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) SearchResult(org.eclipse.epp.internal.mpc.core.model.SearchResult)

Example 8 with SearchResult

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

Aggregations

SearchResult (org.eclipse.epp.internal.mpc.core.model.SearchResult)8 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)7 INode (org.eclipse.epp.mpc.core.model.INode)5 SubMonitor (org.eclipse.core.runtime.SubMonitor)4 Node (org.eclipse.epp.internal.mpc.core.model.Node)4 CoreException (org.eclipse.core.runtime.CoreException)2 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 FileNotFoundException (java.io.FileNotFoundException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Category (org.eclipse.epp.internal.mpc.core.model.Category)1 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)1 Search (org.eclipse.epp.internal.mpc.core.model.Search)1 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)1