Java 类org.springframework.web.servlet.support.WebContentGenerator 实例源码

项目:communote-server    文件:ApplicationInitializationStatusController.java   
/**
 * {@inheritDoc}
 */
@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    // only support POST
    if (!request.getMethod().equals(WebContentGenerator.METHOD_POST)) {
        LOG.debug("Ignoring request because it is not a POST");
        return null;
    }

    ObjectNode jsonResponse = JsonHelper.getSharedObjectMapper().createObjectNode();
    StringBuilder message = new StringBuilder();
    InitializationStatus status = CommunoteRuntime.getInstance().getInitializationStatus();
    if (InitializationStatus.Type.SUCCESS.equals(status.getStatus())) {
        jsonResponse.put("status", "OK");
        String url = StringUtils.removeEnd(request.getRequestURL().toString(),
                request.getServletPath());
        message.append(MessageHelper.getText(request, "initialization.status.success",
                new Object[] { url }));
    } else if (InitializationStatus.Type.FAILURE.equals(status.getStatus())) {
        jsonResponse.put("status", "ERROR");
        message.append(MessageHelper.getText(request, "initialization.status.failed"));
    } else {
        jsonResponse.put("status", "PROCESSING");
    }

    jsonResponse.put("message", message.toString());

    JsonHelper.writeJsonTree(response.getWriter(), jsonResponse);
    return null;
}
项目:spring4-understanding    文件:WebContentInterceptorTests.java   
@Before
public void setUp() throws Exception {
    request = new MockHttpServletRequest();
    request.setMethod(WebContentGenerator.METHOD_GET);
    response = new MockHttpServletResponse();
}
项目:class-guard    文件:WebContentInterceptorTests.java   
@Before
public void setUp() throws Exception {
    request = new MockHttpServletRequest();
    request.setMethod(WebContentGenerator.METHOD_GET);
    response = new MockHttpServletResponse();
}