Fix #11074 export simple archive format with no collection

(cherry picked from commit d282f92427)
This commit is contained in:
Martin Walk
2025-08-20 15:45:14 +02:00
committed by github-actions[bot]
parent bc5df89155
commit 0e55e70f16

View File

@@ -353,7 +353,7 @@ public class ItemExportServiceImpl implements ItemExportService {
/** /**
* Create the 'collections' file. List handles of all Collections which * Create the 'collections' file. List handles of all Collections which
* contain this Item. The "owning" Collection is listed first. * contain this Item. The "owning" Collection is listed first.
* *
* @param item list collections holding this Item. * @param item list collections holding this Item.
* @param destDir write the file here. * @param destDir write the file here.
@@ -364,12 +364,14 @@ public class ItemExportServiceImpl implements ItemExportService {
File outFile = new File(destDir, "collections"); File outFile = new File(destDir, "collections");
if (outFile.createNewFile()) { if (outFile.createNewFile()) {
try (PrintWriter out = new PrintWriter(new FileWriter(outFile))) { try (PrintWriter out = new PrintWriter(new FileWriter(outFile))) {
String ownerHandle = item.getOwningCollection().getHandle(); Collection owningCollection = item.getOwningCollection();
out.println(ownerHandle); // The owning collection is null for workspace and workflow items
if (owningCollection != null) {
out.println(owningCollection.getHandle());
}
for (Collection collection : item.getCollections()) { for (Collection collection : item.getCollections()) {
String collectionHandle = collection.getHandle(); if (!collection.equals(owningCollection)) {
if (!collectionHandle.equals(ownerHandle)) { out.println(collection.getHandle());
out.println(collectionHandle);
} }
} }
} }