Search in sources :

Example 1 with ICatalog

use of org.eclipse.epp.mpc.core.model.ICatalog in project epp.mpc by eclipse.

the class UnmarshallerTest method marketplaceCatalogs.

@Test
public void marketplaceCatalogs() throws IOException, UnmarshalException {
    Object model = processResource("resources/catalogs.xml");
    assertNotNull(model);
    assertTrue(model instanceof ICatalogs);
    ICatalogs catalogs = (ICatalogs) model;
    assertEquals(3, catalogs.getCatalogs().size());
    // <catalog id="35656" title="Marketplace Catalog" url="http://marketplace.eclipse.org" selfContained="1"  dependencyRepository="http://download.eclipse.org/releases/helios">
    // <description>Here is a description</description>
    // <icon>http://marketplace.eclipse.org/sites/default/files/jacket.jpg</icon>
    // <wizard title="Eclipse Marketplace Catalog">
    // <icon>http://marketplace.eclipse.org/sites/default/files/giant-rabbit2.jpg</icon>
    // <searchtab enabled='1'>Search</searchtab>
    // <populartab enabled='1'>Popular</populartab>
    // <recenttab enabled='1'>Recent</recenttab>
    // </wizard>
    // </catalog>
    ICatalog catalog = catalogs.getCatalogs().get(0);
    assertEquals("35656", catalog.getId());
    assertEquals("Marketplace Catalog", catalog.getName());
    assertEquals("http://marketplace.eclipse.org", catalog.getUrl());
    assertEquals("Here is a description", catalog.getDescription());
    assertTrue(catalog.isSelfContained());
    assertEquals("http://marketplace.eclipse.org/sites/default/files/marketplace32.png", catalog.getImageUrl());
    assertEquals("http://download.eclipse.org/releases/helios", catalog.getDependencyRepository());
    ICatalogBranding branding = catalog.getBranding();
    assertNotNull(branding);
    assertEquals("Eclipse Marketplace Catalog", branding.getWizardTitle());
    assertEquals("http://marketplace.eclipse.org/sites/default/files/giant-rabbit2.jpg", branding.getWizardIcon());
    assertEquals("Search", branding.getSearchTabName());
    assertEquals("Popular", branding.getPopularTabName());
    assertEquals("Recent", branding.getRecentTabName());
    assertTrue(branding.hasSearchTab());
    assertFalse(branding.hasPopularTab());
    assertTrue(branding.hasRecentTab());
    INews news = catalog.getNews();
    assertNotNull(news);
    assertEquals("http://marketplace.eclipse.org/news", news.getUrl());
    assertEquals("News", news.getShortTitle());
    assertEquals(Long.valueOf(1363181064000l), news.getTimestamp());
    assertNull(catalogs.getCatalogs().get(1).getNews());
    assertNull(catalogs.getCatalogs().get(2).getNews());
}
Also used : INews(org.eclipse.epp.mpc.core.model.INews) ICatalogs(org.eclipse.epp.mpc.core.model.ICatalogs) ICatalogBranding(org.eclipse.epp.mpc.core.model.ICatalogBranding) ICatalog(org.eclipse.epp.mpc.core.model.ICatalog) Test(org.junit.Test)

Example 2 with ICatalog

use of org.eclipse.epp.mpc.core.model.ICatalog in project epp.mpc by eclipse.

the class AbstractMarketplaceWizardCommand method installRemoteCatalogs.

public IStatus installRemoteCatalogs() {
    try {
        final AtomicReference<List<? extends ICatalog>> result = new AtomicReference<List<? extends ICatalog>>();
        PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    ICatalogService catalogService = ServiceHelper.getMarketplaceServiceLocator().getCatalogService();
                    final List<? extends ICatalog> catalogs = catalogService.listCatalogs(monitor);
                    result.set(catalogs);
                } catch (CoreException e) {
                    if (e.getStatus().getSeverity() == IStatus.CANCEL) {
                        throw new InterruptedException();
                    }
                    throw new InvocationTargetException(e);
                }
            }
        });
        List<? extends ICatalog> catalogs = result.get();
        for (ICatalog catalog : catalogs) {
            ResourceProvider resourceProvider = MarketplaceClientUiPlugin.getInstance().getResourceProvider();
            String catalogName = catalog.getName();
            String requestSource = NLS.bind(Messages.MarketplaceWizardCommand_requestCatalog, catalogName, catalog.getId());
            String catalogImageUrl = catalog.getImageUrl();
            if (catalogImageUrl != null) {
                try {
                    resourceProvider.retrieveResource(requestSource, catalogImageUrl);
                } catch (Exception e) {
                    MarketplaceClientUi.log(IStatus.WARNING, Messages.MarketplaceWizardCommand_FailedRetrievingCatalogImage, catalogName, catalogImageUrl, e);
                }
            }
            if (catalog.getBranding() != null && catalog.getBranding().getWizardIcon() != null) {
                String wizardIconUrl = catalog.getBranding().getWizardIcon();
                try {
                    resourceProvider.retrieveResource(requestSource, wizardIconUrl);
                } catch (Exception e) {
                    MarketplaceClientUi.log(IStatus.WARNING, Messages.MarketplaceWizardCommand_FailedRetrievingCatalogWizardIcon, catalogName, wizardIconUrl, e);
                }
            }
            CatalogDescriptor descriptor = new CatalogDescriptor(catalog);
            registerOrOverrideCatalog(descriptor);
        }
    } catch (InterruptedException ie) {
        if (ie.getMessage() == null || "".equals(ie.getMessage())) {
            InterruptedException ie1 = new InterruptedException("Operation cancelled");
            ie1.setStackTrace(ie.getStackTrace());
            if (ie.getCause() != null) {
                ie1.initCause(ie.getCause());
            }
            ie = ie1;
        }
        IStatus errorStatus = MarketplaceClientCore.computeStatus(ie, Messages.MarketplaceWizardCommand_CannotInstallRemoteLocations);
        return new Status(IStatus.CANCEL, MarketplaceClientCore.BUNDLE_ID, errorStatus.getMessage(), ie);
    } catch (Exception e) {
        IStatus status = MarketplaceClientCore.computeStatus(e, Messages.MarketplaceWizardCommand_CannotInstallRemoteLocations);
        return status;
    }
    return Status.OK_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ICatalogService(org.eclipse.epp.mpc.core.service.ICatalogService) AtomicReference(java.util.concurrent.atomic.AtomicReference) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ResourceProvider(org.eclipse.epp.internal.mpc.ui.catalog.ResourceProvider) List(java.util.List) ICatalog(org.eclipse.epp.mpc.core.model.ICatalog) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 3 with ICatalog

use of org.eclipse.epp.mpc.core.model.ICatalog in project epp.mpc by eclipse.

the class DefaultCatalogService method listCatalogs.

public List<? extends ICatalog> listCatalogs(IProgressMonitor monitor) throws CoreException {
    // $NON-NLS-1$
    Catalogs result = processRequest("catalogs/" + API_URI_SUFFIX, monitor);
    List<Catalog> catalogs = result.getCatalogs();
    for (Catalog catalog : catalogs) {
        registerDynamicFavoritesService(catalog);
    }
    return catalogs;
}
Also used : Catalogs(org.eclipse.epp.internal.mpc.core.model.Catalogs) ICatalog(org.eclipse.epp.mpc.core.model.ICatalog) Catalog(org.eclipse.epp.internal.mpc.core.model.Catalog)

Example 4 with ICatalog

use of org.eclipse.epp.mpc.core.model.ICatalog in project epp.mpc by eclipse.

the class CatalogServiceTest method listCatalogs.

@Test
@Category(RemoteTests.class)
public void listCatalogs() throws CoreException {
    List<? extends ICatalog> catalogs = catalogService.listCatalogs(new NullProgressMonitor());
    assertNotNull(catalogs);
    assertFalse(catalogs.isEmpty());
    for (ICatalog catalog : catalogs) {
        assertNotNull(catalog.getId());
        assertNotNull(catalog.getUrl());
        assertNotNull(catalog.getName());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICatalog(org.eclipse.epp.mpc.core.model.ICatalog) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

ICatalog (org.eclipse.epp.mpc.core.model.ICatalog)4 Test (org.junit.Test)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 Catalog (org.eclipse.epp.internal.mpc.core.model.Catalog)1 Catalogs (org.eclipse.epp.internal.mpc.core.model.Catalogs)1 ResourceProvider (org.eclipse.epp.internal.mpc.ui.catalog.ResourceProvider)1 ICatalogBranding (org.eclipse.epp.mpc.core.model.ICatalogBranding)1 ICatalogs (org.eclipse.epp.mpc.core.model.ICatalogs)1 INews (org.eclipse.epp.mpc.core.model.INews)1 ICatalogService (org.eclipse.epp.mpc.core.service.ICatalogService)1 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1