Project

General

Profile

« Previous | Next » 

Revision 51738

using commons.lang3 and lambdas

View differences:

modules/dnet-download-service/trunk/src/main/java/eu/dnetlib/data/download/rmi/DownloadServiceFeeder.java
7 7
import java.util.concurrent.Future;
8 8
import javax.annotation.Resource;
9 9

  
10
import com.google.common.base.Function;
11 10
import com.google.common.base.Joiner;
12 11
import com.google.common.collect.Lists;
13 12
import com.google.common.collect.Queues;
......
110 109
		for (int i = 0; i < numberOfThreads; i++) {
111 110
			responses.add(executor
112 111
					.submit(new DownloadWorker(itemsQueue, objStore, Protocols.valueOf(protocol), mimeType, connectTimeoutMs, readTimeoutMs, sleepTimeMs,
113
					new Function<String, DownloadItem>() {
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;
114 118

  
115
				@Override
116
				public DownloadItem apply(final String input) {
117
					if (input == null) {
118
						log.debug("Input is null");
119
						return null;
120
					}
121
					if (input.equals(DownloadServiceImpl.END_QUEUE_STRING)) return DownloadServiceImpl.END_QUEUE;
119
								DownloadItem di = null;
120
								try {
121
									di = DownloadItem.newObjectfromJSON(input);
122 122

  
123
					DownloadItem di = null;
124
					try {
125
						di = DownloadItem.newObjectfromJSON(input);
126

  
127
						if (downloadPlugin.retrieveUrl(di) == null) {
128
							di.setUrl(null);
129
							di.setOriginalUrl(null);
130
						}
131
						return di;
132
					} catch (Throwable e) {
133
						reportException(pluginReport, di, e);
134
						log.debug("Exception on transform item :" + input, e);
135
						return null;
136
					}
137
				}
138
			})));
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
							})));
139 134
		}
140 135

  
141 136
		int i = 0;

Also available in: Unified diff