1 19 20 package com.sslexplorer.navigation.actions; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.apache.struts.action.ActionForm; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMapping; 30 31 import com.sslexplorer.core.CoreUtil; 32 import com.sslexplorer.core.DownloadContent; 33 import com.sslexplorer.core.FileDownloadPageInterceptListener; 34 import com.sslexplorer.core.actions.DefaultAction; 35 import com.sslexplorer.security.LogonControllerFactory; 36 import com.sslexplorer.security.SessionInfo; 37 38 45 46 public class CompleteFileDownloadAction extends DefaultAction { 47 final static Log log = LogFactory.getLog(CompleteFileDownloadAction.class); 48 49 52 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 53 throws Exception { 54 String id = request.getParameter("id"); 55 if (id == null) { 56 return mapping.findForward("failed"); 57 } 58 FileDownloadPageInterceptListener l = (FileDownloadPageInterceptListener) CoreUtil.getPageInterceptListenerById(request 59 .getSession(), FileDownloadPageInterceptListener.INTERCEPT_ID); 60 if (l != null) { 61 DownloadContent download = l.getDownload(Integer.parseInt(id)); 62 if(download == null) { 63 log.warn("Expected download " + id + " to be available but it wasn't"); 64 return mapping.findForward("failed"); 65 } 66 else { 67 download.completeDownload(LogonControllerFactory.getInstance().getSessionInfo(request)); 68 l.removeDownload(download.getId()); 69 if(l.size() == 0) { 70 CoreUtil.removePageInterceptListener(request.getSession(), l); 71 } 72 ActionForward fwd = download.getForward(); 73 if(fwd != null) { 74 return fwd; 75 } 76 } 77 } 78 return mapping.findForward("success"); 79 } 80 81 84 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 85 return SessionInfo.ALL_CONTEXTS; 86 } 87 88 } | Popular Tags |