Revision 33231
Added by Andrea Mannocci over 9 years ago
MediawikiCollectorPlugin.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.collector.plugins.mediawiki; |
2 | 2 |
|
3 | 3 |
import java.util.Iterator; |
4 |
import java.util.List; |
|
5 | 4 |
|
6 |
import com.google.common.collect.Lists; |
|
7 |
|
|
8 |
import eu.dnetlib.data.collector.plugin.CollectorPlugin; |
|
5 |
import eu.dnetlib.data.collector.plugin.AbstractCollectorPlugin; |
|
9 | 6 |
import eu.dnetlib.data.collector.rmi.CollectorServiceException; |
10 | 7 |
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor; |
11 | 8 |
|
12 |
public class MediawikiCollectorPlugin implements CollectorPlugin {
|
|
9 |
public class MediawikiCollectorPlugin extends AbstractCollectorPlugin {
|
|
13 | 10 |
|
14 | 11 |
@Override |
15 |
public Iterable<String> collect(final InterfaceDescriptor interfaceDescriptor, final String fromDate, final String untilDate) throws CollectorServiceException { |
|
12 |
public Iterable<String> collect(final InterfaceDescriptor interfaceDescriptor, final String fromDate, final String untilDate) |
|
13 |
throws CollectorServiceException { |
|
16 | 14 |
final String baseUrl = interfaceDescriptor.getBaseUrl(); |
17 |
final String apnamespace= interfaceDescriptor.getParams().get("apnamespace"); |
|
18 |
|
|
19 |
if((baseUrl == null) || baseUrl.isEmpty()) |
|
20 |
throw new CollectorServiceException("Param 'baseurl' is null or empty"); |
|
21 |
|
|
22 |
if((apnamespace == null) || baseUrl.isEmpty()) |
|
23 |
throw new CollectorServiceException("Param 'apnamespace' is null or empty"); |
|
24 |
|
|
15 |
final String apnamespace = interfaceDescriptor.getParams().get("apnamespace"); |
|
16 |
|
|
17 |
if (baseUrl == null || baseUrl.isEmpty()) { throw new CollectorServiceException("Param 'baseurl' is null or empty"); } |
|
18 |
|
|
19 |
if (apnamespace == null || baseUrl.isEmpty()) { throw new CollectorServiceException("Param 'apnamespace' is null or empty"); } |
|
20 |
|
|
25 | 21 |
return new Iterable<String>() { |
22 |
|
|
26 | 23 |
@Override |
27 | 24 |
public Iterator<String> iterator() { |
28 | 25 |
return new MediawikiIterator(baseUrl, apnamespace); |
... | ... | |
30 | 27 |
}; |
31 | 28 |
} |
32 | 29 |
|
33 |
@Override |
|
34 |
public String getProtocol() { |
|
35 |
return "mediawiki"; |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public List<String> listNameParameters() { |
|
40 |
return Lists.newArrayList("apnamespace"); |
|
41 |
} |
|
42 |
|
|
43 | 30 |
} |
Also available in: Unified diff
updates in collector plugins