@Test public void getUserMetadataGoodInputTest() throws Exception { JSONObject headers = new JSONObject(); setAmbryHeadersForPut(headers, Long.toString(RANDOM.nextInt(10000)), generateRandomString(10), Container.DEFAULT_PUBLIC_CONTAINER, "image/gif", generateRandomString(10)); Map<String, String> userMetadata = new HashMap<String, String>(); userMetadata.put(RestUtils.Headers.USER_META_DATA_HEADER_PREFIX + "key1", "value1"); userMetadata.put(RestUtils.Headers.USER_META_DATA_HEADER_PREFIX + "key2", "value2"); userMetadata.put(RestUtils.Headers.USER_META_DATA_HEADER_PREFIX.toUpperCase() + "KeY3", "value3"); userMetadata.put(RestUtils.Headers.USER_META_DATA_HEADER_PREFIX.toLowerCase() + "kEy4", "value4"); setUserMetadataHeaders(headers, userMetadata); verifyUserMetadataConstructionSuccess(headers, userMetadata); }
public static boolean setUserMetadataHeaders(byte[] userMetadata, RestResponseChannel restResponseChannel) throws RestServiceException { Map<String, String> userMetadataMap = buildUserMetadata(userMetadata); boolean setHeaders = userMetadataMap != null; if (setHeaders) { for (Map.Entry<String, String> entry : userMetadataMap.entrySet()) { restResponseChannel.setHeader(entry.getKey(), entry.getValue()); } } return setHeaders; }
RestUtils { public static boolean setUserMetadataHeaders(byte[] userMetadata, RestResponseChannel restResponseChannel) throws RestServiceException { Map<String, String> userMetadataMap = buildUserMetadata(userMetadata); boolean setHeaders = userMetadataMap != null; if (setHeaders) { for (Map.Entry<String, String> entry : userMetadataMap.entrySet()) { restResponseChannel.setHeader(entry.getKey(), entry.getValue()); } } return setHeaders; } }
RestUtils { public static boolean setUserMetadataHeaders(byte[] userMetadata, RestResponseChannel restResponseChannel) throws RestServiceException { Map<String, String> userMetadataMap = buildUserMetadata(userMetadata); boolean setHeaders = userMetadataMap != null; if (setHeaders) { for (Map.Entry<String, String> entry : userMetadataMap.entrySet()) { restResponseChannel.setHeader(entry.getKey(), entry.getValue()); } } return setHeaders; }  }
RestUtils { public static boolean setUserMetadataHeaders(byte[] userMetadata, RestResponseChannel restResponseChannel) throws RestServiceException { Map<String, String> userMetadataMap = buildUserMetadata(userMetadata); boolean setHeaders = userMetadataMap != null; if (setHeaders) { for (Map.Entry<String, String> entry : userMetadataMap.entrySet()) { restResponseChannel.setHeader(entry.getKey(), entry.getValue()); } } return setHeaders; }  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 boolean setUserMetadataHeaders(byte[] userMetadata, RestResponseChannel restResponseChannel) throws RestServiceException { Map<String, String> userMetadataMap = buildUserMetadata(userMetadata); boolean setHeaders = userMetadataMap != null; if (setHeaders) { for (Map.Entry<String, String> entry : userMetadataMap.entrySet()) { restResponseChannel.setHeader(entry.getKey(), entry.getValue()); } } return setHeaders; }  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; }