Examples of GetOptions


Examples of org.jclouds.http.options.GetOptions

      Date ifUnmodifiedSince = new Date(999999l);

      org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions();
      in.ifUnmodifiedSince(ifUnmodifiedSince);
      GetOptions expected = new GetOptions();
      expected.ifUnmodifiedSince(ifUnmodifiedSince);

      assertEquals(fn.apply(in), expected);
   }

Examples of org.jclouds.http.options.GetOptions

      Date ifModifiedSince = new Date(999999l);

      org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions();
      in.ifModifiedSince(ifModifiedSince);
      GetOptions expected = new GetOptions();
      expected.ifModifiedSince(ifModifiedSince);

      assertEquals(fn.apply(in), expected);
   }

Examples of org.jclouds.http.options.GetOptions

      String ifUnmatch = "foo";

      org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions();
      in.ifETagDoesntMatch(ifUnmatch);
      GetOptions expected = new GetOptions();
      expected.ifETagDoesntMatch(ifUnmatch);

      assertEquals(fn.apply(in), expected);
   }

Examples of org.jclouds.http.options.GetOptions

      String ifMatch = "foo";

      org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions();
      in.ifETagMatches(ifMatch);
     
      GetOptions expected = new GetOptions();
      expected.ifETagMatches(ifMatch);

      assertEquals(fn.apply(in), expected);
   }

Examples of org.jclouds.http.options.GetOptions

   public void testRanges(){
      org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions();
      in.range(0,1024);
      in.startAt(2048);
     
      GetOptions expected = new GetOptions();
      expected.range(0,1024);
      expected.startAt(2048);

      assertEquals(fn.apply(in), expected);

   }

Examples of org.jclouds.http.options.GetOptions

   @Test
   public void testRangesTail(){
      org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions();
      in.tail(1024);

      GetOptions expected = new GetOptions();
      expected.tail(1024);

      assertEquals(fn.apply(in), expected);

   }

Examples of org.jclouds.http.options.GetOptions

   @Test
   public void testRangesStart(){
      org.jclouds.blobstore.options.GetOptions in = new org.jclouds.blobstore.options.GetOptions();
      in.startAt(1024);

      GetOptions expected = new GetOptions();
      expected.startAt(1024);

      assertEquals(fn.apply(in), expected);

   }

Examples of org.jclouds.http.options.GetOptions

   @Override
   public GetOptions apply(org.jclouds.blobstore.options.GetOptions from) {
      checkNotNull(from, "options");
      if (from == org.jclouds.blobstore.options.GetOptions.NONE)
         return GetOptions.NONE;
      GetOptions httpOptions = new GetOptions();
      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("\\-", 2);
         if (!firstLast[0].isEmpty() && !firstLast[1].isEmpty())
            httpOptions.range(Long.parseLong(firstLast[0]), Long.parseLong(firstLast[1]));
         else if (firstLast[0].isEmpty() && !firstLast[1].isEmpty())
            httpOptions.tail(Long.parseLong(firstLast[1]));
         else
            httpOptions.startAt(Long.parseLong(firstLast[0]));
      }
      return httpOptions;
   }

Examples of org.jclouds.http.options.GetOptions

*/
@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;
   }

Examples of org.jclouds.http.options.GetOptions

    * @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));
   }
TOP
Copyright © 2018 www.massapi.com. 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.