catch exceptions stemming from invalid id's

(cherry picked from commit 848df25984)
This commit is contained in:
nwoodward
2024-01-16 13:28:40 -06:00
committed by github-actions[bot]
parent 8a59c12b35
commit dc57aceeaf
7 changed files with 63 additions and 28 deletions

View File

@@ -562,10 +562,15 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl<Bundle> implement
@Override
public Bundle findByIdOrLegacyId(Context context, String id) throws SQLException {
if (StringUtils.isNumeric(id)) {
return findByLegacyId(context, Integer.parseInt(id));
} else {
return find(context, UUID.fromString(id));
try {
if (StringUtils.isNumeric(id)) {
return findByLegacyId(context, Integer.parseInt(id));
} else {
return find(context, UUID.fromString(id));
}
} catch (IllegalArgumentException e) {
// Not a valid legacy ID or valid UUID
return null;
}
}