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