VCloudPluginResource.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:plugin-vm-vcloud 作者:
/**
 * Return a snapshot of the console.
 * 
 * @param subscription
 *            the valid screenshot of the console.
 * @return the valid screenshot of the console.
 */
@GET
@Path("{subscription:\\d+}/console.png")
@Produces("image/png")
public StreamingOutput getConsole(@PathParam("subscription") final int subscription) {
    final Map<String, String> parameters = subscriptionResource.getParameters(subscription);
    final VCloudCurlProcessor processor = new VCloudCurlProcessor();
    authenticate(parameters, processor);

    // Get the screen thumbnail
    return output -> {
        final String url = StringUtils.appendIfMissing(parameters.get(PARAMETER_API), "/") + "vApp/vm-" + parameters.get(PARAMETER_VM)
                + "/screen";
        final CurlRequest curlRequest = new CurlRequest("GET", url, null, (request, response) -> {
            if (response.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) {
                // Copy the stream
                IOUtils.copy(response.getEntity().getContent(), output);
                output.flush();
            }
            return false;
        });
        processor.process(curlRequest);
    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号