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.struts.action.ActionForm; 26 import org.apache.struts.action.ActionForward; 27 import org.apache.struts.action.ActionMapping; 28 29 import com.sslexplorer.boot.PropertyClass; 30 import com.sslexplorer.boot.PropertyClassManager; 31 import com.sslexplorer.boot.PropertyDefinition; 32 import com.sslexplorer.boot.Util; 33 import com.sslexplorer.core.CoreMenuTree; 34 import com.sslexplorer.core.actions.DefaultAction; 35 import com.sslexplorer.navigation.NavigationManager; 36 import com.sslexplorer.navigation.forms.HelpForm; 37 import com.sslexplorer.security.Constants; 38 import com.sslexplorer.security.LogonControllerFactory; 39 import com.sslexplorer.security.SessionInfo; 40 41 46 47 public class HelpAction extends DefaultAction { 48 49 52 public HelpAction() { 53 super(); 54 } 55 56 64 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, 65 HttpServletResponse response) throws Exception { 66 String source = request.getParameter("source"); 67 HelpForm helpForm = (HelpForm)form; 68 if(source == null) { 69 throw new Exception ("Help action requires a source parameter."); 70 } 71 if(source.equalsIgnoreCase("property")) { 72 String name = request.getParameter("name"); 73 if(name == null) { 74 throw new Exception ("Help for property source requires a name parameter."); 75 } 76 String propertyClassName = request.getParameter("propertyClass"); 77 if(propertyClassName == null) { 78 throw new Exception ("Help for property source requires a propertyClass parameter."); 79 } 80 PropertyClass propertyClass = PropertyClassManager.getInstance().getPropertyClass(propertyClassName); 81 if(propertyClass == null) { 82 throw new Exception ("Invalid property class."); 83 } 84 PropertyDefinition def = propertyClass.getDefinition(name); 85 if(def == null) { 86 throw new Exception ("No property definition with name of " + name); 87 } 88 request.setAttribute(Constants.REQ_ATTR_PROPERTY_DEFINITION, def); 89 return mapping.findForward("property"); 90 } 91 else if(source.equalsIgnoreCase("help")) { 92 SessionInfo info = LogonControllerFactory.getInstance().getSessionInfo(request); 94 helpForm.setMenu(NavigationManager.getMenuTree(CoreMenuTree.MENU_ITEM_MENU_TREE).rebuildMenus(SessionInfo.HELP_CONTEXT, 95 info, 96 request, 97 Util.getOriginalRequest(request))); 98 return mapping.findForward("help"); 99 } 100 throw new Exception ("No source of type " + source); 101 102 } 103 104 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 105 return SessionInfo.HELP_CONTEXT; 106 } 107 108 } | Popular Tags |