Java Code Examples for org.kohsuke.stapler.StaplerResponse#getWriter()

The following examples show how to use org.kohsuke.stapler.StaplerResponse#getWriter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceException.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Override
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
    rsp.setStatus(status);
    rsp.setContentType("application/json");
    PrintWriter w = rsp.getWriter();
    w.write(toJson());
    w.close();
}
 
Example 2
Source File: LogResource.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private Writer createWriter(StaplerRequest req, StaplerResponse rsp, long size) throws IOException {
    // when sending big text, try compression. don't bother if it's small
    if(size >4096)
        return rsp.getCompressedWriter(req);
    else
        return rsp.getWriter();
}
 
Example 3
Source File: GogsWebHook.java    From gogs-webhook-plugin with MIT License 5 votes vote down vote up
/**
 * Exit the WebHook
 *
 * @param result GogsResults
 */
private void exitWebHook(GogsResults result, StaplerResponse resp) throws IOException {
    if (result.getStatus() != 200) {
        LOGGER.warning(result.getMessage());
    }
    //noinspection MismatchedQueryAndUpdateOfCollection
    JSONObject json = new JSONObject();
    json.element("result", result.getStatus() == 200 ? "OK" : "ERROR");
    json.element("message", result.getMessage());
    resp.setStatus(result.getStatus());
    resp.addHeader("Content-Type", "application/json");
    PrintWriter printer = resp.getWriter();
    printer.print(json.toString());
}
 
Example 4
Source File: StatusJsonAction.java    From gitlab-plugin with GNU General Public License v2.0 5 votes vote down vote up
private void writeBody(StaplerResponse response, JSONObject body) throws IOException {
    response.setContentType("application/json");
    PrintWriter writer = response.getWriter();
    writer.write(body.toString());
    writer.flush();
    writer.close();
}
 
Example 5
Source File: XMLDataWriter.java    From blueocean-plugin with MIT License 4 votes vote down vote up
XMLDataWriter(Object bean, StaplerResponse rsp, ExportConfig config) throws IOException {
    this(bean,rsp.getWriter(),config);
}