/
StaticPageController.java
70 lines (60 loc) · 1.89 KB
/
StaticPageController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package org.formflowstartertemplate.app;
import formflow.library.config.FormFlowConfigurationProperties;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.HashMap;
/**
* A controller to render static pages that are not in any flow.
*/
@Controller
public class StaticPageController {
FormFlowConfigurationProperties formFlowConfigurationProperties;
public StaticPageController(FormFlowConfigurationProperties formFlowConfigurationProperties) {
this.formFlowConfigurationProperties = formFlowConfigurationProperties;
}
/**
* Renders the website index page.
*
* @param httpSession The current HTTP session, not null.
* @return the static page template.
*/
@GetMapping("/")
ModelAndView getIndex(HttpSession httpSession) {
httpSession.invalidate(); // For dev, reset session if you visit home
HashMap<String, Object> model = new HashMap<>();
model.put("ubiEnabled", formFlowConfigurationProperties == null ||
!formFlowConfigurationProperties.isFlowDisabled("ubi"));
model.put("docUploadEnabled", formFlowConfigurationProperties == null ||
!formFlowConfigurationProperties.isFlowDisabled("docUpload"));
return new ModelAndView("index", model);
}
/**
* Renders the website faq page.
*
* @return the static page template
*/
@GetMapping("/faq")
String getFaq() {
return "faq";
}
/**
* Renders the website privacy page.
*
* @return the static page template
*/
@GetMapping("/privacy")
String getPrivacy() {
return "privacy";
}
/**
* Renders the page to redirect to when a flow is disabled.
*
* @return the static page template
*/
@GetMapping("/disabledFeature")
String getDisabled() {
return "disabledFeature";
}
}