-
Notifications
You must be signed in to change notification settings - Fork 12
/
iiMetadata.r
49 lines (43 loc) · 1.7 KB
/
iiMetadata.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# \file iiMetadata.r
# \brief This file contains rules related to metadata to a dataset.
# \author Paul Frederiks
# \author Lazlo Westerhof
# \copyright Copyright (c) 2017-2022, Utrecht University. All rights reserved.
# \license GPLv3, see LICENSE.
# \brief Remove the User AVU's from the irods AVU store.
#
# \param[in] coll Collection to scrub of user metadata
# \param[in] prefix prefix of metadata to remov
#
iiRemoveAVUs(*coll, *prefix) {
#DEBUG writeLine("serverLog", "iiRemoveAVUs: Remove all AVU's from *coll prefixed with *prefix");
msiString2KeyValPair("", *kvp);
*prefix = *prefix ++ "%";
*duplicates = list();
*prev = "";
foreach(*row in SELECT order_asc(META_COLL_ATTR_NAME), META_COLL_ATTR_VALUE WHERE COLL_NAME = *coll AND META_COLL_ATTR_NAME like *prefix) {
*attr = *row.META_COLL_ATTR_NAME;
*val = *row.META_COLL_ATTR_VALUE;
if (*attr == *prev) {
#DEBUG writeLine("serverLog", "iiRemoveAVUs: Duplicate attribute " ++ *attr);
*duplicates = cons((*attr, *val), *duplicates);
} else {
msiAddKeyVal(*kvp, *attr, *val);
#DEBUG writeLine("serverLog", "iiRemoveAVUs: Attribute=\"*attr\", Value=\"*val\" from *coll will be removed");
*prev = *attr;
}
}
msiRemoveKeyValuePairsFromObj(*kvp, *coll, "-C");
foreach(*pair in *duplicates) {
(*attr, *val) = *pair;
#DEBUG writeLine("serverLog", "iiRemoveUserAVUs: Duplicate key Attribute=\"*attr\", Value=\"*val\" from *coll will be removed");
msiString2KeyValPair("", *kvp);
msiAddKeyVal(*kvp, *attr, *val);
msiRemoveKeyValuePairsFromObj(*kvp, *coll, "-C");
}
}
# \brief Perform a vault ingest as rodsadmin.
#
iiAdminVaultIngest() {
msiExecCmd("admin-vaultingest.sh", uuClientFullName, "", "", 0, *out);
}