1 19 20 package com.sslexplorer.extensions.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.actions.AuthenticatedDispatchAction; 32 import com.sslexplorer.extensions.ExtensionBundle; 33 import com.sslexplorer.extensions.forms.ExtensionBundleInformationForm; 34 import com.sslexplorer.extensions.store.ExtensionStore; 35 import com.sslexplorer.security.Constants; 36 import com.sslexplorer.security.SessionInfo; 37 38 43 public class ExtensionBundleInformationAction extends AuthenticatedDispatchAction { 44 45 final static Log log = LogFactory.getLog(ExtensionBundleInformationAction.class); 46 47 50 public ExtensionBundleInformationAction() { 51 super(); 52 } 53 54 62 public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, 63 HttpServletResponse response) throws Exception { 64 try { 65 String bundleId = request.getParameter("bundleId"); 66 ExtensionBundle bundle; 67 try { 68 bundle = ExtensionStore.getInstance().getExtensionBundle(bundleId); 69 } 70 catch(Exception e) { 71 bundle = ExtensionStore.getInstance().getDownloadableExtensionStoreDescriptor(true).getApplicationBundle(bundleId); 72 } 73 request.setAttribute(Constants.REQ_ATTR_INFO_RESOURCE, bundle); 74 return extensionBundleInformation(mapping, form, request, response); 75 } catch (Exception e) { 76 log.error("Failed to get extension information. ", e); 77 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); 78 return null; 79 } 80 } 81 82 92 public ActionForward extensionBundleInformation(ActionMapping mapping, ActionForm form, HttpServletRequest request, 93 HttpServletResponse response) throws Exception { 94 ((ExtensionBundleInformationForm) form).initialise((ExtensionBundle) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE)); 95 return mapping.findForward("display"); 96 } 97 98 106 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 107 return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT; 108 } 109 } | Popular Tags |