Search in sources :

Example 1 with News

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

the class NewsContentHandler method startElement.

@Override
public void startElement(String uri, String localName, Attributes attributes) {
    if (localName.equals("news")) {
        // $NON-NLS-1$
        model = new News();
        // $NON-NLS-1$
        model.setShortTitle(attributes.getValue(NS_URI, "shorttitle"));
        // $NON-NLS-1$
        model.setTimestamp(toLong(attributes.getValue(NS_URI, "timestamp")));
        capturingContent = true;
    }
}
Also used : News(org.eclipse.epp.internal.mpc.core.model.News)

Example 2 with News

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

the class DefaultMarketplaceServiceTest method news.

@Test
@org.junit.experimental.categories.Category(RemoteTests.class)
public void news() throws CoreException, ParseException, MalformedURLException {
    News news = marketplaceService.news(new NullProgressMonitor());
    assertNotNull(news);
    Long timestamp = news.getTimestamp();
    assertNotNull(timestamp);
    assertThat(new Date(timestamp * 1000), greaterThan(new SimpleDateFormat("yyyy-MM-dd").parse("2014-06-24")));
    String shortTitle = news.getShortTitle();
    assertNotNull(shortTitle);
    String url = news.getUrl();
    assertNotNull(url);
    new URL(url);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) News(org.eclipse.epp.internal.mpc.core.model.News) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) URL(java.net.URL) Test(org.junit.Test)

Example 3 with News

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

the class UnmarshallerTest method news.

@Test
public void news() throws IOException, UnmarshalException {
    Object model = processResource("resources/news.xml");
    assertNotNull(model);
    assertTrue(model instanceof Marketplace);
    Marketplace marketplace = (Marketplace) model;
    News news = marketplace.getNews();
    assertNotNull(news);
    assertEquals("http://marketplace.eclipse.org/news", news.getUrl());
    assertEquals("News", news.getShortTitle());
    assertEquals(Long.valueOf(1363181064000l), news.getTimestamp());
}
Also used : Marketplace(org.eclipse.epp.internal.mpc.core.model.Marketplace) News(org.eclipse.epp.internal.mpc.core.model.News) INews(org.eclipse.epp.mpc.core.model.INews) Test(org.junit.Test)

Example 4 with News

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

the class MarketplaceWizard method updateNews.

protected void updateNews() {
    CatalogDescriptor catalogDescriptor = getConfiguration().getCatalogDescriptor();
    INews news = null;
    if (Boolean.parseBoolean(Platform.getDebugOption(DEBUG_NEWS_FLAG))) {
        // use debug override values
        String debugNewsUrl = Platform.getDebugOption(DEBUG_NEWS_URL);
        if (debugNewsUrl != null && debugNewsUrl.length() > 0) {
            News debugNews = new News();
            news = debugNews;
            debugNews.setUrl(debugNewsUrl);
            String debugNewsTitle = Platform.getDebugOption(DEBUG_NEWS_TITLE);
            if (debugNewsTitle == null || debugNewsTitle.length() == 0) {
                // $NON-NLS-1$
                debugNews.setShortTitle("Debug News");
            } else {
                debugNews.setShortTitle(debugNewsTitle);
            }
            debugNews.setTimestamp(System.currentTimeMillis());
        }
    }
    if (news == null) {
        // try requesting news from marketplace
        try {
            final INews[] result = new INews[1];
            getContainer().run(true, true, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    IStatus status = getCatalog().performNewsDiscovery(monitor);
                    if (!status.isOK() && status.getSeverity() != IStatus.CANCEL) {
                        // don't bother user with missing news
                        MarketplaceClientUi.handle(status, StatusManager.LOG);
                    }
                    result[0] = getCatalog().getNews();
                }
            });
            if (result[0] != null) {
                news = result[0];
            }
        } catch (InvocationTargetException e) {
            final IStatus status = MarketplaceClientCore.computeStatus(e, Messages.MarketplaceViewer_unexpectedException);
            MarketplaceClientUi.handle(status, StatusManager.LOG);
        } catch (InterruptedException e) {
        // cancelled by user
        }
    }
    if (news == null) {
        // use news from catalog
        news = CatalogRegistry.getInstance().getCatalogNews(catalogDescriptor);
    }
    CatalogRegistry.getInstance().addCatalogNews(catalogDescriptor, news);
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) INews(org.eclipse.epp.mpc.core.model.INews) News(org.eclipse.epp.internal.mpc.core.model.News) INews(org.eclipse.epp.mpc.core.model.INews) InvocationTargetException(java.lang.reflect.InvocationTargetException) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

News (org.eclipse.epp.internal.mpc.core.model.News)4 INews (org.eclipse.epp.mpc.core.model.INews)2 Test (org.junit.Test)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URL (java.net.URL)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Marketplace (org.eclipse.epp.internal.mpc.core.model.Marketplace)1 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1