source: EDIS/trunk/java/tracking-server-core/src/main/java/gov/va/med/edp/web/controller/LogoutController.java@ 1227

Last change on this file since 1227 was 1227, checked in by George Lilly, 13 years ago

initial load of EDIS 1.0

File size: 2.3 KB
Line 
1package gov.va.med.edp.web.controller;
2
3import org.springframework.web.servlet.mvc.AbstractController;
4import org.springframework.web.servlet.ModelAndView;
5import org.springframework.util.StringUtils;
6import org.springframework.util.Assert;
7import org.springframework.beans.factory.InitializingBean;
8
9import javax.servlet.http.HttpServletRequest;
10import javax.servlet.http.HttpServletResponse;
11import java.util.Set;
12
13/**
14 * Controller for handling logout.
15 * <p/>
16 * Only logic for logout other than invalidating the session is remove the swfID from the list of recognized ones
17 * for this session. If the count drops to 0, or the swfID is not supplied, then invalidate the session.
18 */
19public class LogoutController extends AbstractController implements InitializingBean {
20
21 public static final String DEFAULT_VIEW_NAME = "logout";
22
23 private String viewName = DEFAULT_VIEW_NAME;
24
25 public void afterPropertiesSet() throws Exception {
26 Assert.notNull(viewName, "viewName must not be null");
27 }
28
29 protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
30 String swfID = request.getParameter("swfID");
31 if (!StringUtils.hasLength(swfID)) {
32 request.getSession().invalidate();
33 } else {
34 String ids = (String) request.getSession().getAttribute(SessionConstants.RECOGNIZED_SWF_IDS_KEY);
35 Set idSet = StringUtils.commaDelimitedListToSet(ids);
36 if (idSet.isEmpty()) {
37 request.getSession().invalidate();
38 } else {
39 idSet.remove(swfID);
40 if (idSet.isEmpty()) {
41 request.getSession().setAttribute(SessionConstants.RECOGNIZED_SWF_IDS_KEY, null);
42 request.getSession().invalidate();
43 } else {
44 ids = StringUtils.collectionToCommaDelimitedString(idSet);
45 request.getSession().setAttribute(SessionConstants.RECOGNIZED_SWF_IDS_KEY, ids);
46 }
47 }
48 }
49
50 return new ModelAndView(getViewName());
51 }
52
53 public String getViewName() {
54 return viewName;
55 }
56
57 public void setViewName(String viewName) {
58 this.viewName = viewName;
59 }
60}
Note: See TracBrowser for help on using the repository browser.