Project

General

Profile

1
package eu.dnetlib.data.mdstore.modular;
2

    
3
import javax.xml.ws.Endpoint;
4

    
5
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
6
import eu.dnetlib.rmi.enabling.ISRegistryException;
7
import eu.dnetlib.rmi.enabling.ISRegistryService;
8
import eu.dnetlib.soap.EndpointReferenceBuilder;
9
import org.antlr.stringtemplate.StringTemplate;
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.beans.factory.annotation.Required;
12

    
13
public class MDStoreProfileCreator {
14

    
15
	private static final String ENDPOINT_TEMPLATE = "http://%s:%s/%s/services/mdStore";
16
	/**
17
	 * service locator.
18
	 */
19
	@Autowired
20
	private UniqueServiceLocator serviceLocator;
21
	/**
22
	 * mdstore ds template.
23
	 */
24
	private StringTemplate mdstoreDsTemplate;
25
	/**
26
	 * service endpoint.
27
	 */
28
	private Endpoint endpoint;
29
	private String hostname;
30
	private String port;
31
	private String context;
32
	/**
33
	 * endpoint builder.
34
	 */
35
	private EndpointReferenceBuilder<Endpoint> eprBuilder;
36

    
37
	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
38
		// XXX: mini hack
39
		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
40
		//template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
41
		template.setAttribute("serviceUri", String.format(ENDPOINT_TEMPLATE, hostname, port, context));
42
		template.setAttribute("format", format);
43
		template.setAttribute("interpretation", interpretation);
44
		template.setAttribute("layout", layout);
45

    
46
		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
47
	}
48

    
49
	public StringTemplate getMdstoreDsTemplate() {
50
		return mdstoreDsTemplate;
51
	}
52

    
53
	@Required
54
	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
55
		this.mdstoreDsTemplate = mdstoreDsTemplate;
56
	}
57

    
58
	public Endpoint getEndpoint() {
59
		return endpoint;
60
	}
61

    
62

    
63
	public void setEndpoint(Endpoint endpoint) {
64
		this.endpoint = endpoint;
65
	}
66

    
67
	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
68
		return eprBuilder;
69
	}
70

    
71
	@Required
72
	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
73
		this.eprBuilder = eprBuilder;
74
	}
75

    
76
	public UniqueServiceLocator getServiceLocator() {
77
		return serviceLocator;
78
	}
79

    
80
	@Required
81
	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
82
		this.serviceLocator = serviceLocator;
83
	}
84

    
85
	public String getHostname() {
86
		return hostname;
87
	}
88

    
89
	@Required
90
	public void setHostname(final String hostname) {
91
		this.hostname = hostname;
92
	}
93

    
94
	public String getPort() {
95
		return port;
96
	}
97

    
98
	@Required
99
	public void setPort(final String port) {
100
		this.port = port;
101
	}
102

    
103
	public String getContext() {
104
		return context;
105
	}
106

    
107
	@Required
108
	public void setContext(final String context) {
109
		this.context = context;
110
	}
111
}
(4-4/10)