Skip to content

Ensure links are passed from DSpace object to Item#76

Merged
jonavellecuerdo merged 1 commit into
mainfrom
IN-1759-add-workaround-for-dspace-rest-client
Jun 17, 2026
Merged

Ensure links are passed from DSpace object to Item#76
jonavellecuerdo merged 1 commit into
mainfrom
IN-1759-add-workaround-for-dspace-rest-client

Conversation

@jonavellecuerdo

Copy link
Copy Markdown
Contributor

Purpose and background context

Testing the new digitized theses workflow revealed a bug when instantiating dspace_rest_client.models.Item objects. This ensures that links from the DSpaceObject that is returned when resolving an item handle are passed to the Item object during the 'update' operation.

How can a reviewer manually see the effects of these changes?

The latest code updates are validated through the successful test run of the new digitized theses DSC workflow: see Jira ticket IN-1759

Includes new or updated dependencies?

YES

Changes expectations for external applications?

NO

What are the relevant tickets?

Code review

  • Code review best practices are documented here and you are encouraged to have a constructive dialogue with your reviewers about their preferences and expectations.

Why these changes are being introduced:
* Testing the new digitized theses workflow revealed
a bug when instantiating dspace_rest_client.models.Item objects.
This ensures that links from the DSpaceObject that is returned
when resolving an item handle are passed to the Item object during
the 'update' operation.

How this addresses that need:
* Set item.links to dspace_object.links
* Allow bitstream upload for items without any bitstreams in their 'ORIGINAL' bundle

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-1759
Comment thread submitter/submission.py
Comment on lines +533 to 549
if len(bitstreams) == 1:
original_bitstream = bitstreams[0] # retrieve single bitstream
self._delete_bitstream_dspace8(original_bitstream)
deleted_bitstreams.append(original_bitstream.name)

# note deleted bitstreams
update_messages.append(
"Full replacement of bitstreams for bundle 'ORIGINAL'."
f"The following bitstreams were removed: {deleted_bitstreams}."
)
elif len(bitstreams) == 0:
logger.warning(f"'ORIGINAL' bundle for item '{item.handle}' is empty")
elif len(bitstreams) > 1:
raise errors.ItemError(
f"Error occurred while updating item '{item.handle}, 'ORIGINAL' "
f"bundle {bundle.uuid} contains {len(bitstreams)} bitstream(s)"
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When first writing the code for the "update" operation, it seemed like a good idea to raise an ItemError if there were no bitstreams in the 'ORIGINAL' bundle. However, in the event that there is an item with without a bitstream and we are running DSS to provide a bitstream, it makes sense to proceed with the upload!

@jonavellecuerdo jonavellecuerdo marked this pull request as ready for review June 17, 2026 15:10
@jonavellecuerdo jonavellecuerdo requested a review from a team as a code owner June 17, 2026 15:10
@jonavellecuerdo jonavellecuerdo requested a review from ehanson8 June 17, 2026 15:10

@ehanson8 ehanson8 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jonavellecuerdo jonavellecuerdo merged commit d226bcd into main Jun 17, 2026
6 checks passed
@jonavellecuerdo jonavellecuerdo deleted the IN-1759-add-workaround-for-dspace-rest-client branch June 17, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants