From e1ca944ed9d9def47056c6bd2d62faf01e26436c Mon Sep 17 00:00:00 2001 From: qqmyers Date: Tue, 18 Apr 2023 18:19:52 -0400 Subject: [PATCH] bag processing errors - no aggregates array with single file (after jsonld compact/expand) - string escaping in creating array --- .../org/sead/uploader/util/PublishedResource.java | 2 +- .../java/org/sead/uploader/util/ResourceFactory.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/sead/uploader/util/PublishedResource.java b/src/main/java/org/sead/uploader/util/PublishedResource.java index 7f985e4..0d5392a 100644 --- a/src/main/java/org/sead/uploader/util/PublishedResource.java +++ b/src/main/java/org/sead/uploader/util/PublishedResource.java @@ -141,7 +141,7 @@ JSONArray getChildren() { if (o instanceof JSONArray) { return (JSONArray) o; } else if (o instanceof String) { - return new JSONArray("[ " + (String) o + " ]"); + return new JSONArray("[ \"" + (String) o + "\" ]"); } return new JSONArray(); } diff --git a/src/main/java/org/sead/uploader/util/ResourceFactory.java b/src/main/java/org/sead/uploader/util/ResourceFactory.java index ac12795..fa772c1 100644 --- a/src/main/java/org/sead/uploader/util/ResourceFactory.java +++ b/src/main/java/org/sead/uploader/util/ResourceFactory.java @@ -156,9 +156,19 @@ final void createOreMapFromString(String mapString) { } rootPath = "/" + aggId + "/data/" + aggregation.getString("Title"); - aggregates = aggregation.getJSONArray("aggregates"); + + aggregates = aggregation.optJSONArray("aggregates"); + if(aggregates==null) { + JSONObject singleFile = aggregation.optJSONObject("aggregates"); + aggregates= new JSONArray(); + if(singleFile!=null) { + aggregates.put(singleFile); + } + } + ArrayList l = new ArrayList<>(aggregates.length() + 1); l.add(aggId); + for (int i = 0; i < aggregates.length(); i++) { l.add(aggregates.getJSONObject(i).getString("@id")); }