Skip to content
Snippets Groups Projects
Commit 964bd96a authored by Vincent Massol's avatar Vincent Massol
Browse files

Revert "XWIKI-20533: Allow users to see What's New in XWiki"

This reverts commit bfc3db49.
parent bfc3db49
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,8 @@
*/
package org.xwiki.whatsnew;
import java.util.Map;
import org.xwiki.component.annotation.Role;
import org.xwiki.stability.Unstable;
......@@ -40,10 +42,10 @@
public interface NewsSourceFactory
{
/**
* @param descriptor the definition of a news source to be instantiated
* @param parameters the source-dependent list of parameters to configure the source
* @return the News source instance
* @throws NewsException when there's a problem creating the news source (e.g. not specific RSS URL for XWiki Blog
* source type)
*/
NewsSource create(NewsSourceDescriptor descriptor) throws NewsException;
NewsSource create(Map<String, String> parameters) throws NewsException;
}
......@@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
......@@ -55,8 +56,8 @@ public class ConfiguredNewsSourceFactory implements NewsSourceFactory, Initializ
private ComponentManager componentManager;
/**
* Cached news source so that calling several times {@link #create(NewsSourceDescriptor)} will be performant and
* return the same News source.
* Cached news source so that calling several times {@link #create(Map)} will be performant and return the same
* News source.
*/
private NewsSource source;
......@@ -72,7 +73,7 @@ public void initialize() throws InitializationException
}
@Override
public NewsSource create(NewsSourceDescriptor descriptor)
public NewsSource create(Map<String, String> parameters)
{
return this.source;
}
......@@ -83,7 +84,7 @@ private NewsSource create() throws NewsException
for (NewsSourceDescriptor descriptor : this.configuration.getNewsSourceDescriptors()) {
NewsSourceFactory factory = getFactory(descriptor.getSourceTypeHint());
if (factory != null) {
sources.add(factory.create(descriptor));
sources.add(factory.create(descriptor.getParameters()));
}
}
return new CompositeNewsSource(sources);
......
......@@ -19,13 +19,14 @@
*/
package org.xwiki.whatsnew.internal.xwikiblog;
import java.util.Map;
import javax.inject.Named;
import javax.inject.Singleton;
import org.xwiki.component.annotation.Component;
import org.xwiki.whatsnew.NewsException;
import org.xwiki.whatsnew.NewsSource;
import org.xwiki.whatsnew.NewsSourceDescriptor;
import org.xwiki.whatsnew.NewsSourceFactory;
/**
......@@ -40,9 +41,9 @@
public class XWikiBlogNewsSourceFactory implements NewsSourceFactory
{
@Override
public NewsSource create(NewsSourceDescriptor descriptor) throws NewsException
public NewsSource create(Map<String, String> parameters) throws NewsException
{
String rssURL = descriptor.getParameters().get("rssURL");
String rssURL = parameters.get("rssURL");
if (rssURL == null) {
throw new NewsException("Failed to create a XWiki Blog news source. A 'rssURL' parameter must be passed");
}
......
......@@ -19,6 +19,8 @@
*/
package org.xwiki.whatsnew.internal.configured;
import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.xwiki.test.junit5.mockito.ComponentTest;
import org.xwiki.test.junit5.mockito.InjectMockComponents;
......@@ -35,7 +37,7 @@ class ConfiguredNewsSourceFactoryTest
@Test
void createWhenEmptyConfiguration()
{
NewsSource source = this.factory.create(null);
NewsSource source = this.factory.create(Collections.emptyMap());
assertNotNull(source);
}
......
......@@ -26,7 +26,6 @@
import org.xwiki.test.junit5.mockito.InjectMockComponents;
import org.xwiki.whatsnew.NewsException;
import org.xwiki.whatsnew.NewsSource;
import org.xwiki.whatsnew.NewsSourceDescriptor;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
......@@ -47,16 +46,14 @@ class XWikiBlogNewsSourceFactoryTest
@Test
void create() throws Exception
{
NewsSource source =
this.factory.create(new NewsSourceDescriptor("id", "hint", Collections.singletonMap("rssURL", "some url")));
NewsSource source = this.factory.create(Collections.singletonMap("rssURL", "some url"));
assertNotNull(source);
}
@Test
void createWhenNoRSSURLParameter()
{
Throwable exception = assertThrows(NewsException.class, () -> this.factory.create(new NewsSourceDescriptor(
"id", "hint", Collections.emptyMap())));
Throwable exception = assertThrows(NewsException.class, () -> this.factory.create(Collections.emptyMap()));
assertEquals("Failed to create a XWiki Blog news source. A 'rssURL' parameter must be passed",
exception.getMessage());
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment