Skip to content

Commit

Permalink
extract context-specific exception handler to calling contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdunnjpl committed Feb 1, 2023
1 parent dcc78bb commit 341e31b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,17 @@ static private Pagination<String> getBundleCollectionLidVids(

// Get the latest versions of LIDs
List<PdsProductIdentifier> productIdentifiers = lidStrings.stream().map(PdsProductIdentifier::fromString).collect(Collectors.toList());
List<PdsLidVid> latestLidVids = LidVidUtils.getLatestLidVidsForProductIdentifiers(
ctlContext,
RequestBuildContextFactory.given(true, "lid", ReferencingLogicTransmuter.Collection.impl().constraints()),
productIdentifiers);
List<String> latestLidVidStrings = latestLidVids.stream().map(PdsLidVid::toString).collect(Collectors.toList());
lidvids.addAll(latestLidVidStrings);
try {
List<PdsLidVid> latestLidVids = LidVidUtils.getLatestLidVidsForProductIdentifiers(
ctlContext,
RequestBuildContextFactory.given(true, "lid", ReferencingLogicTransmuter.Collection.impl().constraints()),
productIdentifiers);
List<String> latestLidVidStrings = latestLidVids.stream().map(PdsLidVid::toString).collect(Collectors.toList());
lidvids.addAll(latestLidVidStrings);
} catch (LidVidNotFoundException e) {
log.error("Database referential integrity error - LID is referenced but does not exist in db: " + e.toString());
}

return lidvids;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ static Pagination<String> parents (ControlContext control, ProductVersionSelecto
bundleLidvids.addAll(LidVidUtils.getAllLidVidsByLids(control, RequestBuildContextFactory.empty(), sortedLidStrings));
}
else {
List<PdsLidVid> latestLidvids = LidVidUtils.getLatestLidVidsForProductIdentifiers(control, RequestBuildContextFactory.empty(), sortedLids);
List<String> latestLidVidStrings = latestLidvids.stream().map(PdsLidVid::toString).collect(Collectors.toList());
bundleLidvids.addAll(latestLidVidStrings);
try {
List<PdsLidVid> latestLidvids = LidVidUtils.getLatestLidVidsForProductIdentifiers(control, RequestBuildContextFactory.empty(), sortedLids);
List<String> latestLidVidStrings = latestLidvids.stream().map(PdsLidVid::toString).collect(Collectors.toList());
bundleLidvids.addAll(latestLidVidStrings);
} catch (LidVidNotFoundException e) {
log.error("Database referential integrity error - LID is referenced but does not exist in db: " + e.toString());
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ static Pagination<String> parents (ControlContext control, ProductVersionSelecto
parents.addAll (LidVidUtils.getAllLidVidsByLids(control, RequestBuildContextFactory.empty(), sortedLidStrings));
}
else{
List<PdsLidVid> latestLidVids = LidVidUtils.getLatestLidVidsForProductIdentifiers(control, RequestBuildContextFactory.empty(), sortedLids);
List<String> latestLidVidStrings = latestLidVids.stream().map(PdsLidVid::toString).collect(Collectors.toList());
parents.addAll(latestLidVidStrings);
try{
List<PdsLidVid> latestLidVids = LidVidUtils.getLatestLidVidsForProductIdentifiers(control, RequestBuildContextFactory.empty(), sortedLids);
List<String> latestLidVidStrings = latestLidVids.stream().map(PdsLidVid::toString).collect(Collectors.toList());
parents.addAll(latestLidVidStrings);
} catch (LidVidNotFoundException e) {
log.error("Database referential integrity error - LID is referenced but does not exist in db: " + e.toString());
}
}

return parents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static List<PdsLidVid> getLatestLidVidsForProductIdentifiers(
PdsLidVid latestLidVid = LidVidUtils.getLatestLidVidByLid(ctlContext, reqContext, id.getLid().toString());
lidVids.add(latestLidVid);
} catch (LidVidNotFoundException e) {
log.error("Database is corrupted. Have reference to LID but cannot find it: " + id.getLid().toString());
throw new LidVidNotFoundException("Could not find any LIDVIDs for LID " + id.getLid().toString());
}
}

Expand Down

0 comments on commit 341e31b

Please sign in to comment.