1 package com.sslexplorer.vfs.actions; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionForward; 8 import org.apache.struts.action.ActionMapping; 9 10 import com.sslexplorer.core.CoreUtil; 11 import com.sslexplorer.core.actions.AuthenticatedDispatchAction; 12 import com.sslexplorer.security.Constants; 13 import com.sslexplorer.security.SessionInfo; 14 import com.sslexplorer.vfs.UploadDetails; 15 import com.sslexplorer.vfs.forms.ShowUploadForm; 16 17 27 public class ShowUploadAction extends AuthenticatedDispatchAction { 28 29 37 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 38 return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT | SessionInfo.USER_CONSOLE_CONTEXT; 39 } 40 41 44 public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, 45 HttpServletResponse response) throws Exception { 46 return upload(mapping, form, request, response); 47 } 48 49 59 public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 60 throws Exception { 61 Integer i = (Integer ) request.getAttribute(Constants.REQ_ATTR_UPLOAD_DETAILS); 62 if (i == null) { 63 throw new Exception ("No upload id."); 64 } 65 UploadDetails upload = CoreUtil.getUpload(request.getSession(), i.intValue()); 66 if (upload == null) { 67 throw new Exception ("No file upload details configured for upload id " + i + "."); 68 } 69 ((ShowUploadForm) form).initialise(i.intValue(), upload); 70 CoreUtil.addRequiredFieldMessage(this, request); 71 return mapping.findForward("display"); 72 } 73 74 84 public ActionForward uploadDone(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 85 throws Exception { 86 UploadDetails upload = CoreUtil.removeUpload(request.getSession(), ((ShowUploadForm) form).getUploadId()); 87 return upload.getDoneForward(); 88 } 89 90 100 public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 101 throws Exception { 102 UploadDetails upload = CoreUtil.removeUpload(request.getSession(), ((ShowUploadForm) form).getUploadId()); 103 return upload.getCancelForward(); 104 } 105 106 } 107 | Popular Tags |