1 25 26 package com.j2biz.blogunity.web.actions; 27 28 import javax.servlet.http.HttpServletRequest ; 29 import javax.servlet.http.HttpServletResponse ; 30 import javax.servlet.http.HttpSession ; 31 32 import org.apache.commons.lang.StringUtils; 33 import org.apache.commons.logging.Log; 34 import org.apache.commons.logging.LogFactory; 35 36 import com.j2biz.blogunity.IConstants; 37 import com.j2biz.blogunity.exception.BlogunityException; 38 import com.j2biz.blogunity.web.IActionResult; 39 import com.j2biz.blogunity.web.NavigationStack; 40 41 48 public abstract class AbstractAction { 49 52 private static final Log log = LogFactory.getLog(AbstractAction.class); 53 54 protected NavigationStack navigationStack; 55 56 protected String currentActionPath; 57 58 public void init(HttpServletRequest request, HttpServletResponse response, String currentActionPath) 59 throws BlogunityException { 60 if (log.isDebugEnabled()) { 61 log.debug("Trying to get navigation-navigationStack for the current user."); 62 } 63 64 String query = request.getQueryString(); 65 if (StringUtils.isNotEmpty(query)){ 66 currentActionPath += "?" + query; 67 } 68 69 this.currentActionPath = currentActionPath; 70 71 HttpSession session = request.getSession(); 72 navigationStack = (NavigationStack) session.getAttribute(IConstants.Session.NAVIGATION_STACK); 73 74 if (navigationStack == null) { 75 if (log.isDebugEnabled()) { 76 log.debug("Navigation-navigationStack not found -> create new one."); 77 } 78 navigationStack = new NavigationStack(); 79 session.setAttribute(IConstants.Session.NAVIGATION_STACK, navigationStack); 80 } 81 82 83 if (log.isDebugEnabled()) { 84 log.debug("Setting not-cacheable response..."); 85 } 86 87 88 } 89 90 96 public abstract IActionResult execute(HttpServletRequest request, HttpServletResponse response) 97 throws BlogunityException; 98 99 } | Popular Tags |