1
|
|
2
|
<%@page import="org.codehaus.jackson.node.ArrayNode"%><%@ page contentType="text/html;charset=UTF-8" language="java"
|
3
|
%><%@page import="eu.etaxonomy.cdm.server.Bootloader"
|
4
|
%><%@page import="java.util.Set"
|
5
|
%><%@page import="java.net.URL"
|
6
|
%><%@page import="org.codehaus.jackson.map.ObjectMapper"
|
7
|
%><%@page import="org.codehaus.jackson.JsonNode"
|
8
|
%><%@page import="org.codehaus.jackson.node.ObjectNode"
|
9
|
%><%@page import="eu.etaxonomy.cdm.server.CdmInstanceProperties"
|
10
|
%><%
|
11
|
//////////////////////////////////////////////////////////////////////////////////
|
12
|
//
|
13
|
// The BootloaderService service exposes the Bootloader.getConfigAndStatus()
|
14
|
// property as webservice. Before beeing serialized to JSON the ConfigAndStatus
|
15
|
// properties will be extended by the basePath of the cdm-remote instances.
|
16
|
// For security the password field will be hidden!
|
17
|
//
|
18
|
//////////////////////////////////////////////////////////////////////////////////
|
19
|
|
20
|
ObjectMapper jsonMapper = new ObjectMapper();
|
21
|
|
22
|
response.setHeader("Content-Type", "application/json;charset=UTF-8");
|
23
|
|
24
|
// the servelt context must use the class loader of the Bootloader class otherwise
|
25
|
// getting the status will not work in mulithreading environments !!!
|
26
|
Bootloader bootloader = Bootloader.getBootloader();
|
27
|
java.util.Set<CdmInstanceProperties> configAndStatus = bootloader.getConfigAndStatus();
|
28
|
if(configAndStatus != null){
|
29
|
int i = 0;
|
30
|
|
31
|
ArrayNode arrayNode = jsonMapper.createArrayNode();
|
32
|
|
33
|
for(CdmInstanceProperties props : configAndStatus){
|
34
|
i++;
|
35
|
String basePath = "/" + props.getDataSourceName();
|
36
|
URL fullURL = new URL(request.getScheme(),
|
37
|
request.getServerName(),
|
38
|
request.getServerPort(),
|
39
|
basePath);
|
40
|
|
41
|
JsonNode jsonNode = jsonMapper.valueToTree(props);
|
42
|
if(jsonNode instanceof ObjectNode){
|
43
|
((ObjectNode)jsonNode).put("basePath", basePath);
|
44
|
((ObjectNode)jsonNode).remove("password");
|
45
|
}
|
46
|
arrayNode.add(jsonNode);
|
47
|
}
|
48
|
out.append(arrayNode.toString());
|
49
|
}
|
50
|
|
51
|
%>
|