1
|
package eu.dnetlib.clients.ws;
|
2
|
|
3
|
import eu.dnetlib.api.DriverService;
|
4
|
import eu.dnetlib.api.DriverServiceException;
|
5
|
import eu.dnetlib.domain.ServiceIdentity;
|
6
|
import eu.dnetlib.domain.enabling.Notification;
|
7
|
import eu.dnetlib.utils.ServiceIdentityFactory;
|
8
|
|
9
|
public abstract class BaseWebServiceClient<WS extends DriverWebService<? extends DriverService>>
|
10
|
implements DriverService {
|
11
|
|
12
|
protected WS webService = null;
|
13
|
|
14
|
@Override
|
15
|
public final ServiceIdentity identify() {
|
16
|
String identity = webService.identify();
|
17
|
|
18
|
if (identity != null)
|
19
|
return ServiceIdentityFactory.parseIdentity(webService.identify());
|
20
|
else
|
21
|
return null;
|
22
|
}
|
23
|
|
24
|
@Override
|
25
|
public final void notify(Notification notification)
|
26
|
throws DriverServiceException {
|
27
|
try {
|
28
|
webService.notify(
|
29
|
notification.getSubscriptionId(),
|
30
|
notification.getTopic(),
|
31
|
notification.getIsId(),
|
32
|
notification.getMessage());
|
33
|
} catch (Exception e) {
|
34
|
throw new DriverServiceException(e);
|
35
|
}
|
36
|
}
|
37
|
|
38
|
public final WS getWebService() {
|
39
|
return webService;
|
40
|
}
|
41
|
|
42
|
public final void setWebService(WS webService) {
|
43
|
this.webService = webService;
|
44
|
}
|
45
|
|
46
|
@SuppressWarnings("unchecked")
|
47
|
public final void setWebService(Object webService) {
|
48
|
this.webService = (WS) webService;
|
49
|
}
|
50
|
}
|