mirror of https://github.com/apache/jclouds.git
Issue 830: Add non-JAXB response parser for screen image
This commit is contained in:
parent
d2dc81a1a9
commit
cee5fcc58b
|
@ -56,6 +56,7 @@ import org.jclouds.rest.annotations.EndpointParam;
|
|||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.binders.BindToXMLPayload;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.DeployVAppParams;
|
||||
|
@ -82,6 +83,7 @@ import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.ovf.StartupSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
@ -538,8 +540,8 @@ public interface VAppAsyncClient {
|
|||
@GET
|
||||
@Path("/screen")
|
||||
@Consumes(ANY_IMAGE)
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
@ResponseParser(ReturnPayloadBytes.class)
|
||||
ListenableFuture<byte[]> getScreenImage(@EndpointParam URI vAppURI);
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.functions;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
/**
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Singleton
|
||||
public class ReturnPayloadBytes implements Function<HttpResponse, byte[]> {
|
||||
|
||||
@Override
|
||||
public byte[] apply(HttpResponse from) {
|
||||
try {
|
||||
return ByteStreams.toByteArray(from.getPayload().getInput());
|
||||
} catch (IOException e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue