Search in sources :

Example 6 with HttpParameterHandler

use of com.publiccms.common.handler.HttpParameterHandler in project PublicCMS-preview by sanluan.

the class LotteryController method lottery.

/**
 * @param callback
 * @param request
 * @param session
 * @param response
 */
@RequestMapping("lottery")
public void lottery(String callback, HttpServletRequest request, HttpSession session, HttpServletResponse response) {
    try {
        HttpParameterHandler handler = new HttpParameterHandler(mappingJackson2HttpMessageConverter, jsonMediaType, request, callback, response);
        SysUser user = getUserFromSession(session);
        if (null != user) {
            lotteryDirective.execute(handler, null, user);
        }
        handler.render();
    } catch (Exception e) {
    }
}
Also used : SysUser(com.publiccms.entities.sys.SysUser) HttpParameterHandler(com.publiccms.common.handler.HttpParameterHandler) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with HttpParameterHandler

use of com.publiccms.common.handler.HttpParameterHandler in project PublicCMS-preview by sanluan.

the class AbstractTaskDirective method execute.

@Override
public void execute(HttpMessageConverter<Object> httpMessageConverter, MediaType mediaType, HttpServletRequest request, String callback, HttpServletResponse response) throws IOException, Exception {
    HttpParameterHandler handler = new HttpParameterHandler(httpMessageConverter, mediaType, request, callback, response);
    SysApp app = null;
    if (null == (app = getApp(handler))) {
        handler.put("error", ApiController.NEED_APP_TOKEN).render();
    } else if (CommonUtils.empty(app.getAuthorizedApis()) || !ArrayUtils.contains(StringUtils.split(app.getAuthorizedApis(), COMMA_DELIMITED), getName())) {
        handler.put("error", ApiController.UN_AUTHORIZED).render();
    } else {
        execute(handler);
        handler.render();
    }
}
Also used : SysApp(com.publiccms.entities.sys.SysApp) HttpParameterHandler(com.publiccms.common.handler.HttpParameterHandler)

Aggregations

HttpParameterHandler (com.publiccms.common.handler.HttpParameterHandler)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 SysUser (com.publiccms.entities.sys.SysUser)3 SysApp (com.publiccms.entities.sys.SysApp)2 AbstractAppDirective (com.publiccms.common.base.AbstractAppDirective)1 HttpDirective (com.publiccms.common.directive.HttpDirective)1