From 251ab7a631189890a4d4701c2cf2aa1cf6b665de Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Sat, 12 Oct 2024 13:03:10 -0700 Subject: [PATCH] Generate a warning if attempting to serialize SPDX V3 data Fixes #73 Signed-off-by: Gary O'Neall --- src/main/java/org/spdx/jacksonstore/MultiFormatStore.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/spdx/jacksonstore/MultiFormatStore.java b/src/main/java/org/spdx/jacksonstore/MultiFormatStore.java index c4607a0..784ba5b 100644 --- a/src/main/java/org/spdx/jacksonstore/MultiFormatStore.java +++ b/src/main/java/org/spdx/jacksonstore/MultiFormatStore.java @@ -185,6 +185,9 @@ public synchronized void serialize(OutputStream stream, @Nullable CoreModelObjec List allDocuments = getAllItems(null, SpdxConstantsCompatV2.CLASS_SPDX_DOCUMENT) .map(tv -> tv.getObjectUri().substring(0, tv.getObjectUri().indexOf('#'))) .collect(Collectors.toList()); + if (allDocuments.isEmpty()) { + logger.warn("No SPDX Spec Version 2 Documents were found to serialize. Note: For SPDX Spec version 3, the spdx-v3jsonld-store should be used"); + } output = allDocuments.size() == 1 ? serializer.docToJsonNode(allDocuments.get(0)) : serializer.docsToJsonNode(allDocuments); }