public CloudFilesObject get(String path, long start) { final SwiftObject swiftObject; if (start == 0) { swiftObject = objectApi.get(path); } else { swiftObject = objectApi.get(path, new GetOptions().startAt(start)); } Payload payload = swiftObject.getPayload(); return new CloudFilesObject(payload, this.region, this.container, path); }
/** * @see GetOptions#startAt(long) */ public static GetOptions startAt(long start) { GetOptions options = new GetOptions(); return options.startAt(start); }
/** * @see GetOptions#startAt(long) */ public static GetOptions startAt(long start) { GetOptions options = new GetOptions(); return options.startAt(start); }
/** * @see GetOptions#startAt(long) */ public static GetOptions startAt(long start) { GetOptions options = new GetOptions(); return options.startAt(start); }
/** * @see GetOptions#startAt(long) */ public static GetOptions startAt(long start) { GetOptions options = new GetOptions(); return options.startAt(start); }
/** * @see GetOptions#startAt(long) */ public static GetOptions startAt(long start) { GetOptions options = new GetOptions(); return options.startAt(start); }
/** * @see GetOptions#startAt(long) */ public static GetOptions startAt(long start) { GetOptions options = new GetOptions(); return options.startAt(start); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testStartAtFail() { GetOptions options = new GetOptions(); options.startAt(-1); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testStartAtFail() { GetOptions options = new GetOptions(); options.startAt(-1); }
@Test public void testStartAt() { GetOptions options = new GetOptions(); options.startAt(100); assertEquals(options.getRange(), "bytes=100-"); }
@Test public void testStartAt() { GetOptions options = new GetOptions(); options.startAt(100); assertEquals(options.getRange(), "bytes=100-"); }
@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; } }
@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; } }
@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; } }
@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); }
@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); }
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; } }
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; } }
@Test 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); }
@Test 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); }