1 19 20 package com.sslexplorer.properties.attributes.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 import org.apache.struts.util.MessageResources; 31 32 import com.sslexplorer.boot.PropertyClassManager; 33 import com.sslexplorer.core.CoreUtil; 34 import com.sslexplorer.core.actions.AuthenticatedDispatchAction; 35 import com.sslexplorer.properties.attributes.AttributeDefinition; 36 import com.sslexplorer.properties.attributes.forms.AttributeDefinitionInformationForm; 37 import com.sslexplorer.security.Constants; 38 import com.sslexplorer.security.SessionInfo; 39 40 45 public class AttributeDefinitionInformationAction extends AuthenticatedDispatchAction { 46 47 final static Log log = LogFactory.getLog(AttributeDefinitionInformationAction.class); 48 49 57 public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, 58 HttpServletResponse response) throws Exception { 59 try { 60 String name = request.getParameter("name"); 61 String propertyClass = request.getParameter("propertyClass"); 62 AttributeDefinition def = (AttributeDefinition)PropertyClassManager.getInstance().getPropertyClass(propertyClass).getDefinition(name); 63 request.setAttribute(Constants.REQ_ATTR_INFO_RESOURCE, def); 64 return attributeInformation(mapping, form, request, response); 65 } catch (Exception e) { 66 log.error("Failed to get attribute information. ", e); 67 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); 68 return null; 69 } 70 } 71 72 82 public ActionForward attributeInformation(ActionMapping mapping, ActionForm form, HttpServletRequest request, 83 HttpServletResponse response) throws Exception { 84 AttributeDefinition def = (AttributeDefinition) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE); 85 MessageResources mr = null; 86 if(def.getMessageResourcesKey() != null) { 87 mr = CoreUtil.getMessageResources(request.getSession(), def.getMessageResourcesKey()); 88 } 89 ((AttributeDefinitionInformationForm) form).initialise(mr, def); 90 return mapping.findForward("display"); 91 } 92 93 101 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 102 return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT; 103 } 104 } | Popular Tags |