dataverse
dataverse copied to clipboard
Cannot delete empty subdataverse if it once contained a dataset which had a custom role in its Permissions
Version: 4.20
Guten Tag,
I think that custom roles can prevent deletion of an empty subdataverse. By custom roles I mean roles created as Dataverse admin by following this path: Edit
(on a (sub)dataverse homepage) > Permissions
> Roles
> Add New Role
.
This is what happened:
- I created a subdataverse;
- I added a new dataset in this subdataverse;
- I published it (as admin);
- I created a custom role, "Data Request Manager," who only has the
ManageDatasetPermissions
privilege; - At the level of this dataset, I gave a certain user (not myself, the admin) this custom role, "Data Request Manager";
- I then moved the dataset out of the subdataverse into the root dataverse thanks to the
Move Data
functionality in the admin dashboard; - I then tried to delete the – now empty – subdataverse via the GUI, but I got the following error message:
(Transcript: "Error – This dataverse was not able to be deleted. If you believe this is an error, please contact Team SODHA for assistance.")
I think it's because of the custom role for two reasons:
-
By following the exact same steps described above but by giving a default role (e.g.
Contributor
orCurator
) to the user at step 5 instead of a custom role, I could then successfully delete the subdataverse after I had emptied it; -
The error messages in the server logs seem to go in this direction as well:
[2020-11-04T16:41:00.494+0100] [glassfish 4.1] [WARNING] [] [org.eclipse.persistence.session.file:/usr/local/glassfish4/glassfish/domains/domain1/applications/dataverse-4.20/WEB-INF/classes/_VDCNet-ejbPU] [tid: _ThreadID=26 _ThreadName=http-listener-1(2)] [timeMillis: 1604504460494] [levelValue: 900] [[
Local Exception Stack: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: org.postgresql.util.PSQLException: ERROR: update or delete on table "dataverserole" violates foreign key constraint "fk_roleassignment_role_id" on table "roleassignment" Detail: Key (id)=(10) is still referenced from table "roleassignment". Error Code: 0 Call: DELETE FROM DATAVERSEROLE WHERE (ID = ?) bind => [1 parameter bound] Query: DeleteObjectQuery(DataverseRole{id=10, alias=datamanag}) at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340) […]
Here is the full report:
Could this mean that, in order to delete a subdataverse, one must not just remove subdataverses and datasets within but also custom roles created at this level?
(As far as I could see, custom roles cannot be deleted via the GUI.)
@BPeuch from what I see in https://github.com/IQSS/dataverse/blob/635543096cbc12b23022e94305cb10c465d9b141/src/main/java/edu/harvard/iq/dataverse/engine/command/impl/DeleteDataverseCommand.java#L56-L63 , this behaviour looks like some error that needs debugging.
Assigned roles and the roles themselves should be by DeleteDataverseCommand
when deleting the dataverse via UI or API.
Without looking into the code (except the snippet @poikilotherm posted above), we could / should probably handle this with a cascade, anyway. I can't immediately think of any issues that would present, and it would be cleaner.
(i.e. while it feels the above should work and I'm not sure what the issue is, the fix might just be to use the alternative, cleaner path)
Thanks @BPeuch @scolapasta @poikilotherm. Sounds like we have enough of an idea of the path we want to take here.