Project

General

Profile

1
package eu.dnetlib.data.objectstore;
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
// TODO: Auto-generated Javadoc
14

    
15
/**
16
 * The Class ObjectStoreProfileCreator is responsible of creating profile of the ObjectStore
17
 */
18
public class ObjectStoreProfileCreator {
19

    
20
	private static final String ENDPOINT_TEMPLATE = "http://%s:%s/%s/services/objectStore";
21
	/**
22
	 * service locator.
23
	 */
24
	@Autowired
25
	private UniqueServiceLocator serviceLocator;
26
	/**
27
	 * objectstore ds template.
28
	 */
29
	private StringTemplate objectstoreDsTemplate;
30
	private String hostname;
31
	private String port;
32
	private String context;
33
	/**
34
	 * service endpoint.
35
	 */
36
	private Endpoint endpoint;
37

    
38
	/**
39
	 * endpoint builder.
40
	 */
41
	private EndpointReferenceBuilder<Endpoint> eprBuilder;
42

    
43
	/**
44
	 * Register profile.
45
	 *
46
	 * @param interpretation the interpretation
47
	 * @return the string
48
	 * @throws ISRegistryException the IS registry exception
49
	 */
50
	public String registerProfile(final String interpretation)
51
			throws ISRegistryException {
52
		// XXX: mini hack
53
		StringTemplate template = new StringTemplate(objectstoreDsTemplate.getTemplate());
54

    
55
		//template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
56
		template.setAttribute("serviceUri", String.format(ENDPOINT_TEMPLATE, hostname, port, context));
57
		template.setAttribute("interpretation", interpretation);
58

    
59
		return serviceLocator.getService(ISRegistryService.class, true).registerProfile(template.toString());
60
	}
61

    
62
	/**
63
	 * Gets the endpoint.
64
	 *
65
	 * @return the endpoint
66
	 */
67
	public Endpoint getEndpoint() {
68
		return endpoint;
69
	}
70

    
71
	/**
72
	 * Sets the endpoint.
73
	 *
74
	 * @param endpoint the new endpoint
75
	 */
76

    
77
	public void setEndpoint(final Endpoint endpoint) {
78
		this.endpoint = endpoint;
79
	}
80

    
81
	/**
82
	 * Gets the epr builder.
83
	 *
84
	 * @return the epr builder
85
	 */
86
	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
87
		return eprBuilder;
88
	}
89

    
90
	/**
91
	 * Sets the epr builder.
92
	 *
93
	 * @param eprBuilder the new epr builder
94
	 */
95
	@Required
96
	public void setEprBuilder(final EndpointReferenceBuilder<Endpoint> eprBuilder) {
97
		this.eprBuilder = eprBuilder;
98
	}
99

    
100
	/**
101
	 * Gets the objectstore ds template.
102
	 *
103
	 * @return the objectstore ds template
104
	 */
105
	public StringTemplate getObjectstoreDsTemplate() {
106
		return objectstoreDsTemplate;
107
	}
108

    
109
	/**
110
	 * Sets the objectstore ds template.
111
	 *
112
	 * @param objectstoreDsTemplate the new objectstore ds template
113
	 */
114
	@Required
115
	public void setObjectstoreDsTemplate(final StringTemplate objectstoreDsTemplate) {
116
		this.objectstoreDsTemplate = objectstoreDsTemplate;
117
	}
118

    
119
	public UniqueServiceLocator getServiceLocator() {
120
		return serviceLocator;
121
	}
122

    
123
	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
124
		this.serviceLocator = serviceLocator;
125
	}
126

    
127
	public String getHostname() {
128
		return hostname;
129
	}
130

    
131
	@Required
132
	public void setHostname(final String hostname) {
133
		this.hostname = hostname;
134
	}
135

    
136
	public String getPort() {
137
		return port;
138
	}
139

    
140
	@Required
141
	public void setPort(final String port) {
142
		this.port = port;
143
	}
144

    
145
	public String getContext() {
146
		return context;
147
	}
148

    
149
	@Required
150
	public void setContext(final String context) {
151
		this.context = context;
152
	}
153

    
154
}
(20-20/21)