Project

General

Profile

« Previous | Next » 

Revision 45312

codebase used to migrate to java8 the production system

View differences:

modules/dnet-download-plugins/trunk/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
	<modelVersion>4.0.0</modelVersion>
3
	<parent>
4
		<groupId>eu.dnetlib</groupId>
5
		<artifactId>dnet-parent</artifactId>
6
		<version>1.0.0</version>
7
	</parent>
8
	<groupId>eu.dnetlib</groupId>
9
	<artifactId>dnet-download-plugins</artifactId>
10
	<version>2.1.16-SNAPSHOT</version>
11
	<scm>
12
	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-download-plugins/trunk</developerConnection>
13
	</scm>
14
	<dependencies>
15
		<dependency>
16
			<groupId>eu.dnetlib</groupId>
17
			<artifactId>dnet-download-service</artifactId>
18
			<version>[2.0.0,3.0.0)</version>
19
		</dependency>
20
		<dependency>
21
			<groupId>org.jsoup</groupId>
22
			<artifactId>jsoup</artifactId>
23
			<version>1.7.2</version>
24
		</dependency>
25
		<dependency>
26
			<groupId>joda-time</groupId>
27
			<artifactId>joda-time</artifactId>
28
			<version>2.3</version>
29
		</dependency>
30
		<dependency>
31
			<groupId>junit</groupId>
32
			<artifactId>junit</artifactId>
33
			<version>${junit.version}</version>
34
			<scope>test</scope>
35
		</dependency>
36
	</dependencies>
37

  
38
</project>
modules/dnet-download-plugins/trunk/src/main/java/eu/dnetlib/download/plugin/HindawiDownloadPlugin.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.nio.file.FileSystems;
4
import java.nio.file.Files;
5
import java.nio.file.Path;
6
import java.util.ArrayList;
7
import java.util.List;
8

  
9
import com.google.common.base.Function;
10
import com.google.common.collect.Iterables;
11
import com.google.gson.Gson;
12
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
13
import eu.dnetlib.data.download.rmi.DownloadItem;
14
import eu.dnetlib.data.download.rmi.DownloadPlugin;
15
import eu.dnetlib.data.download.rmi.DownloadPluginException;
16

  
17
/**
18
 * Created by sandro on 3/1/16.
19
 */
20
public class HindawiDownloadPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
21

  
22
	private String basePath;
23

  
24
	private Gson gson;
25

  
26
	public HindawiDownloadPlugin() {
27
		this.gson = new Gson();
28
	}
29

  
30
	@Override
31
	public String extractURL(final String baseURL) throws DownloadPluginException {
32
		return null;
33
	}
34

  
35
	@Override
36
	public void setBasePath(final String basePath) {
37
		this.basePath = basePath;
38
	}
39

  
40
	/*
41
	 * (non-Javadoc)
42
     *
43
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
44
     */
45
	@Override
46
	public String getPluginName() {
47
		return "HindawiDownloadPlugin";
48
	}
49

  
50
	@Override
51
	public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) throws DownloadPluginException {
52
		return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
53

  
54
			@Override
55
			public DownloadItem apply(final DownloadItem input) {
56
				return retrieveUrl(input);
57
			}
58
		});
59
	}
60

  
61
	/*
62
	 * (non-Javadoc)
63
	 *
64
	 * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
65
	 */
66
	@Override
67
	public DownloadItem retrieveUrl(final DownloadItem input) throws DownloadPluginException {
68

  
69
		List<String> inputList = this.gson.fromJson(input.getUrl(), ArrayList.class);
70
		if (inputList == null || inputList.size() == 0) {
71
			input.setUrl(null);
72
			return input;
73
		}
74

  
75
		for (String fileUrl : inputList) {
76
			Path inputhPath = FileSystems.getDefault().getPath(basePath).resolve("." + fileUrl);
77
			if (Files.exists(inputhPath)) {
78
				input.setOriginalUrl("file://" + inputhPath.toString());
79
				input.setUrl("file://" + inputhPath.toString());
80
				return input;
81
			}
82
		}
83
		input.setUrl(null);
84
		return input;
85
	}
86
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.14/src/main/java/eu/dnetlib/download/plugin/EuropePMC.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import com.google.common.base.Function;
7
import com.google.common.collect.Iterables;
8
import com.google.gson.Gson;
9
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
10
import eu.dnetlib.data.download.rmi.DownloadItem;
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginException;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
15

  
16
// TODO: Auto-generated Javadoc
17

  
18
/**
19
 * The Class EuropePMC.
20
 */
21
public class EuropePMC extends AbstractDownloadPlugin implements DownloadPlugin {
22

  
23
    private static final Log log = LogFactory.getLog(EuropePMC.class);
24

  
25
    /**
26
     * The base path.
27
     */
28
    private String basePath;
29

  
30
    // //*[local-name()='metadata']//*[local-name()='identifier' and ./@identifierType='pmc']/text()
31

  
32
    /*
33
     * (non-Javadoc)
34
     *
35
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
36
     */
37
    @Override
38
    public String getPluginName() {
39
        return "europePMCDownloadPlugin";
40
    }
41

  
42
    @Override
43
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) throws DownloadPluginException {
44
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
45

  
46
            @Override
47
            public DownloadItem apply(final DownloadItem input) {
48
                return retrieveUrl(input);
49
            }
50
        });
51
    }
52

  
53
    /*
54
     * (non-Javadoc)
55
     *
56
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
57
     */
58
    @Override
59
    public DownloadItem retrieveUrl(final DownloadItem input) throws DownloadPluginException {
60

  
61
        try {
62
            String url = input.getOriginalUrl();
63
            if ((url == null) || (url.trim().length() == 0)) return input;
64
            @SuppressWarnings("unchecked")
65
            List<String> urls = new Gson().fromJson(url, ArrayList.class);
66
            log.debug(String.format("urls is %s", url));
67
            if ((urls == null) || (urls.size() == 0)) return input;
68
            input.setFileName(input.getIdItemMetadata());
69
            Boolean added = false;
70
            for (String s : urls) {
71
                if (s.startsWith("http")) {
72
                    log.debug(String.format("found url starting with http replace original URL with %s", s));
73
                    input.setOriginalUrl(s);
74
                } else if (s.startsWith("PMC")) {
75
                    String correctUrl = s.replace("PMC", "");
76
                    log.debug(String.format("found url starting with PMC %s", correctUrl));
77
                    added = true;
78
                    String path = PathRetreiver.getInstance(basePath).getPathForPMCID(Integer.parseInt(correctUrl));
79
                    if (path != null) {
80
                        input.setUrl("file://" + path);
81
                    } else {
82
                        input.setUrl(path);
83
                    }
84

  
85
                }
86
            }
87
            if (added == false) {
88
                input.setOriginalUrl(null);
89
                input.setUrl(null);
90
            }
91
            return input;
92
        } catch (Throwable e) {
93
            log.error("Exception on Download Plugin");
94
            log.error(e);
95
            throw new DownloadPluginException(e);
96
        }
97

  
98
    }
99

  
100
    /**
101
     * Gets the base path.
102
     *
103
     * @return the basePath
104
     */
105
    public String getBasePath() {
106
        return basePath;
107
    }
108

  
109
    /**
110
     * Sets the base path.
111
     *
112
     * @param basePath the basePath to set
113
     */
114
    @Override
115
    public void setBasePath(final String basePath) {
116
        this.basePath = basePath;
117
    }
118

  
119
    @Override
120
    public String extractURL(String baseURL) throws DownloadPluginException {
121
        return null;
122
    }
123
}
modules/dnet-download-plugins/trunk/src/main/java/eu/dnetlib/download/plugin/FollowPDFLinkPlugins.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.net.HttpURLConnection;
4
import java.net.URL;
5
import java.util.ArrayList;
6
import java.util.List;
7

  
8
import com.google.common.base.Function;
9
import com.google.common.collect.Iterables;
10
import com.google.gson.Gson;
11
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadItem;
13
import eu.dnetlib.data.download.rmi.DownloadPlugin;
14
import eu.dnetlib.data.download.rmi.DownloadPluginException;
15
import org.apache.commons.logging.Log;
16
import org.apache.commons.logging.LogFactory;
17
import org.jsoup.Jsoup;
18
import org.jsoup.nodes.Document;
19
import org.jsoup.nodes.Element;
20
import org.jsoup.select.Elements;
21

  
22
public class FollowPDFLinkPlugins extends AbstractDownloadPlugin implements DownloadPlugin {
23

  
24
    /**
25
     * The Constant log.
26
     */
27
    private static final Log log = LogFactory.getLog(FollowPDFLinkPlugins.class);
28

  
29
    private final static int maxNumberJump = 10;
30

  
31
    /**
32
     * Extract url.
33
     *
34
     * @param url the url
35
     * @return the string
36
     */
37
    @Override
38
    public String extractURL(final String url) throws DownloadPluginException {
39
        try {
40
            URL startURL = new URL(url);
41
            HttpURLConnection conn = (HttpURLConnection) startURL.openConnection();
42

  
43
	        conn.setConnectTimeout(AbstractDownloadPlugin.DEFAULT_TIMEOUT);
44

  
45
            conn.setInstanceFollowRedirects(true);  // you still need to handle redirect manully.
46
            HttpURLConnection.setFollowRedirects(true);
47
            String location = url;
48

  
49
            int numJump =1;
50

  
51
            int responseCode = conn.getResponseCode();
52

  
53
            while ((responseCode >= 300) && (responseCode < 400) &&  (numJump++ < maxNumberJump)) {
54
                location = conn.getHeaderFields().get("Location").get(0);
55
                conn.disconnect();
56
                startURL = new URL(location);
57
                conn = (HttpURLConnection) startURL.openConnection();
58
                conn.setConnectTimeout(AbstractDownloadPlugin.DEFAULT_TIMEOUT);
59
                conn.setInstanceFollowRedirects(true);  // you still need to handle redirect manully.
60
                HttpURLConnection.setFollowRedirects(true);
61
                responseCode = conn.getResponseCode();
62
            }
63
            conn.disconnect();
64
            if (!((responseCode >= 200) && (responseCode < 300)))
65
                return null;
66
            Document doc = Jsoup.connect(location).get();
67
            Elements links = doc.select("a[href$=.pdf]");
68

  
69
            for (Element link : links) {
70
                String linkValue = link.attr("abs:href");
71
                if (regularExpression != null) {
72
                    for (String regex : regularExpression) {
73
                        if (linkValue.matches(regex))
74
                            return linkValue;
75
                    }
76
                } else
77
                    return linkValue;
78
            }
79
            return null;
80
        } catch (Throwable e) {
81
	        throw new DownloadPluginException("Error on extract URL", e);
82
        }
83

  
84
    }
85

  
86
    @Override
87
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
88
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
89

  
90
            @Override
91
            public DownloadItem apply(final DownloadItem input) {
92
                return retrieveUrl(input);
93
            }
94
        });
95
    }
96

  
97
    /*
98
     * (non-Javadoc)
99
     *
100
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
101
     */
102
    @Override
103
    public String getPluginName() {
104
        return "FollowPDFLinkPlugins";
105
    }
106

  
107
    /*
108
     * (non-Javadoc)
109
     *
110
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
111
     */
112
    @Override
113
    public DownloadItem retrieveUrl(final DownloadItem input) {
114
        if (checkOpenAccess(input) == null) return null;
115
        String url = input.getOriginalUrl();
116

  
117
        if ((url == null) || (url.trim().length() == 0)) return input;
118
        @SuppressWarnings("unchecked")
119
        List<String> urls = new Gson().fromJson(url, ArrayList.class);
120
        if ((urls == null) || (urls.size() == 0)) return input;
121
        if (checkUrlsNotNull(input, urls))
122
            return input;
123
        input.setOriginalUrl(null);
124
        input.setUrl(null);
125
        return input;
126
    }
127

  
128
    @Override
129
    public void setBasePath(final String basePath) {
130
        // TODO Auto-generated method stub
131

  
132
    }
133

  
134
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.14/src/main/java/eu/dnetlib/download/plugin/ELisDownloadPlugin.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import com.google.common.base.Function;
7
import com.google.common.collect.Iterables;
8
import com.google.gson.Gson;
9
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
10
import eu.dnetlib.data.download.rmi.DownloadItem;
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginException;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
15
import org.jsoup.Jsoup;
16
import org.jsoup.nodes.Document;
17
import org.jsoup.nodes.Element;
18
import org.jsoup.select.Elements;
19

  
20
/**
21
 * The Class ELisDownloadPlugin.
22
 */
23
public class ELisDownloadPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
24

  
25
    /**
26
     * The Constant log.
27
     */
28
    private static final Log log = LogFactory.getLog(ELisDownloadPlugin.class);
29

  
30
    /**
31
     * Extract url.
32
     *
33
     * @param url the url
34
     * @return the string
35
     */
36
    @Override
37
    public String extractURL(final String url) throws DownloadPluginException {
38
        try {
39
            Document doc = Jsoup.connect(url).get();
40
            Elements links = doc.select("a[href$=.pdf]");
41
            for (Element link : links) {
42
                String linkvalue = link.attr("abs:href");
43
                if (!linkvalue.toLowerCase().contains("thumbnailversion")) {
44
                    return linkvalue;
45
                }
46
            }
47
            return null;
48
        } catch (Exception e) {
49
            throw new DownloadPluginException("Error on extract URL", e);
50
        }
51

  
52
    }
53

  
54
    @Override
55
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
56
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
57

  
58
            @Override
59
            public DownloadItem apply(final DownloadItem input) {
60
                return retrieveUrl(input);
61
            }
62
        });
63
    }
64

  
65
    /*
66
     * (non-Javadoc)
67
     *
68
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
69
     */
70
    @Override
71
    public String getPluginName() {
72
        return "ELisDownloadPlugin";
73
    }
74

  
75
    /*
76
     * (non-Javadoc)
77
     *
78
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
79
     */
80
    @Override
81
    public DownloadItem retrieveUrl(final DownloadItem input) {
82
        if (checkOpenAccess(input) == null) {
83
            return null;
84
        }
85
        String url = input.getOriginalUrl();
86

  
87
        if (url == null || url.trim().length() == 0) {
88
            return input;
89
        }
90
        @SuppressWarnings("unchecked")
91
        List<String> urls = new Gson().fromJson(url, ArrayList.class);
92
        if (urls == null || urls.size() == 0) {
93
            return input;
94
        }
95
        if (checkUrlsNotNull(input, urls))
96
            return input;
97
        input.setOriginalUrl(null);
98
        input.setUrl(null);
99
        return input;
100
    }
101

  
102
    @Override
103
    public void setBasePath(final String basePath) {
104
        // TODO Auto-generated method stub
105

  
106
    }
107

  
108
}
modules/dnet-download-plugins/trunk/src/main/java/eu/dnetlib/download/plugin/EuropePMC.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import com.google.common.base.Function;
7
import com.google.common.collect.Iterables;
8
import com.google.gson.Gson;
9
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
10
import eu.dnetlib.data.download.rmi.DownloadItem;
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginException;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
15

  
16
// TODO: Auto-generated Javadoc
17

  
18
/**
19
 * The Class EuropePMC.
20
 */
21
public class EuropePMC extends AbstractDownloadPlugin implements DownloadPlugin {
22

  
23
    private static final Log log = LogFactory.getLog(EuropePMC.class);
24

  
25
    /**
26
     * The base path.
27
     */
28
    private String basePath;
29

  
30
    // //*[local-name()='metadata']//*[local-name()='identifier' and ./@identifierType='pmc']/text()
31

  
32
    /*
33
     * (non-Javadoc)
34
     *
35
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
36
     */
37
    @Override
38
    public String getPluginName() {
39
        return "europePMCDownloadPlugin";
40
    }
41

  
42
    @Override
43
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) throws DownloadPluginException {
44
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
45

  
46
            @Override
47
            public DownloadItem apply(final DownloadItem input) {
48
                return retrieveUrl(input);
49
            }
50
        });
51
    }
52

  
53
    /*
54
     * (non-Javadoc)
55
     *
56
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
57
     */
58
    @Override
59
    public DownloadItem retrieveUrl(final DownloadItem input) throws DownloadPluginException {
60

  
61
        try {
62
            String url = input.getOriginalUrl();
63
            if ((url == null) || (url.trim().length() == 0)) return input;
64
            @SuppressWarnings("unchecked")
65
            List<String> urls = new Gson().fromJson(url, ArrayList.class);
66
            log.debug(String.format("urls is %s", url));
67
            if ((urls == null) || (urls.size() == 0)) return input;
68
            input.setFileName(input.getIdItemMetadata());
69
            Boolean added = false;
70
            for (String s : urls) {
71
                if (s.startsWith("http")) {
72
                    log.debug(String.format("found url starting with http replace original URL with %s", s));
73
                    input.setOriginalUrl(s);
74
                } else if (s.startsWith("PMC")) {
75
                    String correctUrl = s.replace("PMC", "");
76
                    log.debug(String.format("found url starting with PMC %s", correctUrl));
77
                    added = true;
78
                    String path = PathRetreiver.getInstance(basePath).getPathForPMCID(Integer.parseInt(correctUrl));
79
                    if (path != null) {
80
                        input.setUrl("file://" + path);
81
                    } else {
82
                        input.setUrl(path);
83
                    }
84

  
85
                }
86
            }
87
            if (added == false) {
88
                input.setOriginalUrl(null);
89
                input.setUrl(null);
90
            }
91
            return input;
92
        } catch (Throwable e) {
93
            log.error("Exception on Download Plugin");
94
            log.error(e);
95
            throw new DownloadPluginException(e);
96
        }
97

  
98
    }
99

  
100
    /**
101
     * Gets the base path.
102
     *
103
     * @return the basePath
104
     */
105
    public String getBasePath() {
106
        return basePath;
107
    }
108

  
109
    /**
110
     * Sets the base path.
111
     *
112
     * @param basePath the basePath to set
113
     */
114
    @Override
115
    public void setBasePath(final String basePath) {
116
        this.basePath = basePath;
117
    }
118

  
119
    @Override
120
    public String extractURL(String baseURL) throws DownloadPluginException {
121
        return null;
122
    }
123
}
modules/dnet-download-plugins/trunk/src/main/java/eu/dnetlib/download/plugin/ArxivDownloadPlugin.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import com.google.common.base.Function;
7
import com.google.common.collect.Iterables;
8
import com.google.gson.Gson;
9
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
10
import eu.dnetlib.data.download.rmi.DownloadItem;
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginException;
13

  
14
public class ArxivDownloadPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
15

  
16
    @Override
17
    public DownloadItem retrieveUrl(final DownloadItem input) {
18
        if (checkOpenAccess(input) == null) {
19
            return null;
20
        }
21
        String url = input.getOriginalUrl();
22
        if (url == null || url.trim().length() == 0) {
23
            return input;
24
        }
25
        @SuppressWarnings("unchecked")
26
        List<String> urls = new Gson().fromJson(url, ArrayList.class);
27
        if (urls == null || urls.size() == 0) {
28
            return input;
29
        }
30
        for (String s : urls) {
31
            if (s.startsWith("http")) {
32
                input.setOriginalUrl(s);
33
                String correctUrl = s.replace("abs", "pdf");
34
                correctUrl += ".pdf";
35
                input.setUrl(correctUrl);
36
            }
37
        }
38
        return input;
39
    }
40

  
41
    @Override
42
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
43
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
44

  
45
            @Override
46
            public DownloadItem apply(final DownloadItem input) {
47
                return retrieveUrl(input);
48
            }
49
        });
50
    }
51

  
52
    @Override
53
    public String getPluginName() {
54
        return "ArxivDownloadPlugin";
55
    }
56

  
57
    @Override
58
    public void setBasePath(final String basePath) {
59

  
60
    }
61

  
62
    @Override
63
    public String extractURL(String baseURL) throws DownloadPluginException {
64
        return null;
65
    }
66
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.14/src/main/java/eu/dnetlib/download/plugin/HALPdfDocumentPlugin.java
1
/**
2
 *
3
 */
4
package eu.dnetlib.download.plugin;
5

  
6
import java.util.ArrayList;
7
import java.util.List;
8

  
9
import com.google.common.base.Function;
10
import com.google.common.collect.Iterables;
11
import com.google.gson.Gson;
12
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
13
import eu.dnetlib.data.download.rmi.DownloadItem;
14
import eu.dnetlib.data.download.rmi.DownloadPlugin;
15
import eu.dnetlib.data.download.rmi.DownloadPluginException;
16
import org.apache.commons.logging.Log;
17
import org.apache.commons.logging.LogFactory;
18

  
19

  
20
/**
21
 * @author sandro
22
 */
23
public class HALPdfDocumentPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
24

  
25
    private static final Log log = LogFactory.getLog(HALPdfDocumentPlugin.class); // NOPMD by marko on 11/24/08 5:02 PM
26

  
27

  
28
    /**
29
     * {@inheritDoc}
30
     *
31
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
32
     */
33
    @Override
34
    public String getPluginName() {
35
        // TODO Auto-generated method stub
36
        return "HALPdfDocumentPlugin";
37
    }
38

  
39
    /**
40
     * {@inheritDoc}
41
     *
42
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrls(java.lang.Iterable)
43
     */
44
    @Override
45
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
46
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
47

  
48
            @Override
49
            public DownloadItem apply(final DownloadItem input) {
50
                return retrieveUrl(input);
51
            }
52
        });
53
    }
54

  
55
    /**
56
     * {@inheritDoc}
57
     *
58
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
59
     */
60
    @Override
61
    public DownloadItem retrieveUrl(final DownloadItem input) {
62
        try {
63
            if (checkOpenAccess(input) == null) return null;
64
            if (input == null) return null;
65
            String url = input.getOriginalUrl();
66

  
67
            if ((url == null) || (url.trim().length() == 0)) return input;
68
            @SuppressWarnings("unchecked")
69
            List<String> urls = new Gson().fromJson(url, ArrayList.class);
70
            if ((urls == null) || (urls.size() == 0)) return input;
71
            if (checkUrlsNotNull(input, urls)) return input;
72
            input.setOriginalUrl(null);
73
            input.setUrl(null);
74
            return input;
75
        } catch (Throwable e) {
76
            log.error("Error on retreiving URL", e);
77
            input.setOriginalUrl(null);
78
            input.setUrl(null);
79
            return input;
80
        }
81
    }
82

  
83
    /**
84
     * {@inheritDoc}
85
     *
86
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#setBasePath(java.lang.String)
87
     */
88
    @Override
89
    public void setBasePath(final String arg0) {
90
        // TODO Auto-generated method stub
91

  
92
    }
93

  
94
    @Override
95
    public String extractURL(String baseURL) throws DownloadPluginException {
96
        return baseURL.toLowerCase().endsWith("document") ? baseURL : null;
97
    }
98
}
modules/dnet-download-plugins/trunk/src/main/java/eu/dnetlib/download/plugin/EasyPDFDownloadPlugin.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import com.google.common.base.Function;
7
import com.google.common.collect.Iterables;
8
import com.google.gson.Gson;
9
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
10
import eu.dnetlib.data.download.rmi.DownloadItem;
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginException;
13

  
14
/**
15
 * The Class EasyPDFDownloadPlugin.
16
 */
17
public class EasyPDFDownloadPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
18

  
19
    /*
20
     * (non-Javadoc)
21
     *
22
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
23
     */
24
    @Override
25
    public DownloadItem retrieveUrl(final DownloadItem input) {
26
        if (checkOpenAccess(input) == null) {
27
            return null;
28
        }
29
        if (input == null) {
30
            return null;
31
        }
32
        String url = input.getOriginalUrl();
33

  
34
        if (url == null || url.trim().length() == 0) {
35
            return input;
36
        }
37
        @SuppressWarnings("unchecked")
38
        List<String> urls = new Gson().fromJson(url, ArrayList.class);
39
        if (urls == null || urls.size() == 0) {
40
            return input;
41
        }
42
        if (checkUrlsNotNull(input, urls))
43
            return input;
44
        input.setOriginalUrl(null);
45
        input.setUrl(null);
46
        return input;
47
    }
48

  
49
    @Override
50
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
51
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
52

  
53
            @Override
54
            public DownloadItem apply(final DownloadItem input) {
55
                return retrieveUrl(input);
56
            }
57
        });
58
    }
59

  
60
    /*
61
     * (non-Javadoc)
62
     *
63
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
64
     */
65
    @Override
66
    public String getPluginName() {
67
        return "easyPDFDownloadPlugin";
68
    }
69

  
70
    @Override
71
    public void setBasePath(final String basePath) {
72
        // TODO Auto-generated method stub
73

  
74
    }
75

  
76
    @Override
77
    public String extractURL(String baseURL) throws DownloadPluginException {
78
        return baseURL.endsWith(".pdf") ? baseURL : null;
79
    }
80
}
modules/dnet-download-plugins/trunk/src/main/java/eu/dnetlib/download/plugin/ELisDownloadPlugin.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import com.google.common.base.Function;
7
import com.google.common.collect.Iterables;
8
import com.google.gson.Gson;
9
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
10
import eu.dnetlib.data.download.rmi.DownloadItem;
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginException;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
15
import org.jsoup.Jsoup;
16
import org.jsoup.nodes.Document;
17
import org.jsoup.nodes.Element;
18
import org.jsoup.select.Elements;
19

  
20
/**
21
 * The Class ELisDownloadPlugin.
22
 */
23
public class ELisDownloadPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
24

  
25
    /**
26
     * The Constant log.
27
     */
28
    private static final Log log = LogFactory.getLog(ELisDownloadPlugin.class);
29

  
30
    /**
31
     * Extract url.
32
     *
33
     * @param url the url
34
     * @return the string
35
     */
36
    @Override
37
    public String extractURL(final String url) throws DownloadPluginException {
38
        try {
39
            Document doc = Jsoup.connect(url).get();
40
            Elements links = doc.select("a[href$=.pdf]");
41
            for (Element link : links) {
42
                String linkvalue = link.attr("abs:href");
43
                if (!linkvalue.toLowerCase().contains("thumbnailversion")) {
44
                    return linkvalue;
45
                }
46
            }
47
            return null;
48
        } catch (Exception e) {
49
            throw new DownloadPluginException("Error on extract URL", e);
50
        }
51

  
52
    }
53

  
54
    @Override
55
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
56
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
57

  
58
            @Override
59
            public DownloadItem apply(final DownloadItem input) {
60
                return retrieveUrl(input);
61
            }
62
        });
63
    }
64

  
65
    /*
66
     * (non-Javadoc)
67
     *
68
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
69
     */
70
    @Override
71
    public String getPluginName() {
72
        return "ELisDownloadPlugin";
73
    }
74

  
75
    /*
76
     * (non-Javadoc)
77
     *
78
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
79
     */
80
    @Override
81
    public DownloadItem retrieveUrl(final DownloadItem input) {
82
        if (checkOpenAccess(input) == null) {
83
            return null;
84
        }
85
        String url = input.getOriginalUrl();
86

  
87
        if (url == null || url.trim().length() == 0) {
88
            return input;
89
        }
90
        @SuppressWarnings("unchecked")
91
        List<String> urls = new Gson().fromJson(url, ArrayList.class);
92
        if (urls == null || urls.size() == 0) {
93
            return input;
94
        }
95
        if (checkUrlsNotNull(input, urls))
96
            return input;
97
        input.setOriginalUrl(null);
98
        input.setUrl(null);
99
        return input;
100
    }
101

  
102
    @Override
103
    public void setBasePath(final String basePath) {
104
        // TODO Auto-generated method stub
105

  
106
    }
107

  
108
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.15/src/main/java/eu/dnetlib/download/plugin/HALPdfDocumentPlugin.java
1
/**
2
 *
3
 */
4
package eu.dnetlib.download.plugin;
5

  
6
import java.util.ArrayList;
7
import java.util.List;
8

  
9
import com.google.common.base.Function;
10
import com.google.common.collect.Iterables;
11
import com.google.gson.Gson;
12
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
13
import eu.dnetlib.data.download.rmi.DownloadItem;
14
import eu.dnetlib.data.download.rmi.DownloadPlugin;
15
import eu.dnetlib.data.download.rmi.DownloadPluginException;
16
import org.apache.commons.logging.Log;
17
import org.apache.commons.logging.LogFactory;
18

  
19

  
20
/**
21
 * @author sandro
22
 */
23
public class HALPdfDocumentPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
24

  
25
    private static final Log log = LogFactory.getLog(HALPdfDocumentPlugin.class); // NOPMD by marko on 11/24/08 5:02 PM
26

  
27

  
28
    /**
29
     * {@inheritDoc}
30
     *
31
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
32
     */
33
    @Override
34
    public String getPluginName() {
35
        // TODO Auto-generated method stub
36
        return "HALPdfDocumentPlugin";
37
    }
38

  
39
    /**
40
     * {@inheritDoc}
41
     *
42
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrls(java.lang.Iterable)
43
     */
44
    @Override
45
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
46
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
47

  
48
            @Override
49
            public DownloadItem apply(final DownloadItem input) {
50
                return retrieveUrl(input);
51
            }
52
        });
53
    }
54

  
55
    /**
56
     * {@inheritDoc}
57
     *
58
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
59
     */
60
    @Override
61
    public DownloadItem retrieveUrl(final DownloadItem input) {
62
        try {
63
            if (checkOpenAccess(input) == null) return null;
64
            if (input == null) return null;
65
            String url = input.getOriginalUrl();
66

  
67
            if ((url == null) || (url.trim().length() == 0)) return input;
68
            @SuppressWarnings("unchecked")
69
            List<String> urls = new Gson().fromJson(url, ArrayList.class);
70
            if ((urls == null) || (urls.size() == 0)) return input;
71
            if (checkUrlsNotNull(input, urls)) return input;
72
            input.setOriginalUrl(null);
73
            input.setUrl(null);
74
            return input;
75
        } catch (Throwable e) {
76
            log.error("Error on retreiving URL", e);
77
            input.setOriginalUrl(null);
78
            input.setUrl(null);
79
            return input;
80
        }
81
    }
82

  
83
    /**
84
     * {@inheritDoc}
85
     *
86
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#setBasePath(java.lang.String)
87
     */
88
    @Override
89
    public void setBasePath(final String arg0) {
90
        // TODO Auto-generated method stub
91

  
92
    }
93

  
94
    @Override
95
    public String extractURL(String baseURL) throws DownloadPluginException {
96
        return baseURL.toLowerCase().endsWith("document") ? baseURL : null;
97
    }
98
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.15/src/main/java/eu/dnetlib/download/plugin/InfoPath.java
1
package eu.dnetlib.download.plugin;
2

  
3
/**
4
 * The Class InfoPath.
5
 */
6
public class InfoPath {
7

  
8
	/** The lower. */
9
	private int lower;
10

  
11
	/** The upper. */
12
	private int upper;
13

  
14
	/** The path. */
15
	private String path;
16

  
17
	/**
18
	 * Gets the lower.
19
	 *
20
	 * @return the lower
21
	 */
22
	public int getLower() {
23
		return lower;
24
	}
25

  
26
	/**
27
	 * Sets the lower.
28
	 *
29
	 * @param lower
30
	 *            the new lower
31
	 */
32
	public void setLower(final int lower) {
33
		this.lower = lower;
34
	}
35

  
36
	/**
37
	 * Gets the upper.
38
	 *
39
	 * @return the upper
40
	 */
41
	public int getUpper() {
42
		return upper;
43
	}
44

  
45
	/**
46
	 * Sets the upper.
47
	 *
48
	 * @param upper
49
	 *            the new upper
50
	 */
51
	public void setUpper(final int upper) {
52
		this.upper = upper;
53
	}
54

  
55
	/**
56
	 * Gets the path.
57
	 *
58
	 * @return the path
59
	 */
60
	public String getPath() {
61
		return path;
62
	}
63

  
64
	/**
65
	 * Sets the path.
66
	 *
67
	 * @param path
68
	 *            the new path
69
	 */
70
	public void setPath(final String path) {
71
		this.path = path;
72
	}
73
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.15/src/test/java/eu/dnetlib/download/plugin/ArxivImportFromFileTest.java
1
package eu.dnetlib.download.plugin;
2

  
3
import junit.framework.Assert;
4

  
5
import org.junit.Before;
6
import org.junit.Test;
7

  
8
import com.google.gson.Gson;
9
import com.google.gson.GsonBuilder;
10

  
11
import eu.dnetlib.data.download.rmi.DownloadItem;
12

  
13
public class ArxivImportFromFileTest {
14

  
15
	@Before
16
	public void setUp() throws Exception {}
17

  
18
	@Test
19
	public void testREgEx() {
20
		String regExp = "\\d{4}\\.\\d{4}";
21

  
22
		String input = "1308.0021";
23

  
24
		Assert.assertTrue(input.matches(regExp));
25

  
26
	}
27

  
28
	@Test
29
	public void testPlugin() {
30
		DownloadItem item = new DownloadItem();
31
		item.setOpenAccess("OPEN");
32
		String[] myList = new String[] { "http://arxiv.org/abs/1308.0001", "b" };
33
		Gson g = new GsonBuilder().disableHtmlEscaping().create();
34
		item.setUrl(g.toJson(myList));
35

  
36
		ArxivImportFromFile plugin = new ArxivImportFromFile();
37
		plugin.setBasePath("/test/path");
38

  
39
		plugin.retrieveUrl(item);
40

  
41
		Assert.assertNotNull(item);
42

  
43
	}
44

  
45
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.14/src/test/java/eu/dnetlib/download/plugin/ArxivImportFromFileTest.java
1
package eu.dnetlib.download.plugin;
2

  
3
import junit.framework.Assert;
4

  
5
import org.junit.Before;
6
import org.junit.Test;
7

  
8
import com.google.gson.Gson;
9
import com.google.gson.GsonBuilder;
10

  
11
import eu.dnetlib.data.download.rmi.DownloadItem;
12

  
13
public class ArxivImportFromFileTest {
14

  
15
	@Before
16
	public void setUp() throws Exception {}
17

  
18
	@Test
19
	public void testREgEx() {
20
		String regExp = "\\d{4}\\.\\d{4}";
21

  
22
		String input = "1308.0021";
23

  
24
		Assert.assertTrue(input.matches(regExp));
25

  
26
	}
27

  
28
	@Test
29
	public void testPlugin() {
30
		DownloadItem item = new DownloadItem();
31
		item.setOpenAccess("OPEN");
32
		String[] myList = new String[] { "http://arxiv.org/abs/1308.0001", "b" };
33
		Gson g = new GsonBuilder().disableHtmlEscaping().create();
34
		item.setUrl(g.toJson(myList));
35

  
36
		ArxivImportFromFile plugin = new ArxivImportFromFile();
37
		plugin.setBasePath("/test/path");
38

  
39
		plugin.retrieveUrl(item);
40

  
41
		Assert.assertNotNull(item);
42

  
43
	}
44

  
45
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.15/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-download-plugins/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-download-plugins"}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.14/src/main/java/eu/dnetlib/download/plugin/FollowPDFLinkPlugins.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.net.HttpURLConnection;
4
import java.net.URL;
5
import java.util.ArrayList;
6
import java.util.List;
7

  
8
import com.google.common.base.Function;
9
import com.google.common.collect.Iterables;
10
import com.google.gson.Gson;
11
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadItem;
13
import eu.dnetlib.data.download.rmi.DownloadPlugin;
14
import eu.dnetlib.data.download.rmi.DownloadPluginException;
15
import org.apache.commons.logging.Log;
16
import org.apache.commons.logging.LogFactory;
17
import org.jsoup.Jsoup;
18
import org.jsoup.nodes.Document;
19
import org.jsoup.nodes.Element;
20
import org.jsoup.select.Elements;
21

  
22
public class FollowPDFLinkPlugins extends AbstractDownloadPlugin implements DownloadPlugin {
23

  
24
    /**
25
     * The Constant log.
26
     */
27
    private static final Log log = LogFactory.getLog(FollowPDFLinkPlugins.class);
28

  
29
    private final static int maxNumberJump = 10;
30

  
31
    /**
32
     * Extract url.
33
     *
34
     * @param url the url
35
     * @return the string
36
     */
37
    @Override
38
    public String extractURL(final String url) throws DownloadPluginException {
39
        try {
40
            URL startURL = new URL(url);
41
            HttpURLConnection conn = (HttpURLConnection) startURL.openConnection();
42

  
43
	        conn.setConnectTimeout(AbstractDownloadPlugin.DEFAULT_TIMEOUT);
44

  
45
            conn.setInstanceFollowRedirects(true);  // you still need to handle redirect manully.
46
            HttpURLConnection.setFollowRedirects(true);
47
            String location = url;
48

  
49
            int numJump =1;
50

  
51
            int responseCode = conn.getResponseCode();
52

  
53
            while ((responseCode >= 300) && (responseCode < 400) &&  (numJump++ < maxNumberJump)) {
54
                location = conn.getHeaderFields().get("Location").get(0);
55
                conn.disconnect();
56
                startURL = new URL(location);
57
                conn = (HttpURLConnection) startURL.openConnection();
58
                conn.setConnectTimeout(AbstractDownloadPlugin.DEFAULT_TIMEOUT);
59
                conn.setInstanceFollowRedirects(true);  // you still need to handle redirect manully.
60
                HttpURLConnection.setFollowRedirects(true);
61
                responseCode = conn.getResponseCode();
62
            }
63
            conn.disconnect();
64
            if (!((responseCode >= 200) && (responseCode < 300)))
65
                return null;
66
            Document doc = Jsoup.connect(location).get();
67
            Elements links = doc.select("a[href$=.pdf]");
68

  
69
            for (Element link : links) {
70
                String linkValue = link.attr("abs:href");
71
                if (regularExpression != null) {
72
                    for (String regex : regularExpression) {
73
                        if (linkValue.matches(regex))
74
                            return linkValue;
75
                    }
76
                } else
77
                    return linkValue;
78
            }
79
            return null;
80
        } catch (Throwable e) {
81
	        throw new DownloadPluginException("Error on extract URL", e);
82
        }
83

  
84
    }
85

  
86
    @Override
87
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) {
88
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
89

  
90
            @Override
91
            public DownloadItem apply(final DownloadItem input) {
92
                return retrieveUrl(input);
93
            }
94
        });
95
    }
96

  
97
    /*
98
     * (non-Javadoc)
99
     *
100
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
101
     */
102
    @Override
103
    public String getPluginName() {
104
        return "FollowPDFLinkPlugins";
105
    }
106

  
107
    /*
108
     * (non-Javadoc)
109
     *
110
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#retrieveUrl(eu.dnetlib.data.download.rmi.DownloadItem)
111
     */
112
    @Override
113
    public DownloadItem retrieveUrl(final DownloadItem input) {
114
        if (checkOpenAccess(input) == null) return null;
115
        String url = input.getOriginalUrl();
116

  
117
        if ((url == null) || (url.trim().length() == 0)) return input;
118
        @SuppressWarnings("unchecked")
119
        List<String> urls = new Gson().fromJson(url, ArrayList.class);
120
        if ((urls == null) || (urls.size() == 0)) return input;
121
        if (checkUrlsNotNull(input, urls))
122
            return input;
123
        input.setOriginalUrl(null);
124
        input.setUrl(null);
125
        return input;
126
    }
127

  
128
    @Override
129
    public void setBasePath(final String basePath) {
130
        // TODO Auto-generated method stub
131

  
132
    }
133

  
134
}
modules/dnet-download-plugins/tags/dnet-download-plugins-2.1.13/src/main/java/eu/dnetlib/download/plugin/EuropePMC.java
1
package eu.dnetlib.download.plugin;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import com.google.common.base.Function;
7
import com.google.common.collect.Iterables;
8
import com.google.gson.Gson;
9
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
10
import eu.dnetlib.data.download.rmi.DownloadItem;
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginException;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
15

  
16
// TODO: Auto-generated Javadoc
17

  
18
/**
19
 * The Class EuropePMC.
20
 */
21
public class EuropePMC extends AbstractDownloadPlugin implements DownloadPlugin {
22

  
23
    private static final Log log = LogFactory.getLog(EuropePMC.class);
24

  
25
    /**
26
     * The base path.
27
     */
28
    private String basePath;
29

  
30
    // //*[local-name()='metadata']//*[local-name()='identifier' and ./@identifierType='pmc']/text()
31

  
32
    /*
33
     * (non-Javadoc)
34
     *
35
     * @see eu.dnetlib.data.download.rmi.DownloadPlugin#getPluginName()
36
     */
37
    @Override
38
    public String getPluginName() {
39
        return "europePMCDownloadPlugin";
40
    }
41

  
42
    @Override
43
    public Iterable<DownloadItem> retrieveUrls(final Iterable<DownloadItem> urls) throws DownloadPluginException {
44
        return Iterables.transform(urls, new Function<DownloadItem, DownloadItem>() {
45

  
46
            @Override
47
            public DownloadItem apply(final DownloadItem input) {
48
                return retrieveUrl(input);
49
            }
50
        });
51
    }
52

  
53
    /*
54
     * (non-Javadoc)
55
     *
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff