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