Skip to content

Commit 8109a34

Browse files
committed
feat(migrate): add migration script to identify datasets with access issues
This script identifies datasets with restricted files lacking terms of access or request access settings. It logs affected datasets with owner details and provides references for further information in the Dataverse 5.11 release notes and issue IQSS#8191. If matching files/datasets are found, the admin needs to take manual action to resolve the situation (we cannot decide here which would be the way to go for any file).
1 parent c6bda30 commit 8109a34

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
-- this query will identify datasets where at least one file does not have either terms of access or
2+
-- request access enabled, and will include owner information for those datasets
3+
4+
DO
5+
$$
6+
DECLARE
7+
affected_dataset RECORD;
8+
row_count INTEGER := 0;
9+
BEGIN
10+
-- Create a temporary table to store the results
11+
CREATE TEMPORARY TABLE IF NOT EXISTS affected_dataset_results (
12+
email TEXT,
13+
name TEXT,
14+
dataset_url TEXT
15+
);
16+
17+
-- Insert the query results into the temporary table
18+
INSERT INTO affected_dataset_results
19+
select au.email,
20+
concat(au.firstname, ' ', au.lastname) as name,
21+
concat('dx.doi.org/' , dvo.authority , '/' , dvo.identifier) as dataset_url
22+
from roleassignment ra, dataverserole dvr,
23+
authenticateduser au, dvobject dvo
24+
where
25+
au.useridentifier = rtrim(substring(ra.assigneeidentifier, 2, 100))
26+
and dvo.id = ra.definitionpoint_id
27+
and
28+
ra.role_id = dvr.id and
29+
dvr.alias in (
30+
'fullContributor',
31+
'dsContributor',
32+
'contributor',
33+
'admin',
34+
'curator'
35+
) and
36+
ra.definitionpoint_id in (
37+
select dvo.id from datasetversion v
38+
join termsofuseandaccess ua on ua.id = v.termsofuseandaccess_id
39+
join filemetadata fm on v.id = fm.datasetversion_id
40+
join datafile f on f.id = fm.datafile_id
41+
join dvobject dvo on v.dataset_id = dvo.id
42+
where ua.fileaccessrequest = false and ua.termsofaccess isnull
43+
and f.restricted = true
44+
);
45+
46+
-- Get the number of affected rows
47+
GET DIAGNOSTICS row_count = ROW_COUNT;
48+
49+
-- Print notice if there are affected datasets
50+
IF row_count > 0 THEN
51+
RAISE NOTICE '--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---';
52+
RAISE NOTICE 'Found % dataset(s) with files lacking proper access settings.', row_count;
53+
RAISE NOTICE 'For details see Dataverse 5.11 release notes and issue 8191.';
54+
55+
-- Loop through affected datasets and print details
56+
FOR affected_dataset IN SELECT * FROM affected_dataset_results LOOP
57+
RAISE NOTICE 'Dataset %, Owner % (%)',
58+
affected_dataset.dataset_url,
59+
affected_dataset.name,
60+
affected_dataset.email;
61+
END LOOP;
62+
63+
RAISE NOTICE '--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---';
64+
END IF;
65+
66+
-- Clean up temporary table
67+
DROP TABLE IF EXISTS affected_dataset_results;
68+
END;
69+
$$;

0 commit comments

Comments
 (0)