-
Notifications
You must be signed in to change notification settings - Fork 495
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
Go from (User, Permission) to a list of DvObjects #784
Comments
@michbarsinai since I'm working on the SWORD-based Data Deposit API for the current milestone I moved this ticket there too. Please check out dd83960 where I added the method below that SWORD needs to PermissionServiceBean:
I'm calling it like this from
From this list I construct a "Service Document" that shows where the user can deposit data (which is why I'm using Obviously, it's inefficient to iterate through every dataverse like this but I don't know if our permission system provides a better way. |
It doesn't. We could add some auxiliary indices at some point, if we feel the performance needs that. BTW, why not move this method to the PermissionServiceBean? Seems useful.
|
@michbarsinai it's there already. But! I just realized I forgot to put any logic for isPermissionRoot. I tried to add it but then I realized that the root dataverse itself is not permissionRoot:
That can't be right, can it? Shouldn't the root dataverse be permissionRoot:true? |
You can add this as an issue and assign it to me. It's a problem in the Json printer, though. isRoot() is a JPA-style getter, You should use isEffectivelyPermissionRoot() (insert rant about JPA contaminating the pure object model with getters and setters here)
|
@michbarsinai ok, I created #987 and assigned it to you. |
@sekmiller and @scolapasta as we discussed today, it would still be a wonderful thing if we had an efficient method. See also Because we lack this method I have documented "inefficiency" at http://guides.dataverse.org/en/latest/api/sword.html#known-issues |
Removed the following from a code comment. Keeping it here in case its useful: In DVN 3.x we had this: |
Now that we are in production, it's clear that the getDataversesUserHasPermissionOn method in PermissionServiceBean is not performant enough for 2901 dataverses. It's taking over 24 minutes:
@raprasad dropped by and he helped me come up with this, which looks promising:
/cc @rliebz and @axfelix whom I've been chatting with at http://irclog.iq.harvard.edu/dataverse/2015-04-14#i_18331 |
Note the todo that groups are not handled. See also #784
@michbarsinai we are not sure how to add the groups to the list so the commit at 70548db which I'm putting through QA in #2012 does not respect groups. If you have any ideas, please let me know! |
Rather than 24 minutes, with that patch applied in production (again, groups memberships are ignored, unfortunately), I can retrieve the service document in well under a second:
|
We are switching away from the old "admin only" permission checks we were forced to used in the DVN 3.x days when the permission system was less flexible. Now the rule is that if the permission system doesn't prevent you from performing an operation (create dataset, upload file) SWORD won't prevent you either. Two SWORD operations had to be rewritten to support Dataverse 4 permissions. First, retrieval of the Service Document with permissionService.getDataversesUserHasPermissionOn has been changed to pay attention to a user's groups. It's very common for the ":authenticated-users" group to be given a role that should allow SWORD operations, for example. Second, the "list datasets in a dataverse" operation (listCollectionContents) was rewritten to allow anyone with `AddDataset` permission to be able to execute the command to they can see if a dataverse has been published or not but the only datasets that are returned are those for which the user can issue `UpdateDatasetCommand`. In the root dataverse, for example, the user should only see their datasets.
I just opened pull request #3137 as a fix for #1070 and #2495 but I'm passing this issue to QA because my new fix is so closely related to the performance fix I put in for #2012 but now I'm restoring group support (except Shib groups) when retrieving the SWORD Service Document. @michbarsinai I'd be interested to get your feedback on the latest iteration of a method I keep tweaking to go from (User, Permission) to a list of DvObjects (from PermissionServiceBean in pull request #3137):
I'm using a native query which feels a little wrong but we switched to native for performance reasons in 70548db. We lost group support back then and in the pull request above I'm adding it back. I'm moving this issue to QA. From a QA perspective, the question is if the code is performant enough in two cases:
|
Sorry for the late reply - I was snowed under IWPE'16 and DataTags stuff. A few comments:
Other than that, it looks good. I think there's little chance that the identifiers would break the SQL, but if we move to prepared queries (which we totally should) that will no longer be a concern. -- M
|
Leaving in QA but removing my name until I get pull request. |
Tested service doc in test w/ prod data (21s) and prod (16s) from root as admin. Apples to apples comparison on same test box: Though slower, these test cases are likely the worst ones and fall within the 60s apache timeout. We should look at improving these times if possible but do not seem to be a blocker. |
I originally wrote this up as a comment on the pluggable auth design but I'm creating an issue to lay out a concrete use case.
In that comment, I was arguing we need something like this...
List<DvObject> = permissionService.listOfDvObjectsUserHasPermissionOn(user, Permission.EditMetadata);
... and that may be true, but let's be more concrete about an actual need.
In our API docs for the Data Deposit API we shipped in DVN 3.6 we explain how to retrieve SWORD service document and what it is:
The key part of this, of course is "enumerates the dataverses the user can deposit data into". How do we do this in 4.0?
In copying and pasting the Data Deposit API code from DVN 3.6 to 4.0 it became clear to me that we used to have a method for this. I added the following as a todo item:
The point is that I'm acutely aware that what I stubbed out is non-performant and I'd like to do it the right way but I'm not sure how.
For now I'm assigning this to @michbarsinai for review and comment. Yesterday we chatted a bit about how some denormalization in the database could help.
The text was updated successfully, but these errors were encountered: