From f8380f8070d95bb845ec6a4dff9178bc8af3c2c5 Mon Sep 17 00:00:00 2001 From: "Kevin S. Clarke" Date: Tue, 12 Sep 2023 15:11:18 -0400 Subject: [PATCH 1/3] [SERV-910] Add a catch for duplicate IDs in collection doc --- pom.xml | 38 ++--------- src/main/docker/scripts/show_versions.sh | 2 +- .../fester/verticles/V2ManifestVerticle.java | 65 ++++++++++--------- 3 files changed, 43 insertions(+), 62 deletions(-) diff --git a/pom.xml b/pom.xml index fdaea956..df1dab5a 100644 --- a/pom.xml +++ b/pom.xml @@ -34,45 +34,19 @@ UCLA Library http://github.com/uclalibrary America/New_York + + Lead Developer + - - hardyoyo - Hardy Pottinger - hardy.pottinger@gmail.com - America/Chicago - - - cachemeoutside - Anthony Vuong - avuong@cachemeoutside.io - UCLA Library - http://github.com/uclalibrary - America/Los_Angeles - - - markmatney - Mark A. Matney, Jr. - mmatney@library.ucla.edu - UCLA Library - http://github.com/uclalibrary - America/Los_Angeles - - - DRickard - David Rickard - drickard1967@library.ucla.edu - UCLA Library - http://github.com/uclalibrary - America/Los_Angeles - + 22.04 - 17.0.4+8-1~22.04 + 17.0.8.1+1~us1-0ubuntu1~22.04 3.10.6-1~22.04 - 7.81.0-1ubuntu1.6 + 7.81.0-1ubuntu1.13 3.9.14 diff --git a/src/main/docker/scripts/show_versions.sh b/src/main/docker/scripts/show_versions.sh index bd309650..44b36326 100755 --- a/src/main/docker/scripts/show_versions.sh +++ b/src/main/docker/scripts/show_versions.sh @@ -14,7 +14,7 @@ print_line() { } declare -a DEPENDENCIES=( - "openjdk-11-jre-headless" + "openjdk-17-jre-headless" "python3" "curl" ) diff --git a/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java b/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java index 7d0421bc..de5b6e40 100644 --- a/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java +++ b/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java @@ -286,31 +286,38 @@ private void updateCollection(final Message aMessage) throws JsonPro // First, add the old manifests to the map final Stream stream = collection.getManifests().stream(); - manifestMap.putAll(stream.collect(Collectors.toMap(Collection.Manifest::getID, manifest -> manifest))); - // Next, add the new manifests to the map, replacing any that already exist - worksMap.get(IDUtils.getResourceID(collection.getID())).stream().forEach(workArray -> { - final URI manifestURI = URI.create(workArray[0]); - manifestMap.put(manifestURI, new Collection.Manifest(manifestURI, new Label(workArray[1]))); - }); + try { + // Below can throw a RuntimeException if duplicate IDs are found + manifestMap.putAll(stream.collect(Collectors.toMap(Collection.Manifest::getID, manifest -> manifest))); - // Update the manifest list with the manifests in the map, ordered by their label - sortedManifestSet.addAll(manifestMap.values()); + // Next, add the new manifests to the map, replacing any that already exist + worksMap.get(IDUtils.getResourceID(collection.getID())).stream().forEach(workArray -> { + final URI manifestURI = URI.create(workArray[0]); + manifestMap.put(manifestURI, new Collection.Manifest(manifestURI, new Label(workArray[1]))); + }); - collection.getManifests().clear(); - collection.getManifests().addAll(sortedManifestSet); + // Update the manifest list with the manifests in the map, ordered by their label + sortedManifestSet.addAll(manifestMap.values()); - message.put(Constants.DATA, collection.toJSON()); - message.put(Constants.COLLECTION_NAME, collectionName); - options.addHeader(Constants.ACTION, Op.PUT_COLLECTION); + collection.getManifests().clear(); + collection.getManifests().addAll(sortedManifestSet); - sendMessage(S3BucketVerticle.class.getName(), message, options, update -> { - if (update.succeeded()) { - aMessage.reply(collection.toJSON()); - } else { - error(aMessage, update.cause(), MessageCodes.MFS_152, update.cause().getMessage()); - } - }); + message.put(Constants.DATA, collection.toJSON()); + message.put(Constants.COLLECTION_NAME, collectionName); + options.addHeader(Constants.ACTION, Op.PUT_COLLECTION); + + sendMessage(S3BucketVerticle.class.getName(), message, options, update -> { + if (update.succeeded()) { + aMessage.reply(collection.toJSON()); + } else { + error(aMessage, update.cause(), MessageCodes.MFS_152, update.cause().getMessage()); + } + }); + } catch (final RuntimeException details) { + LOGGER.error(details, details.getMessage()); + aMessage.fail(HTTP.INTERNAL_SERVER_ERROR, details.getMessage()); + } } /** @@ -355,11 +362,11 @@ private void updateWork(final Message aMessage) throws JsonProcessin }); CsvParser.getMetadata(workRow, csvHeaders.getLocalRightsStatementIndex()) - .ifPresentOrElse(localRightsStatement -> { - manifest.setAttribution(new Attribution(localRightsStatement)); - }, () -> { - manifest.clearAttribution(); - }); + .ifPresentOrElse(localRightsStatement -> { + manifest.setAttribution(new Attribution(localRightsStatement)); + }, () -> { + manifest.clearAttribution(); + }); CsvParser.getMetadata(workRow, csvHeaders.getRightsContactIndex()).ifPresentOrElse(rightsContact -> { manifest.setMetadata(updateMetadata(manifest.getMetadata(), MetadataLabels.RIGHTS_CONTACT, rightsContact)); @@ -456,10 +463,10 @@ private Canvas[] createCanvases(final CsvHeaders aCsvHeaders, final List Date: Tue, 12 Sep 2023 15:21:04 -0400 Subject: [PATCH 2/3] Be more specific about runtime exception --- .../library/iiif/fester/verticles/V2ManifestVerticle.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java b/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java index de5b6e40..3d322f76 100644 --- a/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java +++ b/src/main/java/edu/ucla/library/iiif/fester/verticles/V2ManifestVerticle.java @@ -288,7 +288,7 @@ private void updateCollection(final Message aMessage) throws JsonPro final Stream stream = collection.getManifests().stream(); try { - // Below can throw a RuntimeException if duplicate IDs are found + // Below can throw a IllegalStateException if duplicate IDs are found manifestMap.putAll(stream.collect(Collectors.toMap(Collection.Manifest::getID, manifest -> manifest))); // Next, add the new manifests to the map, replacing any that already exist @@ -314,7 +314,7 @@ private void updateCollection(final Message aMessage) throws JsonPro error(aMessage, update.cause(), MessageCodes.MFS_152, update.cause().getMessage()); } }); - } catch (final RuntimeException details) { + } catch (final IllegalStateException details) { LOGGER.error(details, details.getMessage()); aMessage.fail(HTTP.INTERNAL_SERVER_ERROR, details.getMessage()); } From e3ef5771dc7557603fb498696fb381e906d13a58 Mon Sep 17 00:00:00 2001 From: "Kevin S. Clarke" Date: Tue, 12 Sep 2023 15:22:35 -0400 Subject: [PATCH 3/3] Update vert.x version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index df1dab5a..6dabe5f0 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 7.81.0-1ubuntu1.13 - 3.9.14 + 3.9.16 5.7.1 2.0.0 1.7.32