... |
... |
@@ -1,5 +1,5 @@ |
1 |
1 |
{{groovy}} |
2 |
|
-def mainGroupDoc = xwiki.getDocument("XWiki.XWikiAllGroup") |
|
2 |
+def mainGroupDoc = xwiki.getDocument("XWiki.XWikiAllGroup").getDocument() |
3 |
3 |
def groupClassRef = "XWiki.XWikiGroups" |
4 |
4 |
|
5 |
5 |
def allUsers = xwiki.searchDocuments("where doc.fullName like 'XWiki.%' and doc.fullName != 'XWiki.XWikiAllGroup'") |
... |
... |
@@ -7,8 +7,9 @@ |
7 |
7 |
|
8 |
8 |
allUsers.each { userDocName -> |
9 |
9 |
def userDoc = xwiki.getDocument(userDocName) |
10 |
|
- def existing = mainGroupDoc.getXObjects(groupClassRef) |
11 |
|
- def alreadyMember = existing?.any { it?.getStringValue("member") == userDocName } |
|
10 |
+ def alreadyMember = mainGroupDoc.getXObjects(groupClassRef)?.any { |
|
11 |
+ it?.getStringValue("member") == userDocName |
|
12 |
+ } |
12 |
12 |
|
13 |
13 |
if (!alreadyMember) { |
14 |
14 |
def newObj = mainGroupDoc.newXObject(groupClassRef) |
... |
... |
@@ -18,7 +18,7 @@ |
18 |
18 |
} |
19 |
19 |
|
20 |
20 |
if (added) { |
21 |
|
- xwiki.saveDocument(mainGroupDoc, "Added missing users to XWikiAllGroup: ${added.join(', ')}") |
|
22 |
+ xwiki.saveDocument(mainGroupDoc.newDocument(), "Added missing users to XWikiAllGroup: ${added.join(', ')}") |
22 |
22 |
println "✅ Added users to main wiki: ${added.join(', ')}" |
23 |
23 |
} else { |
24 |
24 |
println "✅ All users are already members of the main wiki." |