Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-server / src / main / webapp / manage / BootloaderService.jsp @ 929a8c09

History | View | Annotate | Download (2.17 KB)

1
<%@page import="org.codehaus.jackson.node.ArrayNode"
2
%><%@ page contentType="application/json;charset=UTF-8" language="java"
3
%><%@page import="eu.etaxonomy.cdm.server.Bootloader"
4
%><%@page import="eu.etaxonomy.cdm.server.instance.CdmInstance"
5
%><%@page import="java.util.Set"
6
%><%@page import="java.net.URL"
7
%><%@page import="org.codehaus.jackson.map.ObjectMapper"
8
%><%@page import="org.codehaus.jackson.JsonNode"
9
%><%@page import="org.codehaus.jackson.node.ObjectNode"
10
%><%@page import="eu.etaxonomy.cdm.server.instance.Configuration"
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 multihreading environments !!!
26
  Bootloader bootloader = Bootloader.getBootloader();
27
  java.util.List<CdmInstance> instances = bootloader.getCdmInstances();
28
  if(instances != null){
29
   int i = 0;
30

    
31
   ArrayNode arrayNode = jsonMapper.createArrayNode();
32

    
33
   for(CdmInstance instance: instances){
34
    i++;
35
    Configuration props = instance.getConfiguration();
36
    String basePath = request.getContextPath() + "/" + props.getInstanceName();
37
      URL fullURL = new URL(request.getScheme(),
38
                  request.getServerName(),
39
                  request.getServerPort(),
40
                  basePath);
41

    
42
      JsonNode jsonNode = jsonMapper.valueToTree(props);
43
      if(jsonNode instanceof ObjectNode){
44
           ((ObjectNode)jsonNode).put("basePath", basePath);
45
           ((ObjectNode)jsonNode).put("fullUrl", fullURL.toString());
46
           ((ObjectNode)jsonNode).remove("password");
47
      }
48
      arrayNode.add(jsonNode);
49
   }
50
   out.append(arrayNode.toString());
51
  }%>
Add picture from clipboard (Maximum size: 40 MB)