Search in sources :

Example 1 with HttpDirective

use of com.publiccms.common.directive.HttpDirective in project PublicCMS-preview by sanluan.

the class DirectiveController method directive.

/**
 * 接口指令统一分发
 *
 * @param action
 * @param callback
 * @param request
 * @param response
 */
@RequestMapping("directive/{action}")
public void directive(@PathVariable String action, String callback, HttpServletRequest request, HttpServletResponse response) {
    try {
        HttpDirective directive = actionMap.get(action);
        if (null != directive) {
            request.setAttribute(AbstractFreemarkerView.CONTEXT_SITE, getSite(request));
            directive.execute(mappingJackson2HttpMessageConverter, jsonMediaType, request, callback, response);
        } else {
            HttpParameterHandler handler = new HttpParameterHandler(mappingJackson2HttpMessageConverter, jsonMediaType, request, callback, response);
            handler.put(ERROR, ApiController.INTERFACE_NOT_FOUND).render();
        }
    } catch (Exception e) {
        HttpParameterHandler handler = new HttpParameterHandler(mappingJackson2HttpMessageConverter, jsonMediaType, request, callback, response);
        try {
            handler.put(ERROR, ApiController.EXCEPTION).render();
        } catch (Exception renderException) {
            log.error(renderException.getMessage());
        }
        log.error(e.getMessage(), e);
    }
}
Also used : HttpDirective(com.publiccms.common.directive.HttpDirective) HttpParameterHandler(com.publiccms.common.handler.HttpParameterHandler) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

HttpDirective (com.publiccms.common.directive.HttpDirective)1 HttpParameterHandler (com.publiccms.common.handler.HttpParameterHandler)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1