From 4af206c4e7dcbb174d6f55c3ccfe89a3ad7d6f00 Mon Sep 17 00:00:00 2001 From: nidhiii-27 Date: Wed, 1 Oct 2025 16:56:30 +0530 Subject: [PATCH 1/7] samples: add samples for object contexts --- .../storage/object/GetObjectContexts.java | 36 +++++++++++ .../storage/object/ListObjectContexts.java | 44 +++++++++++++ .../storage/object/SetObjectContexts.java | 61 +++++++++++++++++++ 3 files changed, 141 insertions(+) create mode 100644 samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java create mode 100644 samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java create mode 100644 samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java diff --git a/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java new file mode 100644 index 0000000000..4bbae33f39 --- /dev/null +++ b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java @@ -0,0 +1,36 @@ +package com.example.storage.object; + +// [START storage_get_object_contexts] + +import com.google.cloud.storage.Blob; +import com.google.cloud.storage.BlobInfo.ObjectCustomContextPayload; +import com.google.cloud.storage.Storage; +import com.google.cloud.storage.StorageOptions; +import java.util.Map; + +public class GetObjectContexts { + public static void getObjectMetadata(String projectId, String bucketName, String blobName) + throws Exception { + // The ID of your GCP project + // String projectId = "your-project-id"; + + // The ID of your GCS bucket + // String bucketName = "your-unique-bucket-name"; + + // The ID of your GCS object + // String objectName = "your-object-name"; + + try (Storage storage = + StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { + + Blob blob = storage.get(bucketName, blobName); + Map customContexts = blob.getContexts().getCustom(); + // Print blob's object contexts + System.out.println("\nCustom Contexts:"); + for (Map.Entry custom : customContexts.entrySet()) { + System.out.println(custom.getKey() + "=" + custom.getValue()); + } + } + } +} +// [END storage_get_object_contexts] diff --git a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java new file mode 100644 index 0000000000..6bc179a556 --- /dev/null +++ b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java @@ -0,0 +1,44 @@ +package com.example.storage.object; + +// [START storage_list_object_contexts] + +import com.google.api.gax.paging.Page; +import com.google.cloud.storage.Blob; +import com.google.cloud.storage.Storage; +import com.google.cloud.storage.StorageOptions; + +public class ListObjectContexts { + public static void listObjectContexts(String projectId, String bucketName) throws Exception { + // The ID of your GCP project + // String projectId = "your-project-id"; + + // The ID of your GCS bucket + // String bucketName = "your-unique-bucket-name"; + + try (Storage storage = + StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { + /** + * List any object that has a context with the specified key attached String filter = + * "contexts.\"KEY\":*"; + * + *

List any object that that does not have a context with the specified key attached String + * filter = "NOT contexts.\"KEY\":*"; + * + *

List any object that has a context with the specified key and value attached String + * filter = "contexts.\"KEY\"=\"VALUE\""; + * + *

List any object that does not have a context with the specified key and value attached + * String filter = "NOT contexts.\"KEY\"=\"VALUE\""; + */ + String key = "your-context-key"; + String filter = "contexts.\"" + key + "\":*"; + + System.out.println("Listing objects for bucket: " + bucketName + "with context key: " + key); + Page blobs = storage.list(bucketName, Storage.BlobListOption.filter(filter)); + for (Blob blob : blobs.iterateAll()) { + System.out.println(blob.getName()); + } + } + } +} +// [END storage_list_object_contexts] diff --git a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java new file mode 100644 index 0000000000..c98a372417 --- /dev/null +++ b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java @@ -0,0 +1,61 @@ +package com.example.storage.object; + +// [START storage_set_object_contexts] + +import com.google.cloud.storage.Blob; +import com.google.cloud.storage.BlobId; +import com.google.cloud.storage.BlobInfo; +import com.google.cloud.storage.BlobInfo.ObjectContexts; +import com.google.cloud.storage.BlobInfo.ObjectCustomContextPayload; +import com.google.cloud.storage.Storage; +import com.google.cloud.storage.StorageOptions; +import com.google.common.collect.Maps; +import java.util.Map; + +public class SetObjectContexts { + public static void setObjectContexts(String projectId, String bucketName, String objectName) + throws Exception { + // The ID of your GCP project + // String projectId = "your-project-id"; + + // The ID of your GCS bucket + // String bucketName = "your-unique-bucket-name"; + + // The name of your GCS object + // String objectName = "your-object-name"; + + try (Storage storage = + StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { + String key = "your-context-key"; + String value = "your-context-value"; + + ObjectCustomContextPayload payload = + ObjectCustomContextPayload.newBuilder().setValue(value).build(); + Map custom = Maps.newHashMap(); + custom.put(key, payload); + ObjectContexts contexts = ObjectContexts.newBuilder().setCustom(custom).build(); + + BlobId blobId = BlobId.of(bucketName, objectName); + Blob blob = storage.get(blobId); + if (blob == null) { + System.out.println("The object " + objectName + " was not found in " + bucketName); + return; + } + + // Optional: set a generation-match precondition to avoid potential race + // conditions and data corruptions. The request to upload returns a 412 error if + // the object's generation number does not match your precondition. + Storage.BlobTargetOption precondition = Storage.BlobTargetOption.generationMatch(); + + // Does an upsert operation, if the key already exists it's replaced by the new value, + // otherwise + // it's added. + BlobInfo pendingUpdate = blob.toBuilder().setContexts(contexts).build(); + storage.update(pendingUpdate, precondition); + + System.out.println( + "Updated custom contexts for object " + objectName + " in bucket " + bucketName); + } + } +} +// [END storage_set_object_contexts] From 3a3c5f1f11770af56e48bc55d2f8d32f1265761b Mon Sep 17 00:00:00 2001 From: nidhiii-27 Date: Mon, 6 Oct 2025 11:24:27 +0530 Subject: [PATCH 2/7] chore: add copyright header --- .../storage/object/GetObjectContexts.java | 16 ++++++++++++++++ .../storage/object/ListObjectContexts.java | 16 ++++++++++++++++ .../storage/object/SetObjectContexts.java | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java index 4bbae33f39..f815b8bc6d 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java @@ -1,3 +1,19 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.example.storage.object; // [START storage_get_object_contexts] diff --git a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java index 6bc179a556..25a1347d1a 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java @@ -1,3 +1,19 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.example.storage.object; // [START storage_list_object_contexts] diff --git a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java index c98a372417..2c89a34045 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java @@ -1,3 +1,19 @@ +/* + * Copyright 2025 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.example.storage.object; // [START storage_set_object_contexts] From b1e11d61596f86d10935bfd543f97c4fd5e80a95 Mon Sep 17 00:00:00 2001 From: nidhiii-27 Date: Tue, 7 Oct 2025 12:28:13 +0530 Subject: [PATCH 3/7] chore: modify SetObjectContexts --- .../storage/object/ListObjectContexts.java | 18 +++---- .../storage/object/SetObjectContexts.java | 47 ++++++++++--------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java index 25a1347d1a..6f157f7e44 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java @@ -33,18 +33,18 @@ public static void listObjectContexts(String projectId, String bucketName) throw try (Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { - /** - * List any object that has a context with the specified key attached String filter = - * "contexts.\"KEY\":*"; + /* + * List any object that has a context with the specified key attached + * String filter = "contexts.\"KEY\":*"; * - *

List any object that that does not have a context with the specified key attached String - * filter = "NOT contexts.\"KEY\":*"; + * List any object that that does not have a context with the specified key attached + * String filter = "NOT contexts.\"KEY\":*"; * - *

List any object that has a context with the specified key and value attached String - * filter = "contexts.\"KEY\"=\"VALUE\""; + * List any object that has a context with the specified key and value attached + * String filter = "contexts.\"KEY\"=\"VALUE\""; * - *

List any object that does not have a context with the specified key and value attached - * String filter = "NOT contexts.\"KEY\"=\"VALUE\""; + * List any object that does not have a context with the specified key and value + * attached String filter = "NOT contexts.\"KEY\"=\"VALUE\""; */ String key = "your-context-key"; String filter = "contexts.\"" + key + "\":*"; diff --git a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java index 2c89a34045..b56b44d9e0 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java @@ -31,26 +31,9 @@ public class SetObjectContexts { public static void setObjectContexts(String projectId, String bucketName, String objectName) throws Exception { - // The ID of your GCP project - // String projectId = "your-project-id"; - - // The ID of your GCS bucket - // String bucketName = "your-unique-bucket-name"; - - // The name of your GCS object - // String objectName = "your-object-name"; try (Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { - String key = "your-context-key"; - String value = "your-context-value"; - - ObjectCustomContextPayload payload = - ObjectCustomContextPayload.newBuilder().setValue(value).build(); - Map custom = Maps.newHashMap(); - custom.put(key, payload); - ObjectContexts contexts = ObjectContexts.newBuilder().setCustom(custom).build(); - BlobId blobId = BlobId.of(bucketName, objectName); Blob blob = storage.get(blobId); if (blob == null) { @@ -58,14 +41,34 @@ public static void setObjectContexts(String projectId, String bucketName, String return; } - // Optional: set a generation-match precondition to avoid potential race - // conditions and data corruptions. The request to upload returns a 412 error if + // Optional: Set a generation-match precondition to avoid potential race + // conditions and data corruptions. The request to update returns a 412 error if // the object's generation number does not match your precondition. Storage.BlobTargetOption precondition = Storage.BlobTargetOption.generationMatch(); - // Does an upsert operation, if the key already exists it's replaced by the new value, - // otherwise - // it's added. + String key = "your-context-key"; + String value = "your-context-value"; + + // This section demonstrates how to upsert, delete all, and delete a specific context. + + // To upsert a context (if the key already exists, its value is replaced; + // otherwise, a new key-value pair is added): + ObjectCustomContextPayload payload = + ObjectCustomContextPayload.newBuilder().setValue(value).build(); + Map custom = Maps.newHashMap(); + custom.put(key, payload); + ObjectContexts contexts = ObjectContexts.newBuilder().setCustom(custom).build(); + + /* + * To delete all existing contexts: + * ObjectContexts contexts = ObjectContexts.newBuilder().setCustom(null).build(); + */ + + /* + * To delete a specific key from the context: + * Map custom = Maps.newHashMap(); custom.put(key, null); + * ObjectContexts contexts = ObjectContexts.newBuilder().setCustom(custom).build(); + */ BlobInfo pendingUpdate = blob.toBuilder().setContexts(contexts).build(); storage.update(pendingUpdate, precondition); From d26c734917dd24572c8fcbdb77e839adc7d74095 Mon Sep 17 00:00:00 2001 From: nidhiii-27 Date: Tue, 7 Oct 2025 12:37:52 +0530 Subject: [PATCH 4/7] chore: fix comment --- .../java/com/example/storage/object/SetObjectContexts.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java index b56b44d9e0..0f8f80f400 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java @@ -66,7 +66,8 @@ public static void setObjectContexts(String projectId, String bucketName, String /* * To delete a specific key from the context: - * Map custom = Maps.newHashMap(); custom.put(key, null); + * Map custom = Maps.newHashMap(); + * custom.put(key, null); * ObjectContexts contexts = ObjectContexts.newBuilder().setCustom(custom).build(); */ BlobInfo pendingUpdate = blob.toBuilder().setContexts(contexts).build(); From 56357aedbe3e11c9deedac6429ca8a1cd38edeae Mon Sep 17 00:00:00 2001 From: nidhiii-27 Date: Tue, 7 Oct 2025 12:46:49 +0530 Subject: [PATCH 5/7] chore: fix comment --- .../java/com/example/storage/object/ListObjectContexts.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java index 6f157f7e44..16716b7e85 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java @@ -35,7 +35,7 @@ public static void listObjectContexts(String projectId, String bucketName) throw StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { /* * List any object that has a context with the specified key attached - * String filter = "contexts.\"KEY\":*"; + * String filter = "contexts.\"KEY\":*"; * * List any object that that does not have a context with the specified key attached * String filter = "NOT contexts.\"KEY\":*"; @@ -43,8 +43,8 @@ public static void listObjectContexts(String projectId, String bucketName) throw * List any object that has a context with the specified key and value attached * String filter = "contexts.\"KEY\"=\"VALUE\""; * - * List any object that does not have a context with the specified key and value - * attached String filter = "NOT contexts.\"KEY\"=\"VALUE\""; + * List any object that does not have a context with the specified key and value attached + * String filter = "NOT contexts.\"KEY\"=\"VALUE\""; */ String key = "your-context-key"; String filter = "contexts.\"" + key + "\":*"; From 30bf37ef1987e770eed68071fac8846ae68650e3 Mon Sep 17 00:00:00 2001 From: nidhiii-27 Date: Thu, 9 Oct 2025 15:44:30 +0530 Subject: [PATCH 6/7] chore: review fixes --- .../storage/object/GetObjectContexts.java | 12 +++++++++-- .../storage/object/ListObjectContexts.java | 10 +++++++--- .../storage/object/SetObjectContexts.java | 20 ++++++++++++++----- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java index f815b8bc6d..526860553f 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java @@ -25,7 +25,7 @@ import java.util.Map; public class GetObjectContexts { - public static void getObjectMetadata(String projectId, String bucketName, String blobName) + public static void getObjectContexts(String projectId, String bucketName, String objectName) throws Exception { // The ID of your GCP project // String projectId = "your-project-id"; @@ -39,8 +39,16 @@ public static void getObjectMetadata(String projectId, String bucketName, String try (Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { - Blob blob = storage.get(bucketName, blobName); + Blob blob = storage.get(bucketName, objectName); + if (blob == null) { + System.out.println("The object " + objectName + " was not found in " + bucketName); + return; + } Map customContexts = blob.getContexts().getCustom(); + if (customContexts == null) { + System.out.println("No custom contexts found for object: " + objectName); + return; + } // Print blob's object contexts System.out.println("\nCustom Contexts:"); for (Map.Entry custom : customContexts.entrySet()) { diff --git a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java index 16716b7e85..3becd448a4 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/ListObjectContexts.java @@ -24,13 +24,17 @@ import com.google.cloud.storage.StorageOptions; public class ListObjectContexts { - public static void listObjectContexts(String projectId, String bucketName) throws Exception { + public static void listObjectContexts(String projectId, String bucketName, String key) + throws Exception { // The ID of your GCP project // String projectId = "your-project-id"; // The ID of your GCS bucket // String bucketName = "your-unique-bucket-name"; + // The context key you want to filter + // String key = "your-context-key"; + try (Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { /* @@ -46,13 +50,13 @@ public static void listObjectContexts(String projectId, String bucketName) throw * List any object that does not have a context with the specified key and value attached * String filter = "NOT contexts.\"KEY\"=\"VALUE\""; */ - String key = "your-context-key"; + String filter = "contexts.\"" + key + "\":*"; System.out.println("Listing objects for bucket: " + bucketName + "with context key: " + key); Page blobs = storage.list(bucketName, Storage.BlobListOption.filter(filter)); for (Blob blob : blobs.iterateAll()) { - System.out.println(blob.getName()); + System.out.println(blob.getBlobId().toGsUtilUri()); } } } diff --git a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java index 0f8f80f400..169399a710 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/SetObjectContexts.java @@ -29,8 +29,21 @@ import java.util.Map; public class SetObjectContexts { - public static void setObjectContexts(String projectId, String bucketName, String objectName) + public static void setObjectContexts( + String projectId, String bucketName, String objectName, String key, String value) throws Exception { + // The ID of your GCP project + // String projectId = "your-project-id"; + + // The ID of your GCS bucket + // String bucketName = "your-unique-bucket-name"; + + // The ID of your GCS object + // String objectName = "your-object-name"; + + // The context key-value you want to add + // String key = "your-context-key"; + // String value = "your-context-value"; try (Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService()) { @@ -41,14 +54,11 @@ public static void setObjectContexts(String projectId, String bucketName, String return; } - // Optional: Set a generation-match precondition to avoid potential race + // Recommended: Set a generation-match precondition to avoid potential race // conditions and data corruptions. The request to update returns a 412 error if // the object's generation number does not match your precondition. Storage.BlobTargetOption precondition = Storage.BlobTargetOption.generationMatch(); - String key = "your-context-key"; - String value = "your-context-value"; - // This section demonstrates how to upsert, delete all, and delete a specific context. // To upsert a context (if the key already exists, its value is replaced; From c936c39d416aee2d932947745ab05130253f546f Mon Sep 17 00:00:00 2001 From: nidhiii-27 Date: Fri, 10 Oct 2025 00:36:40 +0530 Subject: [PATCH 7/7] chore: review fixes --- .../storage/object/GetObjectContexts.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java index 526860553f..a0ab377763 100644 --- a/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java +++ b/samples/snippets/src/main/java/com/example/storage/object/GetObjectContexts.java @@ -19,6 +19,7 @@ // [START storage_get_object_contexts] import com.google.cloud.storage.Blob; +import com.google.cloud.storage.BlobInfo.ObjectContexts; import com.google.cloud.storage.BlobInfo.ObjectCustomContextPayload; import com.google.cloud.storage.Storage; import com.google.cloud.storage.StorageOptions; @@ -44,15 +45,19 @@ public static void getObjectContexts(String projectId, String bucketName, String System.out.println("The object " + objectName + " was not found in " + bucketName); return; } - Map customContexts = blob.getContexts().getCustom(); - if (customContexts == null) { - System.out.println("No custom contexts found for object: " + objectName); - return; - } - // Print blob's object contexts - System.out.println("\nCustom Contexts:"); - for (Map.Entry custom : customContexts.entrySet()) { - System.out.println(custom.getKey() + "=" + custom.getValue()); + ObjectContexts objectContexts = blob.getContexts(); + + if (objectContexts != null) { + Map customContexts = objectContexts.getCustom(); + if (customContexts == null) { + System.out.println("No custom contexts found for object: " + objectName); + return; + } + // Print blob's object contexts + System.out.println("\nCustom Contexts:"); + for (Map.Entry custom : customContexts.entrySet()) { + System.out.println(custom.getKey() + "=" + custom.getValue()); + } } } }