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

doesResourceExist function #1608

Merged
merged 3 commits into from Jan 24, 2020
Merged

doesResourceExist function #1608

merged 3 commits into from Jan 24, 2020

Conversation

whikloj
Copy link
Collaborator

@whikloj whikloj commented Jan 22, 2020

JIRA Ticket: https://jira.lyrasis.org/browse/FCREPO-3137

What does this Pull Request do?

Adds a doesResourceExist method to the ResourceFactory

How should this be tested?

Just review, I have not added this to any other code yet.

Interested parties

@fcrepo4/committers

Copy link
Collaborator

@bbpennel bbpennel left a comment

Choose a reason for hiding this comment

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

This service should be helpful, I seem to recall we needed doesResourceExist a few times now.

resource = new ContainerImpl(fedoraId, transaction, psManager, rsFactory);
}
// Commit session so it doesn't hang around.
psSession.commit();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we want to commit the session if the transaction existed before this service was called, otherwise it might prematurely commit changes. Doesn't seem like we have a commitIfShortLived equivalent for PersistentStorageSession, so might have to rely on checking if transaction was null or not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, we should probably commit in a finally block, otherwise we might leak sessions when exceptions occur

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The commit here is on a persistent storage session we just created. Would that not mean nothing else has occurred in this session and should not cause trouble? I'm a little unclear about how the various sessions work so i could be missing something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have moved the commit to a finally block, but as it also can throw an exception I have had to squash and log that exception. Not sure if that is an acceptable trade-off.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since it retrieves a persistent session using the transaction when present, it could grab an ongoing modification session. What you have here looks good to me, it failing to close the temporary session doesn't really impact that rest of the operation, so logging is fine.

@whikloj
Copy link
Collaborator Author

whikloj commented Jan 24, 2020

@bbpennel Moved the single function into ResourceFactory, so you'll probably want to have another look at this.

@whikloj whikloj changed the title GetResource service doesResourceExist function Jan 24, 2020
@bbpennel
Copy link
Collaborator

Its a little hard to judge whether or not GetResourceService would have been helpful without these being used anywhere, but i think this is good now.

@bbpennel bbpennel merged commit 1cdf310 into fcrepo:master Jan 24, 2020
@whikloj whikloj deleted the FCREPO-3137 branch January 24, 2020 17:10
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.

None yet

2 participants