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 @@ ...@@ -19,6 +19,8 @@
*/ */
package org.xwiki.whatsnew; package org.xwiki.whatsnew;
import java.util.Map;
import org.xwiki.component.annotation.Role; import org.xwiki.component.annotation.Role;
import org.xwiki.stability.Unstable; import org.xwiki.stability.Unstable;
...@@ -40,10 +42,10 @@ ...@@ -40,10 +42,10 @@
public interface NewsSourceFactory 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 * @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 * @throws NewsException when there's a problem creating the news source (e.g. not specific RSS URL for XWiki Blog
* source type) * source type)
*/ */
NewsSource create(NewsSourceDescriptor descriptor) throws NewsException; NewsSource create(Map<String, String> parameters) throws NewsException;
} }
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
...@@ -55,8 +56,8 @@ public class ConfiguredNewsSourceFactory implements NewsSourceFactory, Initializ ...@@ -55,8 +56,8 @@ public class ConfiguredNewsSourceFactory implements NewsSourceFactory, Initializ
private ComponentManager componentManager; private ComponentManager componentManager;
/** /**
* Cached news source so that calling several times {@link #create(NewsSourceDescriptor)} will be performant and * Cached news source so that calling several times {@link #create(Map)} will be performant and return the same
* return the same News source. * News source.
*/ */
private NewsSource source; private NewsSource source;
...@@ -72,7 +73,7 @@ public void initialize() throws InitializationException ...@@ -72,7 +73,7 @@ public void initialize() throws InitializationException
} }
@Override @Override
public NewsSource create(NewsSourceDescriptor descriptor) public NewsSource create(Map<String, String> parameters)
{ {
return this.source; return this.source;
} }
...@@ -83,7 +84,7 @@ private NewsSource create() throws NewsException ...@@ -83,7 +84,7 @@ private NewsSource create() throws NewsException
for (NewsSourceDescriptor descriptor : this.configuration.getNewsSourceDescriptors()) { for (NewsSourceDescriptor descriptor : this.configuration.getNewsSourceDescriptors()) {
NewsSourceFactory factory = getFactory(descriptor.getSourceTypeHint()); NewsSourceFactory factory = getFactory(descriptor.getSourceTypeHint());
if (factory != null) { if (factory != null) {
sources.add(factory.create(descriptor)); sources.add(factory.create(descriptor.getParameters()));
} }
} }
return new CompositeNewsSource(sources); return new CompositeNewsSource(sources);
......
...@@ -19,13 +19,14 @@ ...@@ -19,13 +19,14 @@
*/ */
package org.xwiki.whatsnew.internal.xwikiblog; package org.xwiki.whatsnew.internal.xwikiblog;
import java.util.Map;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.xwiki.component.annotation.Component; import org.xwiki.component.annotation.Component;
import org.xwiki.whatsnew.NewsException; import org.xwiki.whatsnew.NewsException;
import org.xwiki.whatsnew.NewsSource; import org.xwiki.whatsnew.NewsSource;
import org.xwiki.whatsnew.NewsSourceDescriptor;
import org.xwiki.whatsnew.NewsSourceFactory; import org.xwiki.whatsnew.NewsSourceFactory;
/** /**
...@@ -40,9 +41,9 @@ ...@@ -40,9 +41,9 @@
public class XWikiBlogNewsSourceFactory implements NewsSourceFactory public class XWikiBlogNewsSourceFactory implements NewsSourceFactory
{ {
@Override @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) { if (rssURL == null) {
throw new NewsException("Failed to create a XWiki Blog news source. A 'rssURL' parameter must be passed"); throw new NewsException("Failed to create a XWiki Blog news source. A 'rssURL' parameter must be passed");
} }
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
*/ */
package org.xwiki.whatsnew.internal.configured; package org.xwiki.whatsnew.internal.configured;
import java.util.Collections;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.xwiki.test.junit5.mockito.ComponentTest; import org.xwiki.test.junit5.mockito.ComponentTest;
import org.xwiki.test.junit5.mockito.InjectMockComponents; import org.xwiki.test.junit5.mockito.InjectMockComponents;
...@@ -35,7 +37,7 @@ class ConfiguredNewsSourceFactoryTest ...@@ -35,7 +37,7 @@ class ConfiguredNewsSourceFactoryTest
@Test @Test
void createWhenEmptyConfiguration() void createWhenEmptyConfiguration()
{ {
NewsSource source = this.factory.create(null); NewsSource source = this.factory.create(Collections.emptyMap());
assertNotNull(source); assertNotNull(source);
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
import org.xwiki.test.junit5.mockito.InjectMockComponents; import org.xwiki.test.junit5.mockito.InjectMockComponents;
import org.xwiki.whatsnew.NewsException; import org.xwiki.whatsnew.NewsException;
import org.xwiki.whatsnew.NewsSource; 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.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
...@@ -47,16 +46,14 @@ class XWikiBlogNewsSourceFactoryTest ...@@ -47,16 +46,14 @@ class XWikiBlogNewsSourceFactoryTest
@Test @Test
void create() throws Exception void create() throws Exception
{ {
NewsSource source = NewsSource source = this.factory.create(Collections.singletonMap("rssURL", "some url"));
this.factory.create(new NewsSourceDescriptor("id", "hint", Collections.singletonMap("rssURL", "some url")));
assertNotNull(source); assertNotNull(source);
} }
@Test @Test
void createWhenNoRSSURLParameter() void createWhenNoRSSURLParameter()
{ {
Throwable exception = assertThrows(NewsException.class, () -> this.factory.create(new NewsSourceDescriptor( Throwable exception = assertThrows(NewsException.class, () -> this.factory.create(Collections.emptyMap()));
"id", "hint", Collections.emptyMap())));
assertEquals("Failed to create a XWiki Blog news source. A 'rssURL' parameter must be passed", assertEquals("Failed to create a XWiki Blog news source. A 'rssURL' parameter must be passed",
exception.getMessage()); 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