Project

General

Profile

1
package eu.dnetlib.clients;
2

    
3
import org.apache.commons.logging.Log;
4
import org.apache.commons.logging.LogFactory;
5
import org.springframework.beans.factory.annotation.Autowired;
6
import org.springframework.stereotype.Component;
7
import org.springframework.util.LinkedMultiValueMap;
8
import org.springframework.web.client.RestTemplate;
9

    
10
import eu.dnetlib.conf.DnetGenericApplicationProperties;
11
import eu.dnetlib.enabling.annotations.DnetServiceClient;
12
import eu.dnetlib.enabling.annotations.DnetServiceType;
13

    
14
@Component
15
@DnetServiceClient(DnetServiceType.IS_REGISTRY)
16
public class ISRegistryClient extends BaseServiceClient {
17

    
18
	private static final Log log = LogFactory.getLog(ISRegistryClient.class);
19

    
20
	@Autowired
21
	private DnetGenericApplicationProperties props;
22

    
23
	public void registerSchema(final String name, final String xsd) {
24
		final RestTemplate restTemplate = new RestTemplate();
25
		final String url = props.getInformationServiceUrl() + "/register/schema/" + name;
26
		restTemplate.postForObject(url, xsd, Boolean.class);
27
	}
28

    
29
	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
	}
34

    
35
	public String register(final String profile) {
36
		final RestTemplate restTemplate = new RestTemplate();
37
		final String url = props.getInformationServiceUrl() + "/register/profile";
38
		return restTemplate.postForObject(url, profile, String.class);
39
	}
40

    
41
	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
}
(3-3/3)