1 |
45465
|
michele.ar
|
package eu.dnetlib.clients;
|
2 |
|
|
|
3 |
|
|
import org.apache.commons.logging.Log;
|
4 |
|
|
import org.apache.commons.logging.LogFactory;
|
5 |
45542
|
michele.ar
|
import org.springframework.beans.factory.annotation.Autowired;
|
6 |
45465
|
michele.ar
|
import org.springframework.stereotype.Component;
|
7 |
45542
|
michele.ar
|
import org.springframework.util.LinkedMultiValueMap;
|
8 |
|
|
import org.springframework.web.client.RestTemplate;
|
9 |
45465
|
michele.ar
|
|
10 |
45542
|
michele.ar
|
import eu.dnetlib.conf.DnetGenericApplicationProperties;
|
11 |
45547
|
michele.ar
|
import eu.dnetlib.enabling.annotations.DnetServiceClient;
|
12 |
|
|
import eu.dnetlib.enabling.annotations.DnetServiceType;
|
13 |
45542
|
michele.ar
|
|
14 |
45465
|
michele.ar
|
@Component
|
15 |
45547
|
michele.ar
|
@DnetServiceClient(DnetServiceType.IS_REGISTRY)
|
16 |
45465
|
michele.ar
|
public class ISRegistryClient extends BaseServiceClient {
|
17 |
|
|
|
18 |
|
|
private static final Log log = LogFactory.getLog(ISRegistryClient.class);
|
19 |
|
|
|
20 |
45542
|
michele.ar
|
@Autowired
|
21 |
|
|
private DnetGenericApplicationProperties props;
|
22 |
45465
|
michele.ar
|
|
23 |
|
|
public void registerSchema(final String name, final String xsd) {
|
24 |
45542
|
michele.ar
|
final RestTemplate restTemplate = new RestTemplate();
|
25 |
|
|
final String url = props.getInformationServiceUrl() + "/register/schema/" + name;
|
26 |
|
|
restTemplate.postForObject(url, xsd, Boolean.class);
|
27 |
|
|
}
|
28 |
45465
|
michele.ar
|
|
29 |
45542
|
michele.ar
|
public void deleteSchema(final String name) {
|
30 |
|
|
final RestTemplate restTemplate = new RestTemplate();
|
31 |
|
|
final String url = props.getInformationServiceUrl() + "/register/schema/" + name;
|
32 |
|
|
restTemplate.delete(url);
|
33 |
45465
|
michele.ar
|
}
|
34 |
|
|
|
35 |
45477
|
michele.ar
|
public String register(final String profile) {
|
36 |
45542
|
michele.ar
|
final RestTemplate restTemplate = new RestTemplate();
|
37 |
|
|
final String url = props.getInformationServiceUrl() + "/register/profile";
|
38 |
|
|
return restTemplate.postForObject(url, profile, String.class);
|
39 |
45465
|
michele.ar
|
}
|
40 |
|
|
|
41 |
45542
|
michele.ar
|
public void deleteProfile(final String id) {
|
42 |
|
|
final RestTemplate restTemplate = new RestTemplate();
|
43 |
|
|
final String url = props.getInformationServiceUrl() + "/register/profile/" + id;
|
44 |
|
|
restTemplate.delete(url);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
public void updateProfile(final String id, final String profile) {
|
48 |
|
|
final RestTemplate restTemplate = new RestTemplate();
|
49 |
|
|
final String url = props.getInformationServiceUrl() + "/register/profile/" + id;
|
50 |
|
|
restTemplate.postForObject(url, profile, String.class);
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
public void xupdate(final String query) {
|
54 |
|
|
final RestTemplate restTemplate = new RestTemplate();
|
55 |
|
|
final String url = props.getInformationServiceUrl() + "/lookup/find";
|
56 |
|
|
final LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
57 |
|
|
params.add("q", query);
|
58 |
|
|
restTemplate.postForObject(url, params, String.class);
|
59 |
|
|
}
|
60 |
45465
|
michele.ar
|
}
|