Skip to content

Commit

Permalink
Additional Item class cast fixes in handle providers
Browse files Browse the repository at this point in the history
DSOs were not properly checked if they were instanceof Item before
attempting the cast in HandleIdentifierProvider and
VersionedHandleIdentifierProviderWithCanonicalHandles
  • Loading branch information
kshepherd committed Oct 2, 2023
1 parent d6e5074 commit 33d2ee9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ public String register(Context context, DSpaceObject dso) {
try {
String id = mint(context, dso);

// move canonical to point the latest version
// Populate metadata
if (dso instanceof Item || dso instanceof Collection || dso instanceof Community) {
Item item = (Item) dso;
populateHandleMetadata(context, item, id);
populateHandleMetadata(context, dso, id);
}

return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ public String register(Context context, DSpaceObject dso) {
String id = mint(context, dso);

// move canonical to point the latest version
if (dso != null && dso.getType() == Constants.ITEM) {
if (dso.getType() == Constants.ITEM && dso instanceof Item) {
Item item = (Item) dso;
VersionHistory history = null;
VersionHistory history;
try {
history = versionHistoryService.findByItem(context, (Item) dso);
history = versionHistoryService.findByItem(context, item);
} catch (SQLException ex) {
throw new RuntimeException("A problem with the database connection occured.", ex);
}
Expand Down

0 comments on commit 33d2ee9

Please sign in to comment.