Search in sources :

Example 6 with WebAppConfigurationException

use of org.apache.ofbiz.webapp.control.WebAppConfigurationException in project ofbiz-framework by apache.

the class SurveyEvents method createSurveyResponseAndRestoreParameters.

public static String createSurveyResponseAndRestoreParameters(HttpServletRequest request, HttpServletResponse response) {
    // Call createSurveyResponse as an event, easier to setup and ensures parameter security
    ConfigXMLReader.Event createSurveyResponseEvent = new ConfigXMLReader.Event("service", null, "createSurveyResponse", true);
    RequestHandler rh = (RequestHandler) request.getAttribute("_REQUEST_HANDLER_");
    ConfigXMLReader.ControllerConfig controllerConfig = rh.getControllerConfig();
    String requestUri = (String) request.getAttribute("thisRequestUri");
    RequestMap requestMap = null;
    try {
        requestMap = controllerConfig.getRequestMapMap().get(requestUri);
    } catch (WebAppConfigurationException e) {
        Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module);
    }
    String eventResponse = null;
    try {
        eventResponse = rh.runEvent(request, response, createSurveyResponseEvent, requestMap, null);
    } catch (EventHandlerException e) {
        Debug.logError(e, module);
        return "error";
    }
    if (!"success".equals(eventResponse)) {
        return eventResponse;
    }
    // Check for an incoming _ORIG_PARAM_MAP_ID_, if present get the session stored parameter map and insert it's entries as request attributes
    Map<String, Object> combinedMap = UtilHttp.getCombinedMap(request);
    if (combinedMap.containsKey("_ORIG_PARAM_MAP_ID_")) {
        String origParamMapId = (String) combinedMap.get("_ORIG_PARAM_MAP_ID_");
        UtilHttp.restoreStashedParameterMap(request, origParamMapId);
    }
    return "success";
}
Also used : ConfigXMLReader(org.apache.ofbiz.webapp.control.ConfigXMLReader) RequestHandler(org.apache.ofbiz.webapp.control.RequestHandler) EventHandlerException(org.apache.ofbiz.webapp.event.EventHandlerException) RequestMap(org.apache.ofbiz.webapp.control.ConfigXMLReader.RequestMap) WebAppConfigurationException(org.apache.ofbiz.webapp.control.WebAppConfigurationException)

Aggregations

WebAppConfigurationException (org.apache.ofbiz.webapp.control.WebAppConfigurationException)6 Locale (java.util.Locale)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 GenericValue (org.apache.ofbiz.entity.GenericValue)3 LocalDispatcher (org.apache.ofbiz.service.LocalDispatcher)3 ConfigXMLReader (org.apache.ofbiz.webapp.control.ConfigXMLReader)3 Environment (freemarker.core.Environment)2 BeanModel (freemarker.ext.beans.BeanModel)2 TemplateModelException (freemarker.template.TemplateModelException)2 IOException (java.io.IOException)2 Writer (java.io.Writer)2 Delegator (org.apache.ofbiz.entity.Delegator)2 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)2 CategoryContentWrapper (org.apache.ofbiz.product.category.CategoryContentWrapper)2 ProductContentWrapper (org.apache.ofbiz.product.product.ProductContentWrapper)2 OfbizUrlBuilder (org.apache.ofbiz.webapp.OfbizUrlBuilder)2 RequestMap (org.apache.ofbiz.webapp.control.ConfigXMLReader.RequestMap)2 RequestHandler (org.apache.ofbiz.webapp.control.RequestHandler)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1