Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SERV-910] Add a catch for duplicate IDs in collection doc #230

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 7 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,22 @@
<organization>UCLA Library</organization>
<organizationUrl>http://github.com/uclalibrary</organizationUrl>
<timezone>America/New_York</timezone>
<roles>
<role>Lead Developer</role>
</roles>
</developer>
<developer>
<id>hardyoyo</id>
<name>Hardy Pottinger</name>
<email>hardy.pottinger@gmail.com</email>
<timezone>America/Chicago</timezone>
</developer>
<developer>
<id>cachemeoutside</id>
<name>Anthony Vuong</name>
<email>avuong@cachemeoutside.io</email>
<organization>UCLA Library</organization>
<organizationUrl>http://github.com/uclalibrary</organizationUrl>
<timezone>America/Los_Angeles</timezone>
</developer>
<developer>
<id>markmatney</id>
<name>Mark A. Matney, Jr.</name>
<email>mmatney@library.ucla.edu</email>
<organization>UCLA Library</organization>
<organizationUrl>http://github.com/uclalibrary</organizationUrl>
<timezone>America/Los_Angeles</timezone>
</developer>
<developer>
<id>DRickard</id>
<name>David Rickard</name>
<email>drickard1967@library.ucla.edu</email>
<organization>UCLA Library</organization>
<organizationUrl>http://github.com/uclalibrary</organizationUrl>
<timezone>America/Los_Angeles</timezone>
</developer>
<!-- Also https://github.com/UCLALibrary/fester/graphs/contributors -->
</developers>

<properties>
<!-- Docker image dependencies -->
<ubuntu.tag>22.04</ubuntu.tag>
<jdk.version>17.0.4+8-1~22.04</jdk.version>
<jdk.version>17.0.8.1+1~us1-0ubuntu1~22.04</jdk.version>
<python3.version>3.10.6-1~22.04</python3.version>
<curl.version>7.81.0-1ubuntu1.6</curl.version>
<curl.version>7.81.0-1ubuntu1.13</curl.version>

<!-- Application dependencies -->
<vertx.version>3.9.14</vertx.version>
<vertx.version>3.9.16</vertx.version>
<opencsv.version>5.7.1</opencsv.version>
<moirai.version>2.0.0</moirai.version>
<slf4j.ext.version>1.7.32</slf4j.ext.version>
Expand Down
2 changes: 1 addition & 1 deletion src/main/docker/scripts/show_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ print_line() {
}

declare -a DEPENDENCIES=(
"openjdk-11-jre-headless"
"openjdk-17-jre-headless"
"python3"
"curl"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,31 +286,38 @@ private void updateCollection(final Message<JsonObject> aMessage) throws JsonPro

// First, add the old manifests to the map
final Stream<Collection.Manifest> 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 IllegalStateException 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 IllegalStateException details) {
LOGGER.error(details, details.getMessage());
aMessage.fail(HTTP.INTERNAL_SERVER_ERROR, details.getMessage());
}
}

/**
Expand Down Expand Up @@ -355,11 +362,11 @@ private void updateWork(final Message<JsonObject> 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));
Expand Down Expand Up @@ -456,10 +463,10 @@ private Canvas[] createCanvases(final CsvHeaders aCsvHeaders, final List<String[
final String pageURI = StringUtils.format(SIMPLE_URI, aImageHost, encodedPageID);
final String contentURI = StringUtils.format(ANNOTATION_URI, Constants.URL_PLACEHOLDER, aWorkID, idPart);

String resourceURI = StringUtils.format(Constants.SAMPLE_URI_TEMPLATE, pageURI,
Constants.DEFAULT_SAMPLE_SIZE);
ImageResource imageResource = new ImageResource(resourceURI,
new ImageInfoService(APIComplianceLevel.TWO, pageURI));
String resourceURI =
StringUtils.format(Constants.SAMPLE_URI_TEMPLATE, pageURI, Constants.DEFAULT_SAMPLE_SIZE);
ImageResource imageResource =
new ImageResource(resourceURI, new ImageInfoService(APIComplianceLevel.TWO, pageURI));
ImageContent imageContent;
Canvas canvas;

Expand Down
Loading