1
|
package eu.dnetlib.data.collector.plugins.remotemdstore;
|
2
|
|
3
|
import org.apache.commons.lang3.StringUtils;
|
4
|
|
5
|
import eu.dnetlib.data.collector.plugin.AbstractCollectorPlugin;
|
6
|
import eu.dnetlib.data.collector.rmi.CollectorServiceException;
|
7
|
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor;
|
8
|
|
9
|
public class RemoteMdstorePlugin extends AbstractCollectorPlugin {
|
10
|
|
11
|
// URL Example: mongodb://[username:password@]host[:port]
|
12
|
|
13
|
@Override
|
14
|
public Iterable<String> collect(final InterfaceDescriptor interfaceDescriptor, final String fromDate, final String untilDate)
|
15
|
throws CollectorServiceException {
|
16
|
|
17
|
final String baseUrl = interfaceDescriptor.getBaseUrl();
|
18
|
final String dbName = interfaceDescriptor.getParams().get("remote_database");
|
19
|
final String mdId = interfaceDescriptor.getParams().get("remote_mdstore_id");
|
20
|
|
21
|
if (StringUtils.isBlank(baseUrl)) { throw new CollectorServiceException("Invalid baseUrl, example: mongodb://[username:password@]host[:port]"); }
|
22
|
if (StringUtils.isBlank(dbName)) { throw new CollectorServiceException("Empty parameter: remote_database"); }
|
23
|
if (StringUtils.isBlank(mdId)) { throw new CollectorServiceException("Empty parameter: remote_mdstore_id"); }
|
24
|
|
25
|
return () -> {
|
26
|
try {
|
27
|
return new RemoteMdStoreIterator(baseUrl, dbName, mdId);
|
28
|
} catch (final CollectorServiceException e) {
|
29
|
throw new RuntimeException(e);
|
30
|
}
|
31
|
};
|
32
|
}
|
33
|
}
|