dataverse icon indicating copy to clipboard operation
dataverse copied to clipboard

Cannot delete empty subdataverse if it once contained a dataset which had a custom role in its Permissions

Open BPeuch opened this issue 4 years ago • 3 comments

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:

  1. I created a subdataverse;
  2. I added a new dataset in this subdataverse;
  3. I published it (as admin);
  4. I created a custom role, "Data Request Manager," who only has the ManageDatasetPermissions privilege;
  5. At the level of this dataset, I gave a certain user (not myself, the admin) this custom role, "Data Request Manager";
  6. I then moved the dataset out of the subdataverse into the root dataverse thanks to the Move Data functionality in the admin dashboard;
  7. I then tried to delete the – now empty – subdataverse via the GUI, but I got the following error message:

errordel

(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:

  1. By following the exact same steps described above but by giving a default role (e.g. Contributor or Curator) to the user at step 5 instead of a custom role, I could then successfully delete the subdataverse after I had emptied it;

  2. 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:

error-cust-role-del-subd.log

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 avatar Nov 04 '20 16:11 BPeuch

@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.

poikilotherm avatar Nov 05 '20 12:11 poikilotherm

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)

scolapasta avatar Nov 05 '20 14:11 scolapasta

Thanks @BPeuch @scolapasta @poikilotherm. Sounds like we have enough of an idea of the path we want to take here.

djbrooke avatar Nov 05 '20 14:11 djbrooke