Package org.jclouds.http.options

Examples of org.jclouds.http.options.GetOptions


    * @param key
    *           blob key
    */
   @Override
   public ListenableFuture<Blob> getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
      GetOptions azureOptions = blob2ObjectGetOptions.apply(options);
      ListenableFuture<AzureBlob> returnVal = async.getBlob(container, key, azureOptions);
      return transform(returnVal, azureBlob2Blob, userExecutor);
   }


   /**
    * This implementation invokes {@link AtmosClient#readFile}
    */
   @Override
   public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
      GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
      return object2Blob.apply(sync.readFile(container + "/" + key, httpOptions));
   }

   /**
    * This implementation invokes {@link AtmosAsyncClient#readFile}
    */
   @Override
   public ListenableFuture<Blob> getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
      GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
      ListenableFuture<AtmosObject> returnVal = async.readFile(container + "/" + key, httpOptions);
      return transform(returnVal, object2Blob, userExecutor);
   }

            @BinderParam(BindToStringPayload.class) String payload);
   }

   public void testCreateGetVarArgOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException {
      Date date = new Date();
      GetOptions options = GetOptions.Builder.ifModifiedSince(date);
      Invokable<?, ?> method = method(TestRequest.class, "get", String.class,
            HttpRequestOptions[].class);
      GeneratedHttpRequest request = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of("1", options)));
      assertEquals(request.getEndpoint().getHost(), "localhost");

            ImmutableList.of(dateService.rfc822DateFormat(date)));
   }

   public void testCreateGetOptionsThatProducesHeaders() throws SecurityException, NoSuchMethodException {
      Date date = new Date();
      GetOptions options = GetOptions.Builder.ifModifiedSince(date);
      Invokable<?, ?> method = method(TestRequest.class, "get", String.class, HttpRequestOptions.class);
      GeneratedHttpRequest request = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of("1", options)));
      assertEquals(request.getEndpoint().getHost(), "localhost");
      assertEquals(request.getEndpoint().getPath(), "/1");

    * @param key
    *           file name
    */
   @Override
   public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions optionsList) {
      GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList);
      return object2Blob.apply(sync.getObject(container, key, httpOptions));
   }

    * @param key
    *           object key
    */
   @Override
   public ListenableFuture<Blob> getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
      GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
      ListenableFuture<SwiftObject> returnVal = async.getObject(container, key, httpOptions);
      return transform(returnVal, object2Blob, userExecutor);
   }

*/
@Singleton
public class BlobToObjectGetOptions implements
         Function<org.jclouds.blobstore.options.GetOptions, GetOptions> {
   public GetOptions apply(org.jclouds.blobstore.options.GetOptions from) {
      GetOptions httpOptions = new GetOptions();
      if (from != null) {
         if (from.getIfMatch() != null) {
            httpOptions.ifETagMatches(from.getIfMatch());
         }
         if (from.getIfModifiedSince() != null) {
            httpOptions.ifModifiedSince(from.getIfModifiedSince());
         }
         if (from.getIfNoneMatch() != null) {
            httpOptions.ifETagDoesntMatch(from.getIfNoneMatch());
         }
         if (from.getIfUnmodifiedSince() != null) {
            httpOptions.ifUnmodifiedSince(from.getIfUnmodifiedSince());
         }
         for (String range : from.getRanges()) {
            String[] firstLast = range.split("\\-");
            if (firstLast.length == 2)
               httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1]));
            else if (range.startsWith("-"))
               httpOptions.tail(Long.parseLong(firstLast[0]));
            else
               httpOptions.startAt(Long.parseLong(firstLast[0]));
         }
      }
      return httpOptions;
   }

    * @param key
    *           object key
    */
   @Override
   public ListenableFuture<Blob> getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions options) {
      GetOptions httpOptions = blob2ObjectGetOptions.apply(options);
      return transform(async.getObject(container, key, httpOptions), object2Blob, userExecutor);
   }

    * @param key
    *           object key
    */
   @Override
   public Blob getBlob(String container, String key, org.jclouds.blobstore.options.GetOptions optionsList) {
      GetOptions httpOptions = blob2ObjectGetOptions.apply(optionsList);
      return object2Blob.apply(sync.getObject(container, key, httpOptions));
   }

TOP

Related Classes of org.jclouds.http.options.GetOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.