Revision 45176
Added by Claudio Atzori over 6 years ago
modules/dnet-download-service-rmi/trunk/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-service-rmi/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-service-rmi"} |
modules/dnet-download-service-rmi/trunk/src/test/java/eu/dnetlib/data/download/rmi/DownloadItemTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import junit.framework.Assert; |
|
4 |
|
|
5 |
/** |
|
6 |
* Created by sandro on 3/21/14. |
|
7 |
*/ |
|
8 |
public class DownloadItemTest { |
|
9 |
|
|
10 |
@org.junit.Test |
|
11 |
public void testGetFileName() throws Exception { |
|
12 |
DownloadItem di = new DownloadItem(); |
|
13 |
di.setIdItemMetadata("id1"); |
|
14 |
di.setUrl("http://www.test.com"); |
|
15 |
di.setFileName("testFile"); |
|
16 |
Assert.assertEquals("testFile", di.getFileName()); |
|
17 |
} |
|
18 |
} |
modules/dnet-download-service-rmi/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadPluginException.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
public class DownloadPluginException extends RuntimeException { |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
*/ |
|
8 |
private static final long serialVersionUID = -8480343562060711656L; |
|
9 |
|
|
10 |
public DownloadPluginException(final String string, final Throwable exception) { |
|
11 |
super(string, exception); |
|
12 |
} |
|
13 |
|
|
14 |
public DownloadPluginException(final Throwable exception) { |
|
15 |
super(exception); |
|
16 |
} |
|
17 |
|
|
18 |
public DownloadPluginException(final String msg) { |
|
19 |
super(msg); |
|
20 |
|
|
21 |
} |
|
22 |
|
|
23 |
} |
modules/dnet-download-service-rmi/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadItem.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import com.google.gson.Gson; |
|
6 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
7 |
|
|
8 |
// TODO: Auto-generated Javadoc |
|
9 |
/** |
|
10 |
* Download Item Class that serialize information in the resultset. |
|
11 |
*/ |
|
12 |
|
|
13 |
public class DownloadItem { |
|
14 |
|
|
15 |
/** The id item metadata. */ |
|
16 |
private String idItemMetadata; |
|
17 |
/** |
|
18 |
* The url. |
|
19 |
*/ |
|
20 |
private String url; |
|
21 |
/** The file name. */ |
|
22 |
private String fileName; |
|
23 |
/** The original URL should be appear instead of the downloaded URL. */ |
|
24 |
private String originalUrl; |
|
25 |
/** The open access. */ |
|
26 |
private OpenAccessValues openAccess; |
|
27 |
/** The embargo date. */ |
|
28 |
private Date embargoDate; |
|
29 |
|
|
30 |
/** |
|
31 |
* From json. |
|
32 |
* |
|
33 |
* @param inputJson |
|
34 |
* the input json |
|
35 |
* @return the download item |
|
36 |
*/ |
|
37 |
public static DownloadItem newObjectfromJSON(final String inputJson) { |
|
38 |
Gson g = new Gson(); |
|
39 |
DownloadItem instance = g.fromJson(inputJson, DownloadItem.class); |
|
40 |
return instance; |
|
41 |
} |
|
42 |
|
|
43 |
/** |
|
44 |
* To json. |
|
45 |
* |
|
46 |
* @return the string |
|
47 |
*/ |
|
48 |
public String toJSON() { |
|
49 |
return new Gson().toJson(this).replace("\\u003d", "=").replace("\\u0026", "&"); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Gets the id item metadata. |
|
54 |
* |
|
55 |
* @return the id item metadata |
|
56 |
*/ |
|
57 |
public String getIdItemMetadata() { |
|
58 |
return idItemMetadata; |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Sets the id item metadata. |
|
63 |
* |
|
64 |
* @param idItemMetadata |
|
65 |
* the new id item metadata |
|
66 |
*/ |
|
67 |
public void setIdItemMetadata(final String idItemMetadata) { |
|
68 |
this.idItemMetadata = idItemMetadata; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Gets the url. |
|
73 |
* |
|
74 |
* @return the url |
|
75 |
*/ |
|
76 |
public String getUrl() { |
|
77 |
if (url == null) return url; |
|
78 |
return url.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Sets the url. |
|
83 |
* |
|
84 |
* @param url |
|
85 |
* the new url |
|
86 |
*/ |
|
87 |
public void setUrl(final String url) { |
|
88 |
this.url = url; |
|
89 |
|
|
90 |
} |
|
91 |
|
|
92 |
/** |
|
93 |
* Gets the original url. |
|
94 |
* |
|
95 |
* @return the originalUrl |
|
96 |
*/ |
|
97 |
public String getOriginalUrl() { |
|
98 |
if (originalUrl == null) return originalUrl; |
|
99 |
return originalUrl.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Sets the original url. |
|
104 |
* |
|
105 |
* @param originalUrl |
|
106 |
* the originalUrl to set |
|
107 |
*/ |
|
108 |
public void setOriginalUrl(final String originalUrl) { |
|
109 |
this.originalUrl = originalUrl; |
|
110 |
|
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* Gets the file name. |
|
115 |
* |
|
116 |
* @return the file name |
|
117 |
*/ |
|
118 |
public String getFileName() { |
|
119 |
if ((fileName == null) || "".equals(fileName)) return getIdItemMetadata() + "::" + Hashing.md5(getOriginalUrl()); |
|
120 |
return fileName; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Sets the file name. |
|
125 |
* |
|
126 |
* @param fileName |
|
127 |
* the new file name |
|
128 |
*/ |
|
129 |
public void setFileName(final String fileName) { |
|
130 |
this.fileName = fileName; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Gets the open access. |
|
135 |
* |
|
136 |
* @return the openAccess |
|
137 |
*/ |
|
138 |
public String getOpenAccess() { |
|
139 |
return openAccess.toString(); |
|
140 |
} |
|
141 |
|
|
142 |
/** |
|
143 |
* Sets the open access. |
|
144 |
* |
|
145 |
* @param openAccess |
|
146 |
* the openAccess to set |
|
147 |
*/ |
|
148 |
public void setOpenAccess(final String openAccess) { |
|
149 |
for (OpenAccessValues oaValue : OpenAccessValues.values()) { |
|
150 |
if (oaValue.toString().trim().toLowerCase().equals(openAccess.trim().toLowerCase())) { |
|
151 |
this.openAccess = oaValue; |
|
152 |
return; |
|
153 |
} |
|
154 |
} |
|
155 |
this.openAccess = OpenAccessValues.UNKNOWN; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* Gets the embargo date. |
|
160 |
* |
|
161 |
* @return the embargoDate |
|
162 |
*/ |
|
163 |
public Date getEmbargoDate() { |
|
164 |
return embargoDate; |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Sets the embargo date. |
|
169 |
* |
|
170 |
* @param embargoDate |
|
171 |
* the embargoDate to set |
|
172 |
*/ |
|
173 |
public void setEmbargoDate(final Date embargoDate) { |
|
174 |
this.embargoDate = embargoDate; |
|
175 |
} |
|
176 |
|
|
177 |
public enum OpenAccessValues { |
|
178 |
OPEN, RESTRICTED, CLOSED, EMBARGO, UNKNOWN |
|
179 |
} |
|
180 |
} |
modules/dnet-download-service-rmi/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadPlugin.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
/** |
|
6 |
* The DownloadPluin should retrieve the correct URL of the file to download |
|
7 |
*/ |
|
8 |
public interface DownloadPlugin { |
|
9 |
|
|
10 |
/** |
|
11 |
* If Sets the base path, the plugin will start to download from the basePath in the file system |
|
12 |
* |
|
13 |
* @param basePath the base path |
|
14 |
* @return the string |
|
15 |
*/ |
|
16 |
void setBasePath(String basePath); |
|
17 |
|
|
18 |
/** |
|
19 |
* This method retrieve the correct Url of the file from the starting URL |
|
20 |
* |
|
21 |
* @param url the starting url |
|
22 |
* @return the Url of the correct file |
|
23 |
*/ |
|
24 |
DownloadItem retrieveUrl(DownloadItem item) throws DownloadPluginException; |
|
25 |
|
|
26 |
/** |
|
27 |
* This method retrieve the correct Url of the file from a list of starting URL |
|
28 |
* |
|
29 |
* @param urls the list of starting url |
|
30 |
* @return the list of the file URL |
|
31 |
*/ |
|
32 |
Iterable<DownloadItem> retrieveUrls(Iterable<DownloadItem> items) throws DownloadPluginException; |
|
33 |
|
|
34 |
/** |
|
35 |
* Get the name of the plugin |
|
36 |
* |
|
37 |
* @return the name of the plugin |
|
38 |
*/ |
|
39 |
String getPluginName(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Gets the regular expression. |
|
43 |
* |
|
44 |
* @return the regular expression |
|
45 |
*/ |
|
46 |
List<String> getRegularExpression(); |
|
47 |
|
|
48 |
/** |
|
49 |
* Sets the regular expression. |
|
50 |
* |
|
51 |
* @param regularExpression the new regular expression |
|
52 |
*/ |
|
53 |
void setRegularExpression(final List<String> regularExpression); |
|
54 |
|
|
55 |
} |
modules/dnet-download-service-rmi/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadServiceException.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import eu.dnetlib.common.rmi.RMIException; |
|
4 |
|
|
5 |
public class DownloadServiceException extends RMIException { |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = -5031281288958769185L; |
|
11 |
|
|
12 |
public DownloadServiceException(final String string) { |
|
13 |
super(string); |
|
14 |
} |
|
15 |
|
|
16 |
public DownloadServiceException(final String string, final Throwable exception) { |
|
17 |
super(string, exception); |
|
18 |
} |
|
19 |
|
|
20 |
public DownloadServiceException(final Throwable exception) { |
|
21 |
super(exception); |
|
22 |
} |
|
23 |
|
|
24 |
} |
modules/dnet-download-service-rmi/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadPluginEnumerator.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.springframework.beans.factory.BeanFactoryAware; |
|
6 |
|
|
7 |
public interface DownloadPluginEnumerator extends BeanFactoryAware { |
|
8 |
|
|
9 |
/** |
|
10 |
* Get all beans implementing the DownloadPlugin interface. |
|
11 |
* |
|
12 |
* @return |
|
13 |
*/ |
|
14 |
Map<String, DownloadPlugin> getAll(); |
|
15 |
|
|
16 |
/** |
|
17 |
* Get all beans implementing the DownloadPlugin interface, hashed by name. |
|
18 |
* |
|
19 |
* @return |
|
20 |
*/ |
|
21 |
Map<String, DownloadPlugin> getByProtocols(); |
|
22 |
|
|
23 |
} |
modules/dnet-download-service-rmi/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadService.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.jws.WebMethod; |
|
6 |
import javax.jws.WebService; |
|
7 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
8 |
|
|
9 |
import eu.dnetlib.common.rmi.BaseService; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
*/ |
|
14 |
@WebService(targetNamespace = "http://services.dnetlib.eu/") |
|
15 |
public interface DownloadService extends BaseService { |
|
16 |
|
|
17 |
/** |
|
18 |
* Download the file in the resultset to the objectStore. |
|
19 |
* |
|
20 |
* @param resultSet |
|
21 |
* the resultset of the url Object |
|
22 |
* @param plugin |
|
23 |
* the name of the plugin to be applied to retrieve the URL |
|
24 |
* @param objectStoreID |
|
25 |
* the object store id where download the file |
|
26 |
* @throws DownloadServiceException |
|
27 |
* the download service exception |
|
28 |
*/ |
|
29 |
@WebMethod(operationName = "downloadFromResultSet", action = "downloadFromResultSet") |
|
30 |
public void downloadFromResultSet(W3CEndpointReference resultSet, String plugin, String objectStoreID, String protocol, String mimeType) |
|
31 |
throws DownloadServiceException; |
|
32 |
|
|
33 |
@WebMethod(operationName = "listPlugins", action = "listPlugins") |
|
34 |
public List<String> listPlugins() throws DownloadServiceException; |
|
35 |
|
|
36 |
} |
modules/dnet-download-service-rmi/trunk/src/main/java/eu/dnetlib/data/download/rmi/AbstractDownloadPlugin.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import com.google.gson.Gson; |
|
6 |
import eu.dnetlib.data.download.rmi.DownloadItem.OpenAccessValues; |
|
7 |
import org.joda.time.DateTime; |
|
8 |
import org.joda.time.Days; |
|
9 |
|
|
10 |
// TODO: Auto-generated Javadoc |
|
11 |
|
|
12 |
/** |
|
13 |
* The Class AbstractDownloadPlugin. |
|
14 |
*/ |
|
15 |
public abstract class AbstractDownloadPlugin { |
|
16 |
|
|
17 |
public static final int DEFAULT_TIMEOUT = 5000; |
|
18 |
|
|
19 |
/** |
|
20 |
* The regular expression. |
|
21 |
*/ |
|
22 |
protected List<String> regularExpression; |
|
23 |
|
|
24 |
|
|
25 |
/** |
|
26 |
* Check open access. |
|
27 |
* |
|
28 |
* @param input the input |
|
29 |
* @return the download item |
|
30 |
*/ |
|
31 |
public DownloadItem checkOpenAccess(final DownloadItem input) { |
|
32 |
if (input != null) { |
|
33 |
OpenAccessValues openAccess = OpenAccessValues.valueOf(input.getOpenAccess()); |
|
34 |
switch (openAccess) { |
|
35 |
case OPEN: |
|
36 |
return input; |
|
37 |
case CLOSED: |
|
38 |
case RESTRICTED: |
|
39 |
case UNKNOWN: |
|
40 |
return null; |
|
41 |
case EMBARGO: |
|
42 |
if (input.getEmbargoDate() == null) return null; |
|
43 |
DateTime embargoDate = new DateTime(input.getEmbargoDate()); |
|
44 |
DateTime today = new DateTime(); |
|
45 |
Days days = Days.daysBetween(embargoDate, today); |
|
46 |
if (days.getDays() <= 0) return input; |
|
47 |
return null; |
|
48 |
} |
|
49 |
} |
|
50 |
return null; |
|
51 |
} |
|
52 |
|
|
53 |
|
|
54 |
public DownloadItem filterByRegexp(final DownloadItem input) { |
|
55 |
if (this.regularExpression != null && this.regularExpression.size() > 0) { |
|
56 |
final String baseURLs = input.getUrl(); |
|
57 |
final List<String> urlsList = new Gson().fromJson(baseURLs, List.class); |
|
58 |
|
|
59 |
for (final String baseURL : urlsList) { |
|
60 |
for (final String regExp : regularExpression) { |
|
61 |
if (baseURL.matches(regExp)) |
|
62 |
return input; |
|
63 |
} |
|
64 |
} |
|
65 |
return null; |
|
66 |
} else return input; |
|
67 |
} |
|
68 |
|
|
69 |
protected boolean checkUrlsNotNull(DownloadItem input, List<String> urls) { |
|
70 |
for (String s : urls) { |
|
71 |
String newURL = extractURL(s); |
|
72 |
if (newURL != null) { |
|
73 |
input.setOriginalUrl(s); |
|
74 |
input.setUrl(newURL); |
|
75 |
return true; |
|
76 |
} |
|
77 |
} |
|
78 |
return false; |
|
79 |
} |
|
80 |
|
|
81 |
public abstract String extractURL(final String baseURL) throws DownloadPluginException; |
|
82 |
|
|
83 |
|
|
84 |
/** |
|
85 |
* Gets the regular expression. |
|
86 |
* |
|
87 |
* @return the regular expression |
|
88 |
*/ |
|
89 |
public List<String> getRegularExpression() { |
|
90 |
return regularExpression; |
|
91 |
} |
|
92 |
|
|
93 |
|
|
94 |
/** |
|
95 |
* Sets the regular expression. |
|
96 |
* |
|
97 |
* @param regularExpression the new regular expression |
|
98 |
*/ |
|
99 |
public void setRegularExpression(final List<String> regularExpression) { |
|
100 |
this.regularExpression = regularExpression; |
|
101 |
} |
|
102 |
|
|
103 |
} |
modules/dnet-download-service-rmi/trunk/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<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"> |
|
3 |
<parent> |
|
4 |
<groupId>eu.dnetlib</groupId> |
|
5 |
<artifactId>dnet-parent</artifactId> |
|
6 |
<version>1.0.0</version> |
|
7 |
<relativePath /> |
|
8 |
</parent> |
|
9 |
<modelVersion>4.0.0</modelVersion> |
|
10 |
<groupId>eu.dnetlib</groupId> |
|
11 |
<artifactId>dnet-download-service-rmi</artifactId> |
|
12 |
<version>1.3.3-SNAPSHOT</version> |
|
13 |
<scm> |
|
14 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-download-service-rmi/trunk</developerConnection> |
|
15 |
</scm> |
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>eu.dnetlib</groupId> |
|
19 |
<artifactId>cnr-rmi-api</artifactId> |
|
20 |
<version>[2.0.0,3.0.0)</version> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>eu.dnetlib</groupId> |
|
24 |
<artifactId>cnr-misc-utils</artifactId> |
|
25 |
<version>[1.0.0,2.0.0)</version> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>com.google.code.gson</groupId> |
|
29 |
<artifactId>gson</artifactId> |
|
30 |
<version>${google.gson.version}</version> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>junit</groupId> |
|
34 |
<artifactId>junit</artifactId> |
|
35 |
<version>${junit.version}</version> |
|
36 |
<scope>test</scope> |
|
37 |
</dependency> |
|
38 |
|
|
39 |
<dependency> |
|
40 |
<groupId>org.springframework</groupId> |
|
41 |
<artifactId>spring-beans</artifactId> |
|
42 |
<version>${spring.version}</version> |
|
43 |
</dependency> |
|
44 |
<dependency> |
|
45 |
<groupId>joda-time</groupId> |
|
46 |
<artifactId>joda-time</artifactId> |
|
47 |
<version>2.9</version> |
|
48 |
</dependency> |
|
49 |
|
|
50 |
</dependencies> |
|
51 |
|
|
52 |
|
|
53 |
</project> |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/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-service-rmi/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-service-rmi"} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/src/test/java/eu/dnetlib/data/download/rmi/DownloadItemTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import junit.framework.Assert; |
|
4 |
|
|
5 |
/** |
|
6 |
* Created by sandro on 3/21/14. |
|
7 |
*/ |
|
8 |
public class DownloadItemTest { |
|
9 |
|
|
10 |
@org.junit.Test |
|
11 |
public void testGetFileName() throws Exception { |
|
12 |
DownloadItem di = new DownloadItem(); |
|
13 |
di.setIdItemMetadata("id1"); |
|
14 |
di.setUrl("http://www.test.com"); |
|
15 |
di.setFileName("testFile"); |
|
16 |
Assert.assertEquals("testFile", di.getFileName()); |
|
17 |
} |
|
18 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/src/main/java/eu/dnetlib/data/download/rmi/DownloadPluginException.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
public class DownloadPluginException extends RuntimeException { |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
*/ |
|
8 |
private static final long serialVersionUID = -8480343562060711656L; |
|
9 |
|
|
10 |
public DownloadPluginException(final String string, final Throwable exception) { |
|
11 |
super(string, exception); |
|
12 |
} |
|
13 |
|
|
14 |
public DownloadPluginException(final Throwable exception) { |
|
15 |
super(exception); |
|
16 |
} |
|
17 |
|
|
18 |
public DownloadPluginException(final String msg) { |
|
19 |
super(msg); |
|
20 |
|
|
21 |
} |
|
22 |
|
|
23 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/src/main/java/eu/dnetlib/data/download/rmi/DownloadItem.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import com.google.gson.Gson; |
|
6 |
|
|
7 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
8 |
|
|
9 |
// TODO: Auto-generated Javadoc |
|
10 |
/** |
|
11 |
* Download Item Class that serialize information in the resultset. |
|
12 |
*/ |
|
13 |
|
|
14 |
public class DownloadItem { |
|
15 |
|
|
16 |
public enum OpenAccessValues { |
|
17 |
OPEN, RESTRICTED, CLOSED, EMBARGO, UNKNOWN |
|
18 |
} |
|
19 |
|
|
20 |
/** The id item metadata. */ |
|
21 |
private String idItemMetadata; |
|
22 |
|
|
23 |
/** The Url. */ |
|
24 |
private String Url; |
|
25 |
|
|
26 |
/** The file name. */ |
|
27 |
private String fileName; |
|
28 |
|
|
29 |
/** The original URL should be appear instead of the downloaded URL. */ |
|
30 |
private String originalUrl; |
|
31 |
|
|
32 |
/** The open access. */ |
|
33 |
private OpenAccessValues openAccess; |
|
34 |
|
|
35 |
/** The embargo date. */ |
|
36 |
private Date embargoDate; |
|
37 |
|
|
38 |
/** |
|
39 |
* From json. |
|
40 |
* |
|
41 |
* @param inputJson |
|
42 |
* the input json |
|
43 |
* @return the download item |
|
44 |
*/ |
|
45 |
public static DownloadItem newObjectfromJSON(final String inputJson) { |
|
46 |
Gson g = new Gson(); |
|
47 |
DownloadItem instance = g.fromJson(inputJson, DownloadItem.class); |
|
48 |
return instance; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* To json. |
|
53 |
* |
|
54 |
* @return the string |
|
55 |
*/ |
|
56 |
public String toJSON() { |
|
57 |
return new Gson().toJson(this).replace("\\u003d", "=").replace("\\u0026", "&"); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Gets the id item metadata. |
|
62 |
* |
|
63 |
* @return the id item metadata |
|
64 |
*/ |
|
65 |
public String getIdItemMetadata() { |
|
66 |
return idItemMetadata; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Sets the id item metadata. |
|
71 |
* |
|
72 |
* @param idItemMetadata |
|
73 |
* the new id item metadata |
|
74 |
*/ |
|
75 |
public void setIdItemMetadata(final String idItemMetadata) { |
|
76 |
this.idItemMetadata = idItemMetadata; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Gets the url. |
|
81 |
* |
|
82 |
* @return the url |
|
83 |
*/ |
|
84 |
public String getUrl() { |
|
85 |
if (Url == null) return null; |
|
86 |
return Url.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Sets the url. |
|
91 |
* |
|
92 |
* @param url |
|
93 |
* the new url |
|
94 |
*/ |
|
95 |
public void setUrl(final String url) { |
|
96 |
if (url == null) { |
|
97 |
Url = null; |
|
98 |
} else { |
|
99 |
Url = url.replace("\\u003d", "=Date").replace("\\u0026", "&"); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* Gets the original url. |
|
105 |
* |
|
106 |
* @return the originalUrl |
|
107 |
*/ |
|
108 |
public String getOriginalUrl() { |
|
109 |
if (originalUrl == null) return null; |
|
110 |
return originalUrl.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* Sets the original url. |
|
115 |
* |
|
116 |
* @param originalUrl |
|
117 |
* the originalUrl to set |
|
118 |
*/ |
|
119 |
public void setOriginalUrl(final String originalUrl) { |
|
120 |
if (originalUrl == null) { |
|
121 |
this.originalUrl = null; |
|
122 |
} else { |
|
123 |
this.originalUrl = originalUrl.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* Gets the file name. |
|
129 |
* |
|
130 |
* @return the file name |
|
131 |
*/ |
|
132 |
public String getFileName() { |
|
133 |
if ((fileName == null) || "".equals(fileName)) return getIdItemMetadata() + "::" + Hashing.md5(getOriginalUrl()); |
|
134 |
return fileName; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Sets the file name. |
|
139 |
* |
|
140 |
* @param fileName |
|
141 |
* the new file name |
|
142 |
*/ |
|
143 |
public void setFileName(final String fileName) { |
|
144 |
this.fileName = fileName; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Gets the open access. |
|
149 |
* |
|
150 |
* @return the openAccess |
|
151 |
*/ |
|
152 |
public String getOpenAccess() { |
|
153 |
return openAccess.toString(); |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Sets the open access. |
|
158 |
* |
|
159 |
* @param openAccess |
|
160 |
* the openAccess to set |
|
161 |
*/ |
|
162 |
public void setOpenAccess(final String openAccess) { |
|
163 |
for (OpenAccessValues oaValue : OpenAccessValues.values()) { |
|
164 |
if (oaValue.toString().trim().toLowerCase().equals(openAccess.trim().toLowerCase())) { |
|
165 |
this.openAccess = oaValue; |
|
166 |
return; |
|
167 |
} |
|
168 |
} |
|
169 |
this.openAccess = OpenAccessValues.UNKNOWN; |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* Gets the embargo date. |
|
174 |
* |
|
175 |
* @return the embargoDate |
|
176 |
*/ |
|
177 |
public Date getEmbargoDate() { |
|
178 |
return embargoDate; |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* Sets the embargo date. |
|
183 |
* |
|
184 |
* @param embargoDate |
|
185 |
* the embargoDate to set |
|
186 |
*/ |
|
187 |
public void setEmbargoDate(final Date embargoDate) { |
|
188 |
this.embargoDate = embargoDate; |
|
189 |
} |
|
190 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/src/main/java/eu/dnetlib/data/download/rmi/DownloadPlugin.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
/** |
|
6 |
* The DownloadPluin should retrieve the correct URL of the file to download |
|
7 |
*/ |
|
8 |
public interface DownloadPlugin { |
|
9 |
|
|
10 |
/** |
|
11 |
* If Sets the base path, the plugin will start to download from the basePath in the file system |
|
12 |
* |
|
13 |
* @param basePath |
|
14 |
* the base path |
|
15 |
* @return the string |
|
16 |
*/ |
|
17 |
void setBasePath(String basePath); |
|
18 |
|
|
19 |
/** |
|
20 |
* This method retrieve the correct Url of the file from the starting URL |
|
21 |
* |
|
22 |
* @param url |
|
23 |
* the starting url |
|
24 |
* @return the Url of the correct file |
|
25 |
*/ |
|
26 |
DownloadItem retrieveUrl(DownloadItem item) throws DownloadPluginException; |
|
27 |
|
|
28 |
/** |
|
29 |
* This method retrieve the correct Url of the file from a list of starting URL |
|
30 |
* |
|
31 |
* @param urls |
|
32 |
* the list of starting url |
|
33 |
* @return the list of the file URL |
|
34 |
*/ |
|
35 |
Iterable<DownloadItem> retireveUrls(Iterable<DownloadItem> items) throws DownloadPluginException; |
|
36 |
|
|
37 |
/** |
|
38 |
* Get the name of the plugin |
|
39 |
* |
|
40 |
* @return the name of the plugin |
|
41 |
*/ |
|
42 |
String getPluginName(); |
|
43 |
|
|
44 |
/** |
|
45 |
* Gets the regular expression. |
|
46 |
* |
|
47 |
* @return the regular expression |
|
48 |
*/ |
|
49 |
List<String> getRegularExpression(); |
|
50 |
|
|
51 |
/** |
|
52 |
* Sets the regular expression. |
|
53 |
* |
|
54 |
* @param regularExpression |
|
55 |
* the new regular expression |
|
56 |
*/ |
|
57 |
void setRegularExpression(final List<String> regularExpression); |
|
58 |
|
|
59 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/src/main/java/eu/dnetlib/data/download/rmi/DownloadServiceException.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import eu.dnetlib.common.rmi.RMIException; |
|
4 |
|
|
5 |
public class DownloadServiceException extends RMIException { |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = -5031281288958769185L; |
|
11 |
|
|
12 |
public DownloadServiceException(final String string) { |
|
13 |
super(string); |
|
14 |
} |
|
15 |
|
|
16 |
public DownloadServiceException(final String string, final Throwable exception) { |
|
17 |
super(string, exception); |
|
18 |
} |
|
19 |
|
|
20 |
public DownloadServiceException(final Throwable exception) { |
|
21 |
super(exception); |
|
22 |
} |
|
23 |
|
|
24 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/src/main/java/eu/dnetlib/data/download/rmi/DownloadPluginEnumerator.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.springframework.beans.factory.BeanFactoryAware; |
|
6 |
|
|
7 |
public interface DownloadPluginEnumerator extends BeanFactoryAware { |
|
8 |
|
|
9 |
/** |
|
10 |
* Get all beans implementing the DownloadPlugin interface. |
|
11 |
* |
|
12 |
* @return |
|
13 |
*/ |
|
14 |
Map<String, DownloadPlugin> getAll(); |
|
15 |
|
|
16 |
/** |
|
17 |
* Get all beans implementing the DownloadPlugin interface, hashed by name. |
|
18 |
* |
|
19 |
* @return |
|
20 |
*/ |
|
21 |
Map<String, DownloadPlugin> getByProtocols(); |
|
22 |
|
|
23 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/src/main/java/eu/dnetlib/data/download/rmi/DownloadService.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.jws.WebMethod; |
|
6 |
import javax.jws.WebService; |
|
7 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
8 |
|
|
9 |
import eu.dnetlib.common.rmi.BaseService; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
*/ |
|
14 |
@WebService(targetNamespace = "http://services.dnetlib.eu/") |
|
15 |
public interface DownloadService extends BaseService { |
|
16 |
|
|
17 |
/** |
|
18 |
* Download the file in the resultset to the objectStore. |
|
19 |
* |
|
20 |
* @param resultSet |
|
21 |
* the resultset of the url Object |
|
22 |
* @param plugin |
|
23 |
* the name of the plugin to be applied to retrieve the URL |
|
24 |
* @param objectStoreID |
|
25 |
* the object store id where download the file |
|
26 |
* @throws DownloadServiceException |
|
27 |
* the download service exception |
|
28 |
*/ |
|
29 |
@WebMethod(operationName = "downloadFromResultSet", action = "downloadFromResultSet") |
|
30 |
public void downloadFromResultSet(W3CEndpointReference resultSet, String plugin, String objectStoreID, String protocol, String mimeType) |
|
31 |
throws DownloadServiceException; |
|
32 |
|
|
33 |
@WebMethod(operationName = "listPlugins", action = "listPlugins") |
|
34 |
public List<String> listPlugins() throws DownloadServiceException; |
|
35 |
|
|
36 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<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"> |
|
3 |
<parent> |
|
4 |
<groupId>eu.dnetlib</groupId> |
|
5 |
<artifactId>dnet-parent</artifactId> |
|
6 |
<version>1.0.0</version> |
|
7 |
<relativePath /> |
|
8 |
</parent> |
|
9 |
<modelVersion>4.0.0</modelVersion> |
|
10 |
<groupId>eu.dnetlib</groupId> |
|
11 |
<artifactId>dnet-download-service-rmi</artifactId> |
|
12 |
<version>1.2.1</version> |
|
13 |
<scm> |
|
14 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.2.1</developerConnection> |
|
15 |
</scm> |
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>eu.dnetlib</groupId> |
|
19 |
<artifactId>cnr-rmi-api</artifactId> |
|
20 |
<version>[2.0.0,3.0.0)</version> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>eu.dnetlib</groupId> |
|
24 |
<artifactId>cnr-misc-utils</artifactId> |
|
25 |
<version>[1.0.0,2.0.0)</version> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>com.google.code.gson</groupId> |
|
29 |
<artifactId>gson</artifactId> |
|
30 |
<version>${google.gson.version}</version> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>junit</groupId> |
|
34 |
<artifactId>junit</artifactId> |
|
35 |
<version>${junit.version}</version> |
|
36 |
<scope>test</scope> |
|
37 |
</dependency> |
|
38 |
|
|
39 |
<dependency> |
|
40 |
<groupId>org.springframework</groupId> |
|
41 |
<artifactId>spring-beans</artifactId> |
|
42 |
<version>${spring.version}</version> |
|
43 |
</dependency> |
|
44 |
|
|
45 |
</dependencies> |
|
46 |
|
|
47 |
|
|
48 |
</project> |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/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-service-rmi/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-service-rmi"} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/test/java/eu/dnetlib/data/download/rmi/DownloadItemTest.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import junit.framework.Assert; |
|
4 |
|
|
5 |
/** |
|
6 |
* Created by sandro on 3/21/14. |
|
7 |
*/ |
|
8 |
public class DownloadItemTest { |
|
9 |
|
|
10 |
@org.junit.Test |
|
11 |
public void testGetFileName() throws Exception { |
|
12 |
DownloadItem di = new DownloadItem(); |
|
13 |
di.setIdItemMetadata("id1"); |
|
14 |
di.setUrl("http://www.test.com"); |
|
15 |
di.setFileName("testFile"); |
|
16 |
Assert.assertEquals("testFile", di.getFileName()); |
|
17 |
} |
|
18 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/main/java/eu/dnetlib/data/download/rmi/DownloadPluginException.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
public class DownloadPluginException extends RuntimeException { |
|
4 |
|
|
5 |
/** |
|
6 |
* |
|
7 |
*/ |
|
8 |
private static final long serialVersionUID = -8480343562060711656L; |
|
9 |
|
|
10 |
public DownloadPluginException(final String string, final Throwable exception) { |
|
11 |
super(string, exception); |
|
12 |
} |
|
13 |
|
|
14 |
public DownloadPluginException(final Throwable exception) { |
|
15 |
super(exception); |
|
16 |
} |
|
17 |
|
|
18 |
public DownloadPluginException(final String msg) { |
|
19 |
super(msg); |
|
20 |
|
|
21 |
} |
|
22 |
|
|
23 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/main/java/eu/dnetlib/data/download/rmi/DownloadItem.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import com.google.gson.Gson; |
|
6 |
|
|
7 |
import eu.dnetlib.miscutils.functional.hash.Hashing; |
|
8 |
|
|
9 |
// TODO: Auto-generated Javadoc |
|
10 |
/** |
|
11 |
* Download Item Class that serialize information in the resultset. |
|
12 |
*/ |
|
13 |
|
|
14 |
public class DownloadItem { |
|
15 |
|
|
16 |
public enum OpenAccessValues { |
|
17 |
OPEN, RESTRICTED, CLOSED, EMBARGO, UNKNOWN |
|
18 |
} |
|
19 |
|
|
20 |
/** The id item metadata. */ |
|
21 |
private String idItemMetadata; |
|
22 |
|
|
23 |
/** The Url. */ |
|
24 |
private String Url; |
|
25 |
|
|
26 |
/** The file name. */ |
|
27 |
private String fileName; |
|
28 |
|
|
29 |
/** The original URL should be appear instead of the downloaded URL. */ |
|
30 |
private String originalUrl; |
|
31 |
|
|
32 |
/** The open access. */ |
|
33 |
private OpenAccessValues openAccess; |
|
34 |
|
|
35 |
/** The embargo date. */ |
|
36 |
private Date embargoDate; |
|
37 |
|
|
38 |
/** |
|
39 |
* From json. |
|
40 |
* |
|
41 |
* @param inputJson |
|
42 |
* the input json |
|
43 |
* @return the download item |
|
44 |
*/ |
|
45 |
public static DownloadItem newObjectfromJSON(final String inputJson) { |
|
46 |
Gson g = new Gson(); |
|
47 |
DownloadItem instance = g.fromJson(inputJson, DownloadItem.class); |
|
48 |
return instance; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* To json. |
|
53 |
* |
|
54 |
* @return the string |
|
55 |
*/ |
|
56 |
public String toJSON() { |
|
57 |
return new Gson().toJson(this).replace("\\u003d", "=").replace("\\u0026", "&"); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* Gets the id item metadata. |
|
62 |
* |
|
63 |
* @return the id item metadata |
|
64 |
*/ |
|
65 |
public String getIdItemMetadata() { |
|
66 |
return idItemMetadata; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Sets the id item metadata. |
|
71 |
* |
|
72 |
* @param idItemMetadata |
|
73 |
* the new id item metadata |
|
74 |
*/ |
|
75 |
public void setIdItemMetadata(final String idItemMetadata) { |
|
76 |
this.idItemMetadata = idItemMetadata; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Gets the url. |
|
81 |
* |
|
82 |
* @return the url |
|
83 |
*/ |
|
84 |
public String getUrl() { |
|
85 |
if (Url == null) return null; |
|
86 |
return Url.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Sets the url. |
|
91 |
* |
|
92 |
* @param url |
|
93 |
* the new url |
|
94 |
*/ |
|
95 |
public void setUrl(final String url) { |
|
96 |
if (url == null) { |
|
97 |
Url = null; |
|
98 |
} else { |
|
99 |
Url = url.replace("\\u003d", "=Date").replace("\\u0026", "&"); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* Gets the original url. |
|
105 |
* |
|
106 |
* @return the originalUrl |
|
107 |
*/ |
|
108 |
public String getOriginalUrl() { |
|
109 |
if (originalUrl == null) return null; |
|
110 |
return originalUrl.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* Sets the original url. |
|
115 |
* |
|
116 |
* @param originalUrl |
|
117 |
* the originalUrl to set |
|
118 |
*/ |
|
119 |
public void setOriginalUrl(final String originalUrl) { |
|
120 |
if (originalUrl == null) { |
|
121 |
this.originalUrl = null; |
|
122 |
} else { |
|
123 |
this.originalUrl = originalUrl.replace("\\u003d", "=").replace("\\u0026", "&"); |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* Gets the file name. |
|
129 |
* |
|
130 |
* @return the file name |
|
131 |
*/ |
|
132 |
public String getFileName() { |
|
133 |
if ((fileName == null) || "".equals(fileName)) return getIdItemMetadata() + "::" + Hashing.md5(getOriginalUrl()); |
|
134 |
return fileName; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Sets the file name. |
|
139 |
* |
|
140 |
* @param fileName |
|
141 |
* the new file name |
|
142 |
*/ |
|
143 |
public void setFileName(final String fileName) { |
|
144 |
this.fileName = fileName; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Gets the open access. |
|
149 |
* |
|
150 |
* @return the openAccess |
|
151 |
*/ |
|
152 |
public String getOpenAccess() { |
|
153 |
return openAccess.toString(); |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Sets the open access. |
|
158 |
* |
|
159 |
* @param openAccess |
|
160 |
* the openAccess to set |
|
161 |
*/ |
|
162 |
public void setOpenAccess(final String openAccess) { |
|
163 |
for (OpenAccessValues oaValue : OpenAccessValues.values()) { |
|
164 |
if (oaValue.toString().trim().toLowerCase().equals(openAccess.trim().toLowerCase())) { |
|
165 |
this.openAccess = oaValue; |
|
166 |
return; |
|
167 |
} |
|
168 |
} |
|
169 |
this.openAccess = OpenAccessValues.UNKNOWN; |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* Gets the embargo date. |
|
174 |
* |
|
175 |
* @return the embargoDate |
|
176 |
*/ |
|
177 |
public Date getEmbargoDate() { |
|
178 |
return embargoDate; |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* Sets the embargo date. |
|
183 |
* |
|
184 |
* @param embargoDate |
|
185 |
* the embargoDate to set |
|
186 |
*/ |
|
187 |
public void setEmbargoDate(final Date embargoDate) { |
|
188 |
this.embargoDate = embargoDate; |
|
189 |
} |
|
190 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/main/java/eu/dnetlib/data/download/rmi/DownloadPlugin.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
/** |
|
6 |
* The DownloadPluin should retrieve the correct URL of the file to download |
|
7 |
*/ |
|
8 |
public interface DownloadPlugin { |
|
9 |
|
|
10 |
/** |
|
11 |
* If Sets the base path, the plugin will start to download from the basePath in the file system |
|
12 |
* |
|
13 |
* @param basePath the base path |
|
14 |
* @return the string |
|
15 |
*/ |
|
16 |
void setBasePath(String basePath); |
|
17 |
|
|
18 |
/** |
|
19 |
* This method retrieve the correct Url of the file from the starting URL |
|
20 |
* |
|
21 |
* @param url the starting url |
|
22 |
* @return the Url of the correct file |
|
23 |
*/ |
|
24 |
DownloadItem retrieveUrl(DownloadItem item) throws DownloadPluginException; |
|
25 |
|
|
26 |
/** |
|
27 |
* This method retrieve the correct Url of the file from a list of starting URL |
|
28 |
* |
|
29 |
* @param urls the list of starting url |
|
30 |
* @return the list of the file URL |
|
31 |
*/ |
|
32 |
Iterable<DownloadItem> retrieveUrls(Iterable<DownloadItem> items) throws DownloadPluginException; |
|
33 |
|
|
34 |
/** |
|
35 |
* Get the name of the plugin |
|
36 |
* |
|
37 |
* @return the name of the plugin |
|
38 |
*/ |
|
39 |
String getPluginName(); |
|
40 |
|
|
41 |
/** |
|
42 |
* Gets the regular expression. |
|
43 |
* |
|
44 |
* @return the regular expression |
|
45 |
*/ |
|
46 |
List<String> getRegularExpression(); |
|
47 |
|
|
48 |
/** |
|
49 |
* Sets the regular expression. |
|
50 |
* |
|
51 |
* @param regularExpression the new regular expression |
|
52 |
*/ |
|
53 |
void setRegularExpression(final List<String> regularExpression); |
|
54 |
|
|
55 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/main/java/eu/dnetlib/data/download/rmi/DownloadServiceException.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import eu.dnetlib.common.rmi.RMIException; |
|
4 |
|
|
5 |
public class DownloadServiceException extends RMIException { |
|
6 |
|
|
7 |
/** |
|
8 |
* |
|
9 |
*/ |
|
10 |
private static final long serialVersionUID = -5031281288958769185L; |
|
11 |
|
|
12 |
public DownloadServiceException(final String string) { |
|
13 |
super(string); |
|
14 |
} |
|
15 |
|
|
16 |
public DownloadServiceException(final String string, final Throwable exception) { |
|
17 |
super(string, exception); |
|
18 |
} |
|
19 |
|
|
20 |
public DownloadServiceException(final Throwable exception) { |
|
21 |
super(exception); |
|
22 |
} |
|
23 |
|
|
24 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/main/java/eu/dnetlib/data/download/rmi/DownloadPluginEnumerator.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
import org.springframework.beans.factory.BeanFactoryAware; |
|
6 |
|
|
7 |
public interface DownloadPluginEnumerator extends BeanFactoryAware { |
|
8 |
|
|
9 |
/** |
|
10 |
* Get all beans implementing the DownloadPlugin interface. |
|
11 |
* |
|
12 |
* @return |
|
13 |
*/ |
|
14 |
Map<String, DownloadPlugin> getAll(); |
|
15 |
|
|
16 |
/** |
|
17 |
* Get all beans implementing the DownloadPlugin interface, hashed by name. |
|
18 |
* |
|
19 |
* @return |
|
20 |
*/ |
|
21 |
Map<String, DownloadPlugin> getByProtocols(); |
|
22 |
|
|
23 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/main/java/eu/dnetlib/data/download/rmi/DownloadService.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.jws.WebMethod; |
|
6 |
import javax.jws.WebService; |
|
7 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
8 |
|
|
9 |
import eu.dnetlib.common.rmi.BaseService; |
|
10 |
|
|
11 |
/** |
|
12 |
* |
|
13 |
*/ |
|
14 |
@WebService(targetNamespace = "http://services.dnetlib.eu/") |
|
15 |
public interface DownloadService extends BaseService { |
|
16 |
|
|
17 |
/** |
|
18 |
* Download the file in the resultset to the objectStore. |
|
19 |
* |
|
20 |
* @param resultSet |
|
21 |
* the resultset of the url Object |
|
22 |
* @param plugin |
|
23 |
* the name of the plugin to be applied to retrieve the URL |
|
24 |
* @param objectStoreID |
|
25 |
* the object store id where download the file |
|
26 |
* @throws DownloadServiceException |
|
27 |
* the download service exception |
|
28 |
*/ |
|
29 |
@WebMethod(operationName = "downloadFromResultSet", action = "downloadFromResultSet") |
|
30 |
public void downloadFromResultSet(W3CEndpointReference resultSet, String plugin, String objectStoreID, String protocol, String mimeType) |
|
31 |
throws DownloadServiceException; |
|
32 |
|
|
33 |
@WebMethod(operationName = "listPlugins", action = "listPlugins") |
|
34 |
public List<String> listPlugins() throws DownloadServiceException; |
|
35 |
|
|
36 |
} |
modules/dnet-download-service-rmi/tags/dnet-download-service-rmi-1.3.0/src/main/java/eu/dnetlib/data/download/rmi/AbstractDownloadPlugin.java | ||
---|---|---|
1 |
package eu.dnetlib.data.download.rmi; |
|
2 |
|
|
3 |
import com.google.gson.Gson; |
|
4 |
import eu.dnetlib.data.download.rmi.DownloadItem.OpenAccessValues; |
|
5 |
import org.joda.time.DateTime; |
|
6 |
import org.joda.time.Days; |
|
7 |
|
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
// TODO: Auto-generated Javadoc |
|
11 |
|
|
12 |
/** |
|
13 |
* The Class AbstractDownloadPlugin. |
|
14 |
*/ |
|
15 |
public abstract class AbstractDownloadPlugin { |
|
16 |
|
Also available in: Unified diff
codebase used to migrate to java8 the production system