1
2
3
4
5
6
7
8
9
10
11 package psiprobe.controllers.deploy;
12
13 import jakarta.servlet.http.HttpServletRequest;
14 import jakarta.servlet.http.HttpServletResponse;
15
16 import org.springframework.beans.factory.annotation.Value;
17 import org.springframework.security.core.Authentication;
18 import org.springframework.security.core.context.SecurityContextHolder;
19 import org.springframework.stereotype.Controller;
20 import org.springframework.web.bind.ServletRequestUtils;
21 import org.springframework.web.bind.annotation.RequestMapping;
22 import org.springframework.web.servlet.ModelAndView;
23 import org.springframework.web.servlet.view.InternalResourceView;
24
25 import psiprobe.controllers.AbstractTomcatContainerController;
26
27
28
29
30 @Controller
31 public class DeployContextController extends AbstractTomcatContainerController {
32
33 @RequestMapping(path = "/adm/deploycontext.htm")
34 @Override
35 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
36 throws Exception {
37 return super.handleRequest(request, response);
38 }
39
40 @Override
41 public ModelAndView handleRequestInternal(HttpServletRequest request,
42 HttpServletResponse response) throws Exception {
43
44 String contextName = ServletRequestUtils.getStringParameter(request, "context");
45
46 if (contextName != null) {
47 try {
48 if (getContainerWrapper().getTomcatContainer().installContext(contextName)) {
49 request.setAttribute("successMessage", getMessageSourceAccessor()
50 .getMessage("probe.src.deploy.context.success", new Object[] {contextName}));
51
52 Authentication auth = SecurityContextHolder.getContext().getAuthentication();
53
54 String name = auth.getName();
55 logger.info(getMessageSourceAccessor().getMessage("probe.src.log.deploycontext"), name,
56 contextName);
57 } else {
58 request.setAttribute("errorMessage", getMessageSourceAccessor()
59 .getMessage("probe.src.deploy.context.failure", new Object[] {contextName}));
60 }
61 } catch (Exception e) {
62 request.setAttribute("errorMessage", e.getMessage());
63 logger.trace("", e);
64 }
65 }
66
67 return new ModelAndView(new InternalResourceView(getViewName()));
68 }
69
70 @Value("/adm/deploy.htm")
71 @Override
72 public void setViewName(String viewName) {
73 super.setViewName(viewName);
74 }
75
76 }