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);
}
}
Aggregations