1
|
package eu.dnetlib.clients.ws;
|
2
|
|
3
|
import org.apache.log4j.Logger;
|
4
|
|
5
|
import eu.dnetlib.api.DriverService;
|
6
|
import eu.dnetlib.domain.ServiceIdentity;
|
7
|
import eu.dnetlib.domain.enabling.Notification;
|
8
|
|
9
|
public abstract class BaseDriverWebService<S extends DriverService> implements
|
10
|
DriverWebService<S> {
|
11
|
private static Logger logger = Logger.getLogger(BaseDriverWebService.class);
|
12
|
|
13
|
protected S service = null;
|
14
|
|
15
|
public void setService(S service) {
|
16
|
this.service = service;
|
17
|
}
|
18
|
|
19
|
@Override
|
20
|
public final String identify() {
|
21
|
ServiceIdentity identity = service.identify();
|
22
|
|
23
|
if (identity != null)
|
24
|
return service.identify().toString();
|
25
|
else
|
26
|
return null;
|
27
|
}
|
28
|
|
29
|
@Override
|
30
|
public final void notify(String subscriptionId, String topic, String isId,
|
31
|
String message) {
|
32
|
logger.debug("Notification received: " + topic + ", message: "
|
33
|
+ message);
|
34
|
|
35
|
try {
|
36
|
Notification notification = new Notification(subscriptionId,
|
37
|
message, topic, isId);
|
38
|
|
39
|
service.notify(notification);
|
40
|
} catch (Exception e) {
|
41
|
logger.error("Error creating notification", e);
|
42
|
}
|
43
|
}
|
44
|
|
45
|
@Override
|
46
|
public void start() {
|
47
|
throw new UnsupportedOperationException();
|
48
|
}
|
49
|
|
50
|
}
|