Project

General

Profile

« Previous | Next » 

Revision 58499

[maven-release-plugin] copy for tag dnet-download-service-2.2.6

View differences:

modules/dnet-download-service/tags/dnet-download-service-2.2.6/deploy.info
1
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-download-service/trunk/", "deploy_repository": "dnet45-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/dnet45-snapshots", "name": "dnet-download-service"}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/test/java/DownloadWorkerTest.java
1
import java.security.Security;
2

  
3
import com.google.common.base.Function;
4
import eu.dnetlib.data.download.DownloadReportMap;
5
import eu.dnetlib.data.download.rmi.DownloadItem;
6
import eu.dnetlib.data.download.worker.DownloadWorker;
7
import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
8
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
9
import eu.dnetlib.data.objectstore.rmi.Protocols;
10

  
11
import org.junit.Before;
12
import org.junit.Ignore;
13
import org.junit.Test;
14
import org.junit.runner.RunWith;
15
import org.mockito.Mock;
16
import org.mockito.junit.MockitoJUnitRunner;
17

  
18
import static org.junit.Assert.assertEquals;
19
import static org.mockito.Matchers.any;
20
import static org.mockito.Mockito.when;
21

  
22
/**
23
 * Created by alessia on 22/12/16.
24
 */
25
@RunWith(MockitoJUnitRunner.class)
26
public class DownloadWorkerTest {
27

  
28
	private DownloadWorker dw;
29
	private DownloadReportMap reportMap;
30
	@Mock
31
	private ObjectStore objectStore;
32

  
33
	@Before
34
	public void prepare() throws Exception{
35
		//Security.insertProviderAt(new BouncyCastleProvider(),1);
36
		//System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
37
		reportMap = new DownloadReportMap();
38

  
39
		when(objectStore.feedObjectRecord(any(ObjectStoreRecord.class))).thenReturn("OK");
40

  
41
		dw = new DownloadWorker(null, objectStore, Protocols.valueOf("HTTP"), "application/pdf", 60000, 60000, 0,
42
				new Function<String, DownloadItem>() {
43

  
44
					@Override
45
					public DownloadItem apply(final String input) {
46
						return DownloadItem.newObjectfromJSON(input);
47
					}
48
				});
49
	}
50

  
51
	@Ignore
52
	@Test
53
	public void testSSL(){
54
		// String url = "https://econstor.eu/bitstream/10419/45606/1/658945068.pdf";
55
		String url = "https://www.preprints.org/manuscript/201909.0029/v1/download";
56
		dw.doDownload(1, reportMap, getDownloadItem("download.pdf", "download", url));
57

  
58
		System.out.println("Report map status "+reportMap.getStatus());
59
		assertEquals(1,reportMap.getTotalDownloaded());
60
	}
61

  
62
	private DownloadItem getDownloadItem(final String fileName, final String id, String url){
63
		DownloadItem item = new DownloadItem();
64
		item.setFileName(fileName);
65
		item.setIdItemMetadata(id);
66
		item.setOpenAccess("OPEN");
67
		item.setOriginalUrl(url);
68
		item.setUrl(url);
69
		return item;
70
	}
71
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/DownloadReportMap.java
1
package eu.dnetlib.data.download;
2

  
3
import java.util.HashMap;
4

  
5
import com.google.gson.Gson;
6

  
7
/**
8
 * Created by sandro on 06/11/14.
9
 */
10
public class DownloadReportMap extends HashMap<String, DownloadReport> {
11

  
12
	/**
13
	 *
14
	 */
15
	private static final long serialVersionUID = -8881211500697708728L;
16

  
17
	private boolean status;
18

  
19
	private int totalDownloaded;
20

  
21
	public DownloadReportMap() {
22
		this.totalDownloaded = 0;
23
	}
24

  
25
	public void addDowload() {
26
		this.totalDownloaded++;
27
	}
28

  
29
	public boolean getStatus() {
30
		return status;
31
	}
32

  
33
	public void setStatus(final boolean status) {
34
		this.status = status;
35
	}
36

  
37
	public int getTotalDownloaded() {
38
		return totalDownloaded;
39
	}
40

  
41
	public void setTotalDownloaded(final int totalDownloaded) {
42
		this.totalDownloaded = totalDownloaded;
43
	}
44

  
45
	@Override
46
	public String toString() {
47
		Gson g = new Gson();
48
		return g.toJson(this);
49
	}
50
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/plugins/DummyPlugin.java
1
package eu.dnetlib.data.download.plugins;
2

  
3
import com.google.common.base.Function;
4
import com.google.common.collect.Iterables;
5
import com.google.gson.Gson;
6
import eu.dnetlib.data.download.rmi.AbstractDownloadPlugin;
7
import eu.dnetlib.data.download.rmi.DownloadItem;
8
import eu.dnetlib.data.download.rmi.DownloadPlugin;
9

  
10
import java.util.ArrayList;
11
import java.util.List;
12

  
13
public class DummyPlugin extends AbstractDownloadPlugin implements DownloadPlugin {
14

  
15

  
16
    @Override
17
    public void setBasePath(String basePath) {
18

  
19
    }
20

  
21
    @Override
22
    public DownloadItem retrieveUrl(final DownloadItem item) {
23
        if (checkOpenAccess(item) == null) {
24
            return null;
25
        }
26
        if (filterByRegexp(item) == null) return null;
27
        String url = item.getUrl();
28

  
29
        if ((url == null) || (url.trim().length() == 0)) return null;
30
        @SuppressWarnings("unchecked")
31
        List<String> urls = new Gson().fromJson(url, ArrayList.class);
32
        if ((urls == null) || (urls.size() == 0)) {
33
            item.setOriginalUrl(null);
34
            item.setUrl(null);
35
            return item;
36
        }
37
        item.setOriginalUrl(urls.get(0));
38
        item.setUrl(urls.get(0));
39
        return item;
40
    }
41

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

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

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

  
58

  
59
    @Override
60
    public String extractURL(String baseURL) {
61
        return null;
62
    }
63
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/DownloadReport.java
1
package eu.dnetlib.data.download;
2

  
3
import eu.dnetlib.data.download.rmi.DownloadItem;
4

  
5
/**
6
 * Created by sandro on 06/11/14.
7
 */
8
public class DownloadReport {
9

  
10
    private int numberOfOccurrences;
11
    private String stackTrace;
12

  
13
	private DownloadItem downloadItem;
14

  
15

  
16
    public DownloadReport() {
17
        this.numberOfOccurrences =1;
18

  
19
    }
20

  
21
	public DownloadReport(int numberOfOccurrences, String stackTrace, DownloadItem downloadItem) {
22
		this.numberOfOccurrences = numberOfOccurrences;
23
        this.stackTrace = stackTrace;
24
		this.downloadItem = downloadItem;
25
	}
26

  
27
    public void incrementError(){
28
        this.numberOfOccurrences ++;
29
    }
30

  
31
    public void incrementError(int numberOfOccurrences){
32
        this.numberOfOccurrences += numberOfOccurrences;
33
    }
34

  
35
    /**
36
     * Getter for property 'numberOfOccurrences'.
37
     *
38
     * @return Value for property 'numberOfOccurrences'.
39
     */
40
    public int getNumberOfOccurrences() {
41

  
42
        return numberOfOccurrences;
43
    }
44

  
45
    /**
46
     * Setter for property 'numberOfOccurrences'.
47
     *
48
     * @param numberOfOccurrences Value to set for property 'numberOfOccurrences'.
49
     */
50
    public void setNumberOfOccurrences(int numberOfOccurrences) {
51
        this.numberOfOccurrences = numberOfOccurrences;
52
    }
53

  
54
    /**
55
     * Getter for property 'stackTrace'.
56
     *
57
     * @return Value for property 'stackTrace'.
58
     */
59
    public String getStackTrace() {
60
        return stackTrace;
61
    }
62

  
63
    /**
64
     * Setter for property 'stackTrace'.
65
     *
66
     * @param stackTrace Value to set for property 'stackTrace'.
67
     */
68
    public void setStackTrace(String stackTrace) {
69
        this.stackTrace = stackTrace;
70
    }
71

  
72
	public DownloadItem getDownloadItem() {
73
		return downloadItem;
74
	}
75

  
76
	public void setDownloadItem(final DownloadItem downloadItem) {
77
		this.downloadItem = downloadItem;
78
	}
79
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/DownloadAction.java
1
package eu.dnetlib.data.download;
2

  
3
import java.util.List;
4
import javax.annotation.Resource;
5

  
6
import com.google.gson.Gson;
7
import com.google.gson.reflect.TypeToken;
8
import eu.dnetlib.data.download.rmi.DownloadServiceActions;
9
import eu.dnetlib.data.download.rmi.DownloadServiceException;
10
import eu.dnetlib.data.download.rmi.DownloadServiceFeeder;
11
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
12
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
13
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
14
import org.apache.commons.codec.binary.Base64;
15
import org.apache.commons.lang3.StringUtils;
16
import org.apache.commons.logging.Log;
17
import org.apache.commons.logging.LogFactory;
18

  
19
public class DownloadAction implements BlackboardServerAction<DownloadServiceActions> {
20

  
21
	/** The Constant log. */
22
	private static final Log log = LogFactory.getLog(DownloadAction.class);
23
	private static String DEFAULT_NUMBER_OF_THREAD = "5";
24
	private static int DEFAULT_TIMEOUT_MS = 5000;
25
	@Resource
26
	private DownloadServiceFeeder downloadServiceFeeder;
27

  
28
	@Override
29
	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
30
		int connectTimeoutMs = DEFAULT_TIMEOUT_MS;
31
		int readTimeoutMs = DEFAULT_TIMEOUT_MS;
32
		int sleepTimeMs = 0;
33
		try {
34
			String epr = job.getParameters().get("epr");
35
			String plugin = job.getParameters().get("plugin");
36
			String objectStoreID = job.getParameters().get("objectStoreID");
37
			String protocol = job.getParameters().get("protocol");
38
			String mimeType = job.getParameters().get("mimeType");
39
			String numberOfThreads = job.getParameters().get("numberOfThreads");
40
			String basePath = job.getParameters().get("basePath");
41
			String regularExpression = job.getParameters().get("regularExpressions");
42
			String connectTimeoutMsStr = job.getParameters().get("connectTimeoutMs");
43
			String readTimeoutMsStr = job.getParameters().get("readTimeoutMs");
44
			String sleepTimeMsStr = job.getParameters().get("sleepTimeMs");
45
			log.debug("regular Expression: " + regularExpression);
46

  
47
			List<String> expressions = null;
48

  
49
			if (!StringUtils.isBlank(regularExpression)) {
50
				expressions = parseRegexList(regularExpression);
51
			}
52

  
53
			if (StringUtils.isBlank(numberOfThreads)) {
54
				log.warn("Cannot find numberOfThread, using default value " + DEFAULT_NUMBER_OF_THREAD);
55
				numberOfThreads = DEFAULT_NUMBER_OF_THREAD;
56
			}
57

  
58
			if (StringUtils.isNotBlank(connectTimeoutMsStr)) connectTimeoutMs = Integer.parseInt(connectTimeoutMsStr);
59
			if (StringUtils.isNotBlank(readTimeoutMsStr)) readTimeoutMs = Integer.parseInt(readTimeoutMsStr);
60
			if (StringUtils.isNotBlank(sleepTimeMsStr)) sleepTimeMs = Integer.parseInt(sleepTimeMsStr);
61

  
62
			log.info(String.format("downloading using plugin %s , protocol : %s into ObjectStore id %s  ", plugin, protocol, objectStoreID));
63
			handler.ongoing(job);
64
			DownloadReportMap response = downloadServiceFeeder.download(epr, plugin, objectStoreID, protocol, mimeType, Integer.parseInt(numberOfThreads),
65
					basePath, expressions, connectTimeoutMs, readTimeoutMs, sleepTimeMs);
66
			if (response.getStatus()) {
67
				log.info(String.format("Completed Download, plugin: %s, protocol: %s, objectStoreID: %s", plugin, protocol, objectStoreID));
68
				job.getParameters().put("total", "" + response.getTotalDownloaded());
69
				job.getParameters().put("report", Base64.encodeBase64String(response.toString().getBytes()));
70
				handler.done(job);
71
			} else {
72
				log.error("download response is false" + response);
73

  
74
				handler.failed(job, new DownloadServiceException(
75
						"oops! something bad happen to our download hamsters, downloaded so far: " + response.getTotalDownloaded()));
76
			}
77
		} catch (Exception e) {
78
			log.error("An error occur while starting download", e);
79
			handler.failed(job, new DownloadServiceException(e));
80
		}
81
	}
82

  
83
	private List<String> parseRegexList(final String regularExpression) {
84
		log.info("parsing regex list: " + regularExpression);
85
		return new Gson().fromJson(regularExpression, new TypeToken<List<String>>() {}.getType());
86
	}
87

  
88
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/rmi/DownloadServiceFeeder.java
1
package eu.dnetlib.data.download.rmi;
2

  
3
import java.util.List;
4
import java.util.concurrent.BlockingQueue;
5
import java.util.concurrent.ExecutorService;
6
import java.util.concurrent.Executors;
7
import java.util.concurrent.Future;
8
import javax.annotation.Resource;
9

  
10
import com.google.common.base.Joiner;
11
import com.google.common.collect.Lists;
12
import com.google.common.collect.Queues;
13
import eu.dnetlib.data.download.DownloadPluginEnumeratorImpl;
14
import eu.dnetlib.data.download.DownloadReport;
15
import eu.dnetlib.data.download.DownloadReportMap;
16
import eu.dnetlib.data.download.DownloadServiceImpl;
17
import eu.dnetlib.data.download.worker.DownloadWorker;
18
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
19
import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
20
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
21
import eu.dnetlib.data.objectstore.rmi.Protocols;
22
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
23
import org.apache.commons.logging.Log;
24
import org.apache.commons.logging.LogFactory;
25
import org.springframework.beans.factory.annotation.Autowired;
26

  
27
/**
28
 * The Class DownloadServiceFeeder.
29
 */
30
public class DownloadServiceFeeder {
31

  
32
	/** The Constant log. */
33
	private static final Log log = LogFactory.getLog(DownloadServiceFeeder.class);
34
	private static final int MAX_NUM_FOUND = 10;
35

  
36
	/** The download plugin enumerator. */
37
	@Resource
38
	DownloadPluginEnumeratorImpl downloadPluginEnumerator;
39

  
40
	/** The result set client factory. */
41
	@Resource
42
	private ResultSetClientFactory resultSetClientFactory;
43

  
44
	/** The object store dao. */
45
	@Autowired
46
	private ObjectStoreDao objectStoreDao;
47

  
48
	public static void reportException(final DownloadReportMap report, final DownloadItem di, final Throwable e) {
49
		final String className = e.getClass().getName();
50
		if (!report.containsKey(className)) {
51
			final DownloadReport dr = new DownloadReport();
52
			dr.setStackTrace(Joiner.on("\tat ").join(e.getStackTrace()));
53
			if (di != null) {
54
				dr.setDownloadItem(di);
55
			}
56
			report.put(className, dr);
57
		} else {
58
			report.get(className).incrementError();
59
		}
60
	}
61

  
62
	/**
63
	 * Download and feed file into the objectStore .
64
	 *
65
	 * @param epr
66
	 *            the end-point reference of the result-set of Serialized DownloadItem
67
	 * @param plugin
68
	 *            the plugin used to retrieve the correct URL
69
	 * @param objectStoreID
70
	 *            the object store id to store the data
71
	 * @param protocol
72
	 *            the protocol used to download the file
73
	 * @param mimeType
74
	 *            the mime type of the Files
75
	 * @param numberOfThreads
76
	 *            the number of threads to use for download at the same time
77
	 * @throws DownloadServiceException
78
	 *             the download service exception
79
	 * @throws ObjectStoreServiceException
80
	 */
81
	public DownloadReportMap download(final String epr,
82
			final String plugin,
83
			final String objectStoreID,
84
			final String protocol,
85
			final String mimeType,
86
			final int numberOfThreads,
87
			final String basePath,
88
			final List<String> regularExpression,
89
			final int connectTimeoutMs,
90
			final int readTimeoutMs, final int sleepTimeMs) throws DownloadServiceException, ObjectStoreServiceException {
91
		final DownloadPlugin downloadPlugin = downloadPluginEnumerator.get(plugin);
92
		if ((basePath != null) && (basePath.isEmpty() == false)) {
93
			downloadPlugin.setBasePath(basePath);
94
		}
95

  
96
		final Iterable<String> urlInfo = resultSetClientFactory.getClient(epr);
97
		final BlockingQueue<String> itemsQueue = Queues.newArrayBlockingQueue(1024);
98
		final ExecutorService executor = Executors.newFixedThreadPool(numberOfThreads);
99
		final ObjectStore objStore = objectStoreDao.getObjectStore(objectStoreID);
100

  
101
		final List<Future<DownloadReportMap>> responses = Lists.newArrayList();
102
		final DownloadReportMap pluginReport = new DownloadReportMap();
103
		pluginReport.setStatus(true);
104

  
105
		if (regularExpression != null) {
106
			downloadPlugin.setRegularExpression(regularExpression);
107
		}
108

  
109
		for (int i = 0; i < numberOfThreads; i++) {
110
			responses.add(executor
111
					.submit(new DownloadWorker(itemsQueue, objStore, Protocols.valueOf(protocol), mimeType, connectTimeoutMs, readTimeoutMs, sleepTimeMs,
112
							input -> {
113
								if (input == null) {
114
									log.debug("Input is null");
115
									return null;
116
								}
117
								if (input.equals(DownloadServiceImpl.END_QUEUE_STRING)) return DownloadServiceImpl.END_QUEUE;
118

  
119
								DownloadItem di = null;
120
								try {
121
									di = DownloadItem.newObjectfromJSON(input);
122

  
123
									if (downloadPlugin.retrieveUrl(di) == null) {
124
										di.setUrl(null);
125
										di.setOriginalUrl(null);
126
									}
127
									return di;
128
								} catch (Throwable e) {
129
									reportException(pluginReport, di, e);
130
									log.debug("Exception on transform item :" + input, e);
131
									return null;
132
								}
133
							})));
134
		}
135

  
136
		int i = 0;
137
		int null_found = 0;
138
		if (urlInfo != null) {
139
			for (final String downloadItem : urlInfo) {
140
				if (downloadItem != null) {
141
					null_found = 0;
142
					if ((i++ % 1000) == 0) {
143
						log.debug("Read " + i);
144
					}
145
					try {
146
						itemsQueue.put(downloadItem);
147
					} catch (final Exception e) {
148
						log.error("An error occurred while populating the download items queue: " + Joiner.on("\tat ").join(e.getStackTrace()));
149
					}
150
				} else {
151
					if (null_found++ > MAX_NUM_FOUND) {
152
						break;
153
					}
154
				}
155

  
156
			}
157
		}
158

  
159
		try {
160
			itemsQueue.put(DownloadServiceImpl.END_QUEUE_STRING);
161
		} catch (final InterruptedException e) {
162
			log.error("An error occurred adding the loop terminator: " + Joiner.on("\tat ").join(e.getStackTrace()));
163
		}
164

  
165
		final DownloadReportMap resultMap = getDownloadReportMap(responses, pluginReport);
166
		executor.shutdown();
167
		return resultMap;
168
	}
169

  
170
	private DownloadReportMap getDownloadReportMap(final List<Future<DownloadReportMap>> responses, final DownloadReportMap pluginReport) {
171
		final DownloadReportMap resultMap = new DownloadReportMap();
172
		resultMap.setStatus(true);
173

  
174
		for (final Future<DownloadReportMap> currentResponse : responses) {
175
			try {
176
				final DownloadReportMap currentMap = currentResponse.get();
177

  
178
				mergeReport(resultMap, currentMap);
179

  
180
				log.info("Status " + currentMap.getStatus());
181
				resultMap.setStatus(resultMap.getStatus() && currentMap.getStatus());
182
				resultMap.setTotalDownloaded(currentMap.getTotalDownloaded() + resultMap.getTotalDownloaded());
183

  
184
			} catch (final Exception e) {
185
				log.error(e);
186
				resultMap.setStatus(false);
187
			}
188
		}
189
		mergeReport(resultMap, pluginReport);
190
		return resultMap;
191
	}
192

  
193
	private void mergeReport(final DownloadReportMap resultMap, final DownloadReportMap currentMap) {
194
		for (final String key : currentMap.keySet()) {
195
			if (!resultMap.containsKey(key)) {
196
				resultMap.put(key, currentMap.get(key));
197
			} else {
198
				final DownloadReport currentReport = currentMap.get(key);
199
				resultMap.get(key).incrementError(currentReport.getNumberOfOccurrences());
200
			}
201
			resultMap.setTotalDownloaded(resultMap.getTotalDownloaded() + currentMap.getTotalDownloaded());
202
			resultMap.setStatus(resultMap.getStatus() & currentMap.getStatus());
203
		}
204
	}
205
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/rmi/DownloadServiceActions.java
1
package eu.dnetlib.data.download.rmi;
2

  
3
public enum DownloadServiceActions {
4
	DOWNLOAD,
5

  
6
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/worker/DownloadWorker.java
1
package eu.dnetlib.data.download.worker;
2

  
3
import java.io.IOException;
4
import java.net.HttpURLConnection;
5
import java.net.URL;
6
import java.net.URLConnection;
7
import java.util.concurrent.BlockingQueue;
8
import java.util.concurrent.Callable;
9
import java.util.concurrent.TimeUnit;
10

  
11
import com.google.common.base.Function;
12
import com.google.common.base.Joiner;
13
import eu.dnetlib.data.download.DownloadReportMap;
14
import eu.dnetlib.data.download.DownloadServiceImpl;
15
import eu.dnetlib.data.download.rmi.DownloadItem;
16
import eu.dnetlib.data.download.rmi.DownloadServiceFeeder;
17
import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
18
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
19
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
20
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
21
import eu.dnetlib.data.objectstore.rmi.Protocols;
22
import org.apache.commons.lang3.StringUtils;
23
import org.apache.commons.logging.Log;
24
import org.apache.commons.logging.LogFactory;
25

  
26
/**
27
 * The Class DownloadWorker is a worker responsible to download the data into the object store.
28
 */
29
public class DownloadWorker implements Callable<DownloadReportMap> {
30

  
31
	/**
32
	 * The Constant log.
33
	 */
34
	private static final Log log = LogFactory.getLog(DownloadWorker.class);
35
	private static final int MAX_NULLS = 5 ;
36

  
37
	/**
38
	 * The queue.
39
	 */
40
	private BlockingQueue<String> queue = null;
41

  
42
	/**
43
	 * The object store.
44
	 */
45
	private ObjectStore objectStore = null;
46

  
47
	/**
48
	 * The protocol.
49
	 */
50
	private Protocols protocol;
51

  
52
	/**
53
	 * The mime type.
54
	 */
55
	private String mimeType;
56

  
57
	private Function<String, DownloadItem> converter;
58

  
59
	private int connectTimeoutMs;
60
	private int readTimeoutMs;
61

  
62
	/**
63
	 * ms to wait between two subsequent download request
64
	 **/
65
	private int sleepTimeMs;
66
	
67
	private String userAgent = "Mozilla/5.0 (compatible; OAI; +http://www.openaire.eu)";  // "OpenAIRE aggregation system/2.2.5 ; (OpenAccess aggregator; mailto:helpdesk@openaire.eu)"
68

  
69
	/**
70
	 * Instantiates a new download worker.
71
	 *
72
	 * @param queue
73
	 *            the queue
74
	 * @param objectStore
75
	 *            the object store
76
	 * @param protocol
77
	 *            the protocol
78
	 * @param mimeType
79
	 *            the mime type
80
	 */
81
	public DownloadWorker(final BlockingQueue<String> queue,
82
			final ObjectStore objectStore,
83
			final Protocols protocol,
84
			final String mimeType,
85
			final int connectTimeoutMs,
86
			final int readTimeoutMs, final int sleepTimeMs,
87
			final Function<String, DownloadItem> converter) {
88
		this.setConverter(converter);
89
		this.setQueue(queue);
90
		this.setObjectStore(objectStore);
91
		this.setMimeType(mimeType);
92
		this.setProtocol(protocol);
93
		this.setConnectTimeoutMs(connectTimeoutMs);
94
		this.setReadTimeoutMs(readTimeoutMs);
95
		this.setSleepTimeMs(sleepTimeMs);
96
	}
97

  
98
	/*
99
	 * (non-Javadoc)
100
	 *
101
	 * @see java.lang.Runnable#run()
102
	 */
103
	@Override
104
	public DownloadReportMap call() throws Exception {
105
		final DownloadReportMap report = new DownloadReportMap();
106
		final long threadId = Thread.currentThread().getId();
107
		int nullCounter = 0;
108
		try {
109

  
110
			String takedObject = queue.poll(5, TimeUnit.SECONDS);
111

  
112
			while (!DownloadServiceImpl.END_QUEUE_STRING.equals(takedObject) && nullCounter < MAX_NULLS) {
113

  
114
				if (takedObject == null) {
115
					nullCounter++;
116
				}
117
				if (log.isDebugEnabled()) {
118
					log.debug(takedObject);
119
				}
120
				final DownloadItem di = getConverter().apply(takedObject);
121

  
122
				log.debug(threadId + ": Reading " + takedObject);
123

  
124
				if (di == null) {
125
					log.debug("the current download item is Null, skipping");
126
					DownloadServiceFeeder.reportException(report, null, new IllegalArgumentException("found null DownloadItem"));
127
				} else if (StringUtils.isNotBlank(di.getUrl()) && !checkIfExists(di)) {
128
					doDownload(threadId, report, di);
129
				}
130
				takedObject = queue.poll(5, TimeUnit.SECONDS);
131
				log.debug(String.format("%s: next object from queue %s, remaining items: %s", threadId, takedObject, queue.size()));
132
			}
133
		} catch (final Exception e) {
134
			log.debug("An error occured : " + Joiner.on("\tat ").join(e.getStackTrace()));
135
			DownloadServiceFeeder.reportException(report, null, e);
136
			report.setStatus(false);
137
			return report;
138
		} finally {
139
			log.info(String.format("%s: finalising queue, remaining items: %s, nulls: %s", threadId, queue.size(), nullCounter));
140
			final boolean res = queue.offer(DownloadServiceImpl.END_QUEUE_STRING, 5, TimeUnit.SECONDS);
141
			log.info("put terminator in queue: " + res);
142
		}
143

  
144
		log.info("CLOSED THREAD " + threadId);
145
		report.setStatus(true);
146
		return report;
147
	}
148

  
149
	public void doDownload(final long threadId, final DownloadReportMap report, final DownloadItem di) {
150
		try {
151
			if (getSleepTimeMs() > 0) {
152
				log.debug(threadId + ": I will sleep for " + getSleepTimeMs() + " ms, as requested...");
153
				Thread.sleep(getSleepTimeMs());
154
			}
155

  
156
			final URL toDownload = followURL(threadId, new URL(di.getUrl()), report, di);
157
			final ObjectStoreRecord record = new ObjectStoreRecord();
158
			final ObjectStoreFile metadata = new ObjectStoreFile();
159
			metadata.setObjectID(di.getFileName());
160
			metadata.setMetadataRelatedID(di.getIdItemMetadata());
161
			metadata.setAccessProtocol(this.protocol);
162
			metadata.setMimeType(this.mimeType);
163
			metadata.setDownloadedURL(di.getOriginalUrl());
164
			record.setFileMetadata(metadata);
165

  
166
			log.debug(threadId + ": opening connection " + toDownload);
167
			final URLConnection connection = toDownload.openConnection();
168
			// set user-agent
169
			connection.setRequestProperty("User-Agent", userAgent);
170
			connection.setConnectTimeout(getConnectTimeoutMs());
171
			connection.setReadTimeout(getReadTimeoutMs());
172
			//connection.setRequestProperty("User-Agent", "OpenAIRE aggregation system/2.2.5 ; (OpenAccess aggregator; mailto:helpdesk@openaire.eu) ");
173

  
174
			log.debug(threadId + ": getting input stream from " + toDownload);
175
			record.setInputStream(connection.getInputStream());
176
			log.debug(threadId + ": feeding object from  " + toDownload + " into objectstore ...");
177
			objectStore.feedObjectRecord(record);
178
			report.addDowload();
179
			log.debug(threadId + ": saved object " + metadata.toJSON());
180
		} catch (final Throwable e) {
181
			log.debug(threadId + ": error downloading Item: " + di.toJSON(), e);
182
			DownloadServiceFeeder.reportException(report, di, e);
183
		}
184
	}
185

  
186
	private URL followURL(final long threadId, final URL inputURL, final DownloadReportMap report, final DownloadItem di) throws IOException {
187

  
188
		final String ptrcl = inputURL.getProtocol();
189
		if (ptrcl.startsWith("file")) {
190
			log.debug("the protocol is File, returning " + inputURL);
191
			return inputURL;
192
		}
193
		HttpURLConnection conn = (HttpURLConnection) inputURL.openConnection();
194
		conn.setInstanceFollowRedirects(true);  // you still need to handle redirect manually.
195
		conn.setReadTimeout(getReadTimeoutMs());
196
		conn.setConnectTimeout(getConnectTimeoutMs());
197
		// set user-agent
198
		conn.setRequestProperty("User-Agent", userAgent);
199

  
200
		String location = inputURL.toString();
201
		log.debug(threadId + " : followURL connecting  " + inputURL);
202
		conn.connect();
203
		log.debug(threadId + " : followURL connected  " + inputURL);
204
		int responseCode = conn.getResponseCode();
205
		log.debug(threadId + " : followURL " + inputURL + ", response code: " + responseCode);
206
		if ((responseCode >= 300) && (responseCode < 400)) {
207
			location = conn.getHeaderFields().get("Location").get(0);
208
			conn.disconnect();
209
			log.debug(threadId + " : followURL disconnected  " + inputURL);
210
		}
211

  
212
		if (!location.equals(inputURL.toString())) return new URL(location);
213
		return inputURL;
214
	}
215

  
216
	private boolean checkIfExists(final DownloadItem di) {
217
		try {
218
			return objectStore.deliverObject(di.getFileName()) != null;
219
		} catch (final ObjectStoreServiceException e) {
220
			log.debug(e.getMessage());
221
			return false;
222
		}
223
	}
224

  
225
	/**
226
	 * Sets the object store.
227
	 *
228
	 * @param objectStore
229
	 *            the objectStore to set
230
	 */
231
	public void setObjectStore(final ObjectStore objectStore) {
232
		this.objectStore = objectStore;
233
	}
234

  
235
	/**
236
	 * Sets the queue.
237
	 *
238
	 * @param queue
239
	 *            the queue to set
240
	 */
241
	public void setQueue(final BlockingQueue<String> queue) {
242
		this.queue = queue;
243
	}
244

  
245
	/**
246
	 * Sets the protocol.
247
	 *
248
	 * @param protocol
249
	 *            the protocol to set
250
	 */
251
	public void setProtocol(final Protocols protocol) {
252
		this.protocol = protocol;
253
	}
254

  
255
	/**
256
	 * Sets the mime type.
257
	 *
258
	 * @param mimeType
259
	 *            the mimeType to set
260
	 */
261
	public void setMimeType(final String mimeType) {
262
		this.mimeType = mimeType;
263
	}
264

  
265
	public Function<String, DownloadItem> getConverter() {
266
		return converter;
267
	}
268

  
269
	public void setConverter(final Function<String, DownloadItem> converter) {
270
		this.converter = converter;
271
	}
272

  
273
	public int getReadTimeoutMs() {
274
		return readTimeoutMs;
275
	}
276

  
277
	public void setReadTimeoutMs(final int readTimeoutMs) {
278
		this.readTimeoutMs = readTimeoutMs;
279
	}
280

  
281
	public int getConnectTimeoutMs() {
282
		return connectTimeoutMs;
283
	}
284

  
285
	public void setConnectTimeoutMs(final int connectTimeoutMs) {
286
		this.connectTimeoutMs = connectTimeoutMs;
287
	}
288

  
289
	public int getSleepTimeMs() {
290
		return sleepTimeMs;
291
	}
292

  
293
	public void setSleepTimeMs(final int sleepTimeMs) {
294
		this.sleepTimeMs = sleepTimeMs;
295
	}
296
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/DownloadPluginEnumeratorImpl.java
1
package eu.dnetlib.data.download;
2

  
3
import java.util.Map;
4

  
5
import org.springframework.beans.BeansException;
6
import org.springframework.beans.factory.BeanFactory;
7
import org.springframework.beans.factory.ListableBeanFactory;
8

  
9
import com.google.common.collect.Maps;
10

  
11
import eu.dnetlib.data.download.rmi.DownloadPlugin;
12
import eu.dnetlib.data.download.rmi.DownloadPluginEnumerator;
13
import eu.dnetlib.data.download.rmi.DownloadServiceException;
14

  
15
/**
16
 * The Class DownloadPluginEnumeratorImpl.
17
 */
18
public class DownloadPluginEnumeratorImpl implements DownloadPluginEnumerator {
19

  
20
	/**
21
	 * bean factory.
22
	 */
23
	private ListableBeanFactory beanFactory;
24

  
25
	/*
26
	 * (non-Javadoc)
27
	 *
28
	 * @see eu.dnetlib.data.download.rmi.DownloadPluginEnumerator#getAll()
29
	 */
30
	@Override
31
	public Map<String, DownloadPlugin> getAll() {
32
		return beanFactory.getBeansOfType(DownloadPlugin.class);
33
	}
34

  
35
	/*
36
	 * (non-Javadoc)
37
	 *
38
	 * @see eu.dnetlib.data.download.rmi.DownloadPluginEnumerator#getByProtocols()
39
	 */
40
	@Override
41
	public Map<String, DownloadPlugin> getByProtocols() {
42
		final Map<String, DownloadPlugin> res = Maps.newHashMap();
43
		for (DownloadPlugin cp : getAll().values()) {
44
			res.put(cp.getPluginName().toLowerCase(), cp);
45
		}
46
		return res;
47
	}
48

  
49
	/*
50
	 * (non-Javadoc)
51
	 *
52
	 * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
53
	 */
54
	@Override
55
	public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
56
		this.beanFactory = (ListableBeanFactory) beanFactory;
57
	}
58

  
59
	/**
60
	 * Gets the bean factory.
61
	 *
62
	 * @return the bean factory
63
	 */
64
	public ListableBeanFactory getBeanFactory() {
65
		return beanFactory;
66
	}
67

  
68
	/**
69
	 * Get given DownloadPlugin or throws exception.
70
	 *
71
	 * @param protocol
72
	 *            the protocol
73
	 * @return the download plugin
74
	 * @throws eu.dnetlib.data.download.rmi.DownloadServiceException
75
	 *             the download service exception
76
	 */
77
	public DownloadPlugin get(final String protocol) throws DownloadServiceException {
78
		final DownloadPlugin plugin = getByProtocols().get(protocol.toLowerCase());
79
		if (plugin == null) throw new DownloadServiceException("plugin not found for name: " + protocol);
80
		return plugin;
81
	}
82

  
83
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/java/eu/dnetlib/data/download/DownloadServiceImpl.java
1
package eu.dnetlib.data.download;
2

  
3
import java.security.KeyManagementException;
4
import java.security.NoSuchAlgorithmException;
5
import java.security.Security;
6
import java.security.cert.CertificateException;
7
import java.util.ArrayList;
8
import java.util.List;
9
import javax.annotation.Resource;
10
import javax.net.ssl.*;
11
import javax.xml.ws.wsaddressing.W3CEndpointReference;
12

  
13
import eu.dnetlib.data.download.rmi.DownloadItem;
14
import eu.dnetlib.data.download.rmi.DownloadService;
15
import eu.dnetlib.data.download.rmi.DownloadServiceException;
16
import eu.dnetlib.data.download.rmi.DownloadServiceFeeder;
17
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
18
import eu.dnetlib.enabling.tools.AbstractBaseService;
19
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
20
import org.apache.commons.logging.Log;
21
import org.apache.commons.logging.LogFactory;
22
import org.springframework.beans.factory.annotation.Required;
23
import org.springframework.beans.factory.annotation.Value;
24

  
25
/**
26
 * The Class DownloadServiceImpl.
27
 */
28
public class DownloadServiceImpl extends AbstractBaseService implements DownloadService {
29

  
30
	/**
31
	 * The Constant END_QUEUE.
32
	 */
33
	public static final DownloadItem END_QUEUE = new DownloadItem();
34

  
35
	public static final String END_QUEUE_STRING = "END_DOWNLOAD";
36

  
37
	/**
38
	 * The Constant log.
39
	 */
40
	private static final Log log = LogFactory.getLog(DownloadServiceImpl.class);
41
	private static int DEFAULT_CONNECT_TIMEOUT_MS = 5000;
42
	private static int DEFAULT_READ_TIMEOUT_MS = 5000;
43
	/**
44
	 * The download plugin enumerator.
45
	 */
46
	@Resource
47
	private DownloadPluginEnumeratorImpl downloadPluginEnumerator;
48
	@Resource
49
	private DownloadServiceFeeder downloadfeeder;
50
	/**
51
	 * The notification handler.
52
	 */
53
	private NotificationHandler notificationHandler;
54
	@Value("${services.download.http.sslcheck}")
55
	private boolean checkCerts;
56
	@Value("${services.download.https.protocols}")
57
	private String httpsProtocols;
58

  
59
	/*
60
	 * (non-Javadoc)
61
	 *
62
	 * @see eu.dnetlib.data.download.rmi.DownloadService#downloadFromResultSet(javax.xml.ws.wsaddressing.W3CEndpointReference,
63
	 * java.lang.String, java.lang.String, java.lang.String, java.lang.String)
64
	 */
65
	@Override
66
	public void downloadFromResultSet(final W3CEndpointReference resultSet,
67
			final String plugin,
68
			final String objectStoreID,
69
			final String protocol,
70
			final String mimeType) throws DownloadServiceException {
71

  
72
		log.info(String.format("download using plugin '%s' , protocol '%s' into ObjectStore '%s'", plugin, protocol, objectStoreID));
73
		try {
74
			downloadfeeder.download(resultSet.toString(), plugin, objectStoreID, protocol, mimeType, 5, null, null, DEFAULT_CONNECT_TIMEOUT_MS,
75
					DEFAULT_READ_TIMEOUT_MS, 0);
76
		} catch (ObjectStoreServiceException e) {
77
			log.error(e);
78
		}
79
		log.info(String.format("download completed using plugin '%s' , protocol '%s' into ObjectStore '%s'", plugin, protocol, objectStoreID));
80
	}
81

  
82
	/**
83
	 * {@inheritDoc}
84
	 *
85
	 * @see eu.dnetlib.enabling.tools.AbstractBaseService#notify(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
86
	 */
87
	@Override
88
	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
89
		getNotificationHandler().notified(subscriptionId, topic, isId, message);
90
	}
91

  
92
	@Override
93
	public void start() {
94
		if (!checkCerts) {
95
			log.info("disabling SSL check ...");
96
			new Thread(new Runnable() {
97

  
98
				@Override
99
				public void run() {
100
					disableSslVerification();
101
				}
102
			}).start();
103
		}
104
		//TODO: we should remove references to BouncyCastle. We are not expecting issues like #2520 with Java8
105
		//Security.insertProviderAt(new BouncyCastleProvider(),1);
106
		//System.setProperty("https.protocols", httpsProtocols);
107
	}
108

  
109
	private void disableSslVerification() {
110
		try {
111
			// Create a trust manager that does not validate certificate chains
112
			TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
113

  
114
				@Override
115
				public void checkClientTrusted(final java.security.cert.X509Certificate[] x509Certificates, final String s) throws CertificateException {
116

  
117
				}
118

  
119
				@Override
120
				public void checkServerTrusted(final java.security.cert.X509Certificate[] x509Certificates, final String s) throws CertificateException {
121

  
122
				}
123

  
124
				@Override
125
				public java.security.cert.X509Certificate[] getAcceptedIssuers() {
126
					return null;
127
				}
128
			} };
129

  
130
			// Install the all-trusting trust manager
131
			SSLContext sc = SSLContext.getInstance("SSL");
132
			sc.init(null, trustAllCerts, new java.security.SecureRandom());
133
			HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
134

  
135
			// Create all-trusting host name verifier
136
			HostnameVerifier allHostsValid = new HostnameVerifier() {
137

  
138
				@Override
139
				public boolean verify(final String hostname, final SSLSession session) {
140
					return true;
141
				}
142
			};
143

  
144
			// Install the all-trusting host verifier
145
			HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
146
			log.info("disabled SSL check");
147
		} catch (NoSuchAlgorithmException e) {
148
			log.error(e.getMessage(), e);
149
		} catch (KeyManagementException e) {
150
			log.error(e.getMessage(), e);
151
		}
152
	}
153

  
154
	/**
155
	 * @return the downloadfeeder
156
	 */
157
	public DownloadServiceFeeder getDownloadfeeder() {
158
		return downloadfeeder;
159
	}
160

  
161
	/**
162
	 * @param downloadfeeder the downloadfeeder to set
163
	 */
164
	public void setDownloadfeeder(final DownloadServiceFeeder downloadfeeder) {
165
		this.downloadfeeder = downloadfeeder;
166
	}
167

  
168
	/**
169
	 * @return the notificationHandler
170
	 */
171
	public NotificationHandler getNotificationHandler() {
172
		return notificationHandler;
173
	}
174

  
175
	/**
176
	 * @param notificationHandler the notificationHandler to set
177
	 */
178
	@Required
179
	public void setNotificationHandler(final NotificationHandler notificationHandler) {
180
		this.notificationHandler = notificationHandler;
181
	}
182

  
183
	@Override
184
	public List<String> listPlugins() throws DownloadServiceException {
185

  
186
		List<String> result = new ArrayList<String>();
187
		result.addAll(downloadPluginEnumerator.getAll().keySet());
188
		return result;
189
	}
190

  
191
}
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/resources/eu/dnetlib/data/download/applicationContext-dnet-downloadService.properties
1
services.download.http.sslcheck=false
2
services.download.https.protocols=TLSv1,TLSv1.1,TLSv1.2
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/resources/eu/dnetlib/data/download/applicationContext-dnet-downloadService.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
4
	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
5
	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
6
	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
7
	xmlns:util="http://www.springframework.org/schema/util"
8
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
9
                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
10
                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
11
                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
12
                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
13
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
14
                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
15
                            
16
    <bean id="downloadNotificationHandler"
17
		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
18
		p:blackboardExecutor-ref="downloadBlackboardExecutor" />
19
		
20
	<bean id = "DownloadServiceFeeder" class ="eu.dnetlib.data.download.rmi.DownloadServiceFeeder" />
21

  
22
	<bean id="downloadBlackboardExecutor"
23
		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
24
		p:blackboardHandler-ref="blackboardHandler"
25
		p:actionType="eu.dnetlib.data.download.rmi.DownloadServiceActions"
26
		p:incomplete="false">
27
		<property name="actionMap">
28
			<map>
29
				<entry key="DOWNLOAD">
30
					<bean class="eu.dnetlib.data.download.DownloadAction"/>
31
				</entry>				
32
			</map>
33
		</property>
34
	</bean>		
35
                            
36
                            
37
    <bean id="DummyPlugin" class="eu.dnetlib.data.download.plugins.DummyPlugin" />
38

  
39
	<bean id="downloadSerive" class="eu.dnetlib.data.download.DownloadServiceImpl"
40
		init-method="start" p:notificationHandler-ref="downloadNotificationHandler" />
41

  
42
	<bean id="downloadPluginEnumerator" class="eu.dnetlib.data.download.DownloadPluginEnumeratorImpl" />
43

  
44
	<jaxws:endpoint id="downloadServiceEndpoint"
45
		implementor="#downloadSerive" implementorClass="eu.dnetlib.data.download.rmi.DownloadService"
46
		address="/downloadService" />
47

  
48
	<template:instance name="serviceRegistrationManager"
49
		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
50
		t:name="downloadServiceRegistrationManager" t:service="downloadSerive"
51
		t:endpoint="downloadServiceEndpoint" t:jobScheduler="jobScheduler"
52
		t:serviceRegistrator="blackboardServiceRegistrator" />
53

  
54

  
55
</beans>
modules/dnet-download-service/tags/dnet-download-service-2.2.6/src/main/resources/log4j.properties
1
log4j.rootLogger=WARN, CONSOLE
2
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
3
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
4
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
5

  
6
org.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
7

  
8
### Application Level ###
9
log4j.logger.eu.dnetlib=INFO
10
log4j.logger.eu.dnetlib.data.download=DEBUG
11

  
12

  
13

  
modules/dnet-download-service/tags/dnet-download-service-2.2.6/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
	<parent>
3
		<groupId>eu.dnetlib</groupId>
4
		<artifactId>dnet45-parent</artifactId>
5
		<version>1.0.0</version>
6
		<relativePath />
7
	</parent>
8
	<modelVersion>4.0.0</modelVersion>
9
	<groupId>eu.dnetlib</groupId>
10
	<artifactId>dnet-download-service</artifactId>
11
	<version>2.2.6</version>
12
	<scm>
13
		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-download-service/tags/dnet-download-service-2.2.6</developerConnection>
14
	</scm>
15
	<dependencies>
16
		<dependency>
17
			<groupId>eu.dnetlib</groupId>
18
			<artifactId>dnet-download-service-rmi</artifactId>
19
			<version>[1.0.0,2.0.0)</version>
20
		</dependency>
21
		<dependency>
22
			<groupId>eu.dnetlib</groupId>
23
			<artifactId>cnr-service-common</artifactId>
24
			<version>[2.1.0,3.0.0)</version>
25
		</dependency>
26
		<dependency>
27
			<groupId>eu.dnetlib</groupId>
28
			<artifactId>dnet-modular-objectstore-service</artifactId>
29
			<version>[5.0.0,6.0.0)</version>
30
		</dependency>
31
		<dependency>
32
			<groupId>junit</groupId>
33
			<artifactId>junit</artifactId>
34
			<version>${junit.version}</version>
35
			<scope>test</scope>
36
		</dependency>
37
		<dependency>
38
			<groupId>org.mockito</groupId>
39
			<artifactId>mockito-core</artifactId>
40
			<version>${mockito.version}</version>
41
			<scope>test</scope>
42
		</dependency>
43
	</dependencies>
44
</project>

Also available in: Unified diff