Search in sources :

Example 6 with IMarketplaceService

use of org.eclipse.epp.mpc.core.service.IMarketplaceService in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategyTest method testSearchByNodeUrl.

@Test
public void testSearchByNodeUrl() throws Exception {
    final INode[] testNode = new INode[1];
    final IMarketplaceService marketplaceService = new DefaultMarketplaceService(catalogUrl) {

        @Override
        public Node getNode(INode node, IProgressMonitor monitor) throws CoreException {
            testNode[0] = node;
            return (Node) node;
        }

        @Override
        public SearchResult search(IMarket market, ICategory category, String queryText, IProgressMonitor monitor) throws CoreException {
            Assert.fail("Unexpected invocation");
            // dead code
            return null;
        }
    };
    setupCatalog(marketplaceService);
    testNode[0] = null;
    catalog.performQuery(null, null, new URL(catalogUrl, "content/test").toExternalForm(), new NullProgressMonitor());
    assertNotNull(testNode[0]);
    assertNotNull(testNode[0].getUrl());
    testNode[0] = null;
    catalog.performQuery(null, null, new URL(catalogUrl, "node/12345").toExternalForm(), new NullProgressMonitor());
    assertNotNull(testNode[0]);
    assertNotNull(testNode[0].getId());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DefaultMarketplaceService(org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService) Node(org.eclipse.epp.internal.mpc.core.model.Node) INode(org.eclipse.epp.mpc.core.model.INode) ICategory(org.eclipse.epp.mpc.core.model.ICategory) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) IMarket(org.eclipse.epp.mpc.core.model.IMarket) URL(java.net.URL) Test(org.junit.Test)

Example 7 with IMarketplaceService

use of org.eclipse.epp.mpc.core.service.IMarketplaceService in project epp.mpc by eclipse.

the class MarketplaceDiscoveryStrategyTest method setupCatalog.

private void setupCatalog(final IMarketplaceService marketplaceService) {
    discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {

        @Override
        public IMarketplaceService createMarketplaceService() {
            return marketplaceService;
        }
    };
    catalog.getDiscoveryStrategies().clear();
    catalog.getDiscoveryStrategies().add(discoveryStrategy);
}
Also used : MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService)

Example 8 with IMarketplaceService

use of org.eclipse.epp.mpc.core.service.IMarketplaceService in project epp.mpc by eclipse.

the class UserFavoritesService method getMarketplaceBaseUri.

private String getMarketplaceBaseUri() {
    String marketplaceBaseUri = getStorageService().getMarketplaceBaseUri();
    if (marketplaceBaseUri != null) {
        return marketplaceBaseUri;
    }
    IMarketplaceService defaultMarketplaceService = ServiceHelper.getMarketplaceServiceLocator().getDefaultMarketplaceService();
    if (defaultMarketplaceService != null) {
        return defaultMarketplaceService.getBaseUrl().toString();
    }
    return DefaultMarketplaceService.DEFAULT_SERVICE_LOCATION;
}
Also used : IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService)

Example 9 with IMarketplaceService

use of org.eclipse.epp.mpc.core.service.IMarketplaceService in project epp.mpc by eclipse.

the class ProvisioningJobListener method done.

@Override
public void done(IJobChangeEvent event) {
    if (event.getResult().isOK()) {
        Job job = new Job(Messages.ProvisioningJobListener_notificationTaskName) {

            {
                setPriority(Job.LONG);
                setSystem(true);
                setUser(true);
            }

            @Override
            protected IStatus run(final IProgressMonitor monitor) {
                ConcurrentTaskManager taskManager = new ConcurrentTaskManager(installItems.size(), Messages.ProvisioningJobListener_notificationTaskName);
                for (CatalogItem item : installItems) {
                    if (item instanceof MarketplaceNodeCatalogItem) {
                        final MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
                        taskManager.submit(new Runnable() {

                            public void run() {
                                INode node = nodeItem.getData();
                                URL marketplaceUrl = nodeItem.getMarketplaceUrl();
                                IMarketplaceService marketplaceService = ServiceHelper.getMarketplaceServiceLocator().getMarketplaceService(marketplaceUrl.toString());
                                marketplaceService.reportInstallSuccess(node, new NullProgressMonitor() {

                                    @Override
                                    public boolean isCanceled() {
                                        return monitor.isCanceled();
                                    }
                                });
                            }
                        });
                    }
                }
                try {
                    taskManager.waitUntilFinished(monitor);
                } catch (CoreException e) {
                    return e.getStatus();
                }
                return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
            }
        };
        job.schedule();
    }
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode) CoreException(org.eclipse.core.runtime.CoreException) ConcurrentTaskManager(org.eclipse.epp.internal.mpc.ui.util.ConcurrentTaskManager) Job(org.eclipse.core.runtime.jobs.Job) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) URL(java.net.URL)

Example 10 with IMarketplaceService

use of org.eclipse.epp.mpc.core.service.IMarketplaceService 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;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ISearchResult(org.eclipse.epp.mpc.core.model.ISearchResult) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) IMarketplaceServiceLocator(org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator) BundleContext(org.osgi.framework.BundleContext)

Aggregations

IMarketplaceService (org.eclipse.epp.mpc.core.service.IMarketplaceService)11 URL (java.net.URL)5 DefaultMarketplaceService (org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService)3 INode (org.eclipse.epp.mpc.core.model.INode)3 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Node (org.eclipse.epp.internal.mpc.core.model.Node)2 MarketplaceDiscoveryStrategy (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy)2 ISearchResult (org.eclipse.epp.mpc.core.model.ISearchResult)2 IMarketplaceServiceLocator (org.eclipse.epp.mpc.core.service.IMarketplaceServiceLocator)2 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)2 BundleContext (org.osgi.framework.BundleContext)2 MalformedURLException (java.net.MalformedURLException)1 Map (java.util.Map)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 Job (org.eclipse.core.runtime.jobs.Job)1 CachingMarketplaceService (org.eclipse.epp.internal.mpc.core.service.CachingMarketplaceService)1 UserFavoritesService (org.eclipse.epp.internal.mpc.core.service.UserFavoritesService)1