1
|
package eu.dnetlib.data.collector.plugins.filesystem;
|
2
|
|
3
|
import eu.dnetlib.data.collector.plugin.AbstractCollectorPlugin;
|
4
|
import eu.dnetlib.data.collector.rmi.CollectorServiceException;
|
5
|
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor;
|
6
|
import org.apache.commons.lang3.StringUtils;
|
7
|
|
8
|
/**
|
9
|
*
|
10
|
* @author andrea
|
11
|
*
|
12
|
*/
|
13
|
public class FilesystemCollectorPlugin extends AbstractCollectorPlugin {
|
14
|
|
15
|
@Override
|
16
|
public Iterable<String> collect(final InterfaceDescriptor interfaceDescriptor, final String fromDate, final String untilDate)
|
17
|
throws CollectorServiceException {
|
18
|
|
19
|
final String baseUrl = interfaceDescriptor.getBaseUrl();
|
20
|
if (baseUrl == null || baseUrl.isEmpty()) { throw new CollectorServiceException("Param 'baseurl' is null or empty"); }
|
21
|
|
22
|
if (StringUtils.isNotBlank(fromDate) && !fromDate.matches("\\d{4}-\\d{2}-\\d{2}")) { throw new CollectorServiceException("Invalid date (YYYY-MM-DD): " + fromDate); }
|
23
|
return new FilesystemIterable(interfaceDescriptor, fromDate);
|
24
|
}
|
25
|
|
26
|
}
|