当前位置: 首页>>代码示例>>Java>>正文


Java StaplerResponse.setContentType方法代码示例

本文整理汇总了Java中org.kohsuke.stapler.StaplerResponse.setContentType方法的典型用法代码示例。如果您正苦于以下问题:Java StaplerResponse.setContentType方法的具体用法?Java StaplerResponse.setContentType怎么用?Java StaplerResponse.setContentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kohsuke.stapler.StaplerResponse的用法示例。


在下文中一共展示了StaplerResponse.setContentType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: plotGraphMap

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
 * Generates and writes the plotpipeline's clickable map to the response output
 * stream.
 *
 * @param req
 *            the incoming request
 * @param rsp
 *            the response stream
 * @throws IOException
 */
public void plotGraphMap(StaplerRequest req, StaplerResponse rsp)
        throws IOException {
    if ( ChartUtil.awtProblemCause != null) {
        // not available. send out error message
        rsp.sendRedirect2(req.getContextPath() + "/images/headless.png");
        return;
    }
    setWidth(req);
    setHeight(req);
    setNumBuilds(req);
    setRightBuildNum(req);
    setHasLegend(req);
    setTitle(req);
    setStyle(req);
    setUseDescr(req);
    generatePlot(false);
    ChartRenderingInfo info = new ChartRenderingInfo();
    plot.createBufferedImage(getWidth(), getHeight(), info);
    rsp.setContentType("text/plain;charset=UTF-8");
    rsp.getWriter().println(
            ChartUtilities.getImageMap(getCsvFileName(), info));
}
 
开发者ID:MarkusDNC,项目名称:plot-plugin,代码行数:33,代码来源:Plot.java

示例2: doIndex

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
 * Used by Jenkins Stapler service when get request on URL jenkins_host/getUrlName()
 *
 * @param request - request
 * @param response - response
 * @throws IOException
 */
@SuppressWarnings("unused")
public void doIndex(StaplerRequest request, StaplerResponse response) throws IOException {
    final float coverage = Float.parseFloat(request.getParameter("coverage"));
    final float masterCoverage = Float.parseFloat(request.getParameter("masterCoverage"));

    response.setContentType("image/svg+xml");

    String svg = IOUtils.toString(this.getClass().getResourceAsStream(
            "/com/github/terma/jenkins/githubprcoveragestatus/Icon/icon.svg"));

    final Message message = new Message(coverage, masterCoverage);
    svg = StringUtils.replace(svg, "{{ message }}", message.forIcon());

    final int coveragePercent = Percent.of(coverage);
    String color;
    if (coveragePercent < Configuration.getYellowThreshold()) color = "#b94947"; // red
    else if (coveragePercent < Configuration.getGreenThreshold()) color = "#F89406"; // yellow
    else color = "#97CA00"; // green
    svg = StringUtils.replace(svg, "{{ color }}", color);

    response.getWriter().write(svg);
}
 
开发者ID:terma,项目名称:github-pr-coverage-status,代码行数:30,代码来源:CoverageStatusIconAction.java

示例3: doDeployText

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
 * Sends out the raw console output.
 */
public void doDeployText(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("text/plain;charset=UTF-8");
    // Prevent jelly from flushing stream so Content-Length header can be added afterwards
    FlushProofOutputStream out = new FlushProofOutputStream(rsp.getCompressedOutputStream(req));
    try {
        getLogText().writeLogTo(0, out);
    } catch (IOException e) {
        // see comment in writeLogTo() method
        InputStream input = getLogInputStream();
        try {
            IOUtils.copy(input, out);
        } finally {
            IOUtils.closeQuietly(input);
        }
    }
    out.close();
}
 
开发者ID:jenkinsci,项目名称:deployer-framework-plugin,代码行数:21,代码来源:DeployNowRunAction.java

示例4: doLogTail

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doLogTail(final StaplerRequest req, final StaplerResponse rsp) throws IOException, ServletException {
    rsp.setContentType("text/plain;charset=UTF-8");
    final Joiner joiner = Joiner.on("\n");
    final PlainTextConsoleOutputStream out = new PlainTextConsoleOutputStream(new FlushProofOutputStream(rsp.getCompressedOutputStream(req)));
    try {
        out.write(joiner.join(getLog(5000)).getBytes());
    } catch (final IOException e) {
        // see comment in writeLogTo() method
        final InputStream input = getLogInputStream();
        try {
            IOUtils.copy(input, out);
        } finally {
            IOUtils.closeQuietly(input);
        }
    } finally {
        IOUtils.closeQuietly(out);
    }
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:19,代码来源:DbBackedBuild.java

示例5: doSubmit

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doSubmit(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException {
    // '$class' in form data tells Stapler which Fruit subclass to use,
    // older versions of Jenkins/Stapler used 'stapler-class'
    Fruit fruit = req.bindJSON(Fruit.class, req.getSubmittedForm().getJSONObject("fruit"));
    rsp.setContentType("text/plain");
    new XStream2().toXML(fruit, rsp.getWriter());
}
 
开发者ID:10000TB,项目名称:Jenkins-Plugin-Examples,代码行数:8,代码来源:DropdownList.java

示例6: doPdfReport

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doPdfReport(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("application/pdf");
    ServletOutputStream outputStream = rsp.getOutputStream();
    File buildDirectory = owner.getRootDir();
    File a = new File(buildDirectory, "/checkmarx/" + PDF_REPORT_NAME);

    IOUtils.copy(a, outputStream);

    outputStream.flush();
    outputStream.close();
}
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:12,代码来源:CxScanResult.java

示例7: doOsaPdfReport

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doOsaPdfReport(StaplerRequest req, StaplerResponse rsp) throws IOException {

        rsp.setContentType("application/pdf");
        ServletOutputStream outputStream = rsp.getOutputStream();
        File buildDirectory = owner.getRootDir();
        File a = new File(buildDirectory, "/checkmarx/" + OSA_PDF_REPORT_NAME);

        IOUtils.copy(a, outputStream);

        outputStream.flush();
        outputStream.close();
    }
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:13,代码来源:CxScanResult.java

示例8: doOsaHtmlReport

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public void doOsaHtmlReport(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("text/html");
    ServletOutputStream outputStream = rsp.getOutputStream();
    File buildDirectory = owner.getRootDir();
    File a = new File(buildDirectory, "/checkmarx/" + "OSAReport.html");

    IOUtils.copy(a, outputStream);

    outputStream.flush();
    outputStream.close();
}
 
开发者ID:jenkinsci,项目名称:checkmarx-plugin,代码行数:12,代码来源:CxScanResult.java

示例9: doIndex

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
 * Displays the JSON payload from GitHub. Stapler API.
 *
 * @param req request
 * @param rsp response
 * @throws IOException
 */
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("application/json;charset=UTF-8");
    // Prevent jelly from flushing stream so Content-Length header can be added afterwards
    try (FlushProofOutputStream out = new FlushProofOutputStream(rsp.getCompressedOutputStream(req))) {
        IOUtils.copy(getPayloadFile(), out);
    }
}
 
开发者ID:Affirm,项目名称:jenkins-plugins,代码行数:15,代码来源:TagCause.java

示例10: jsonResponse

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public static HttpResponse jsonResponse(final Object payload) {
    return new HttpResponse() {
        @Override
        public void generateResponse(StaplerRequest request, StaplerResponse response, Object node) throws IOException, ServletException {
            response.setContentType("application/json");
            if (payload != null) {
                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
                objectMapper.writeValue(buffer, payload);
                response.getOutputStream().write(buffer.toByteArray());
            }
        }
    };
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:14,代码来源:JSONHelper.java

示例11: jsonResponse

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
public static HttpResponse jsonResponse(final CollectorRegistry collectorRegistry) {
    return new HttpResponse() {
        @Override
        public void generateResponse(StaplerRequest request, StaplerResponse response, Object node) throws IOException, ServletException {
            response.setStatus(StaplerResponse.SC_OK);
            response.setContentType(TextFormat.CONTENT_TYPE_004);

            StringWriter buffer = new StringWriter();
            TextFormat.write004(buffer, collectorRegistry.metricFamilySamples());
            buffer.close();
            response.getWriter().write(buffer.toString());
        }
    };
}
 
开发者ID:fabric8io,项目名称:fabric8-jenkins-workflow-steps,代码行数:15,代码来源:MetricsRequest.java

示例12: doPollingLog

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
 * TODO is it secure?
 */
public void doPollingLog(StaplerRequest req, StaplerResponse rsp) throws IOException {
    rsp.setContentType("text/plain;charset=UTF-8");
    // Prevent jelly from flushing stream so Content-Length header can be added afterwards
    FlushProofOutputStream out = new FlushProofOutputStream(rsp.getCompressedOutputStream(req));
    try {
        getPollingLogText().writeLogTo(0, out);
    } finally {
        closeQuietly(out);
    }
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:14,代码来源:GitHubPollingLogAction.java

示例13: toJSONResponse

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
/**
 * Serves the JSON response.
 * @param item Data to be serialized to JSON
 * @return HTTP response with application/json MIME type
 */
private static HttpResponse toJSONResponse(final Object item) {
    return new HttpResponse() {
        @Override
        public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
            ObjectMapper mapper = new ObjectMapper(); 
            rsp.setContentType("application/json;charset=UTF-8");
            mapper.writeValue(rsp.getWriter(), item);
        }
    };
}
 
开发者ID:jenkinsci,项目名称:docker-traceability-plugin,代码行数:16,代码来源:DockerTraceabilityRootAction.java

示例14: generateResponse

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
@Override
public void generateResponse(StaplerRequest req,
    StaplerResponse rsp,
    Object o) throws IOException, ServletException {

    rsp.setStatus(status);
    rsp.setContentType("application/json");
    rsp.getWriter().println(json);
}
 
开发者ID:dpires,项目名称:jenkins-slack-webhook-plugin,代码行数:10,代码来源:JsonResponse.java

示例15: writeBody

import org.kohsuke.stapler.StaplerResponse; //导入方法依赖的package包/类
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();
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:8,代码来源:StatusJsonAction.java


注:本文中的org.kohsuke.stapler.StaplerResponse.setContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。