Project

General

Profile

« Previous | Next » 

Revision 55262

Datacite plugin now gets the baseUrl from the interfacedescriptor

View differences:

DataciteCollectorPlugin.java
1 1
package eu.dnetlib.data.collector.plugins.datacite;
2 2

  
3
import java.util.Date;
4

  
3 5
import eu.dnetlib.data.collector.plugin.AbstractCollectorPlugin;
4 6
import eu.dnetlib.data.collector.plugin.CollectorPlugin;
5 7
import eu.dnetlib.data.collector.rmi.CollectorServiceException;
6 8
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor;
7 9
import eu.dnetlib.miscutils.datetime.DateUtils;
8

  
9 10
import org.apache.commons.lang3.StringUtils;
11
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
10 13

  
11
import java.util.Date;
12

  
13 14
public class DataciteCollectorPlugin extends AbstractCollectorPlugin implements CollectorPlugin {
14 15

  
16
    private static final Log log = LogFactory.getLog(DataciteCollectorPlugin.class);
15 17

  
16 18
    @Override
17 19
    public Iterable<String> collect(InterfaceDescriptor interfaceDescriptor, String fromDate, String untilDate) throws CollectorServiceException {
18 20

  
21
        String baseurl = interfaceDescriptor.getBaseUrl();
22
        if(StringUtils.isBlank(baseurl)) throw new CollectorServiceException("baseUrl cannot be empty");
19 23
        long timestamp= 0;
20 24
        if (StringUtils.isNotBlank(fromDate)) {
21 25
            Date parsed = new DateUtils().parse(fromDate);
22 26
            timestamp =parsed.getTime() /1000;
27
            log.debug("Querying for Datacite records from timestamp "+timestamp+" (date was "+fromDate+")");
23 28
        }
24 29

  
25 30
        final long finalTimestamp = timestamp;
26 31
        return () -> {
27 32
            try {
28
                return new DataciteESIterator(finalTimestamp);
33
                return new DataciteESIterator(finalTimestamp, baseurl);
29 34
            } catch (Exception e) {
30 35
                throw new RuntimeException(e );
31 36
            }

Also available in: Unified diff