@Test public void buildContentRangeAndLengthTest() throws RestServiceException { doBuildContentRangeAndLengthTest(ByteRanges.fromOffsetRange(4, 8), 12, "bytes 4-8/12", 5, true); doBuildContentRangeAndLengthTest(ByteRanges.fromOffsetRange(4, 12), 12, "bytes 4-11/12", 8, true); doBuildContentRangeAndLengthTest(ByteRanges.fromOffsetRange(4, 15), 12, "bytes 4-11/12", 8, true); doBuildContentRangeAndLengthTest(ByteRanges.fromStartOffset(14), 17, "bytes 14-16/17", 3, true); doBuildContentRangeAndLengthTest(ByteRanges.fromLastNBytes(12), 17, "bytes 5-16/17", 12, true); doBuildContentRangeAndLengthTest(ByteRanges.fromLastNBytes(17), 17, "bytes 0-16/17", 17, true); doBuildContentRangeAndLengthTest(ByteRanges.fromLastNBytes(13), 12, "bytes 0-11/12", 12, true); doBuildContentRangeAndLengthTest(ByteRanges.fromOffsetRange(4, 12), 4, null, -1, false); doBuildContentRangeAndLengthTest(ByteRanges.fromStartOffset(12), 12, null, -1, false); doBuildContentRangeAndLengthTest(ByteRanges.fromStartOffset(15), 12, null, -1, false); }
public static Pair<String, Long> buildContentRangeAndLength(ByteRange range, long blobSize, boolean resolveRangeOnEmptyBlob) throws RestServiceException { try { range = range.toResolvedByteRange(blobSize, resolveRangeOnEmptyBlob); } catch (IllegalArgumentException e) { throw new RestServiceException("Range provided was not satisfiable.", e, RestServiceErrorCode.RangeNotSatisfiable); } return new Pair<>(BYTE_RANGE_UNITS + " " + range.getStartOffset() + "-" + range.getEndOffset() + "/" + blobSize, range.getRangeSize()); }
RestUtils { public static Pair<String, Long> buildContentRangeAndLength(ByteRange range, long blobSize, boolean resolveRangeOnEmptyBlob) throws RestServiceException { try { range = range.toResolvedByteRange(blobSize, resolveRangeOnEmptyBlob); } catch (IllegalArgumentException e) { throw new RestServiceException("Range provided was not satisfiable.", e, RestServiceErrorCode.RangeNotSatisfiable); } return new Pair<>(BYTE_RANGE_UNITS + " " + range.getStartOffset() + "-" + range.getEndOffset() + "/" + blobSize, range.getRangeSize()); } }
RestUtils { public static Pair<String, Long> buildContentRangeAndLength(ByteRange range, long blobSize, boolean resolveRangeOnEmptyBlob) throws RestServiceException { try { range = range.toResolvedByteRange(blobSize, resolveRangeOnEmptyBlob); } catch (IllegalArgumentException e) { throw new RestServiceException("Range provided was not satisfiable.", e, RestServiceErrorCode.RangeNotSatisfiable); } return new Pair<>(BYTE_RANGE_UNITS + " " + range.getStartOffset() + "-" + range.getEndOffset() + "/" + blobSize, range.getRangeSize()); }  }
RestUtils { public static Pair<String, Long> buildContentRangeAndLength(ByteRange range, long blobSize, boolean resolveRangeOnEmptyBlob) throws RestServiceException { try { range = range.toResolvedByteRange(blobSize, resolveRangeOnEmptyBlob); } catch (IllegalArgumentException e) { throw new RestServiceException("Range provided was not satisfiable.", e, RestServiceErrorCode.RangeNotSatisfiable); } return new Pair<>(BYTE_RANGE_UNITS + " " + range.getStartOffset() + "-" + range.getEndOffset() + "/" + blobSize, range.getRangeSize()); }  static BlobProperties buildBlobProperties(Map<String, Object> args); static byte[] buildUserMetadata(Map<String, Object> args); static Map<String, String> buildUserMetadata(byte[] userMetadata); static GetBlobOptions buildGetBlobOptions(Map<String, Object> args, SubResource subResource,
      GetOption getOption, int blobSegmentIdx); static Pair<String, Long> buildContentRangeAndLength(ByteRange range, long blobSize,
      boolean resolveRangeOnEmptyBlob); static RequestPath getRequestPath(RestRequest restRequest); static Long getTimeFromDateString(String dateString); static long toSecondsPrecisionInMs(long ms); static GetOption getGetOption(RestRequest restRequest, GetOption defaultGetOption); static boolean isPrivate(Map<String, Object> args); static boolean isChunkUpload(Map<String, Object> args); static void ensureRequiredHeadersOrThrow(RestRequest restRequest, Set<String> requiredHeaders); static String getHeader(Map<String, ?> args, String header, boolean required); static Long getLongHeader(Map<String, ?> args, String header, boolean required); static T getNumericalHeader(Map<String, ?> args, String header, boolean required,
      Function<String, T> converter); static boolean getBooleanHeader(Map<String, Object> args, String header, boolean required); static Account getAccountFromArgs(Map<String, Object> args); static Container getContainerFromArgs(Map<String, Object> args); static void accountAndContainerNamePreconditionCheck(RestRequest restRequest); static boolean setUserMetadataHeaders(byte[] userMetadata, RestResponseChannel restResponseChannel); }
RestUtils { public static Pair<String, Long> buildContentRangeAndLength(ByteRange range, long blobSize, boolean resolveRangeOnEmptyBlob) throws RestServiceException { try { range = range.toResolvedByteRange(blobSize, resolveRangeOnEmptyBlob); } catch (IllegalArgumentException e) { throw new RestServiceException("Range provided was not satisfiable.", e, RestServiceErrorCode.RangeNotSatisfiable); } return new Pair<>(BYTE_RANGE_UNITS + " " + range.getStartOffset() + "-" + range.getEndOffset() + "/" + blobSize, range.getRangeSize()); }  static BlobProperties buildBlobProperties(Map<String, Object> args); static byte[] buildUserMetadata(Map<String, Object> args); static Map<String, String> buildUserMetadata(byte[] userMetadata); static GetBlobOptions buildGetBlobOptions(Map<String, Object> args, SubResource subResource,
      GetOption getOption, int blobSegmentIdx); static Pair<String, Long> buildContentRangeAndLength(ByteRange range, long blobSize,
      boolean resolveRangeOnEmptyBlob); static RequestPath getRequestPath(RestRequest restRequest); static Long getTimeFromDateString(String dateString); static long toSecondsPrecisionInMs(long ms); static GetOption getGetOption(RestRequest restRequest, GetOption defaultGetOption); static boolean isPrivate(Map<String, Object> args); static boolean isChunkUpload(Map<String, Object> args); static void ensureRequiredHeadersOrThrow(RestRequest restRequest, Set<String> requiredHeaders); static String getHeader(Map<String, ?> args, String header, boolean required); static Long getLongHeader(Map<String, ?> args, String header, boolean required); static T getNumericalHeader(Map<String, ?> args, String header, boolean required,
      Function<String, T> converter); static boolean getBooleanHeader(Map<String, Object> args, String header, boolean required); static Account getAccountFromArgs(Map<String, Object> args); static Container getContainerFromArgs(Map<String, Object> args); static void accountAndContainerNamePreconditionCheck(RestRequest restRequest); static boolean setUserMetadataHeaders(byte[] userMetadata, RestResponseChannel restResponseChannel); static final String HTTP_DATE_FORMAT; static final String BYTE_RANGE_UNITS; static final String SIGNED_ID_PREFIX; static final String JSON_CONTENT_TYPE; }