nakamura 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nakamura/full_group_creator.rb +27 -240
- data/lib/nakamura/users.rb +21 -11
- metadata +7 -7
@@ -10,7 +10,7 @@ include SlingInterface
|
|
10
10
|
include SlingUsers
|
11
11
|
include SlingFile
|
12
12
|
|
13
|
-
$FULL_GROUP_URI="
|
13
|
+
$FULL_GROUP_URI="system/world/create"
|
14
14
|
$BATCH_URI = "system/batch"
|
15
15
|
|
16
16
|
module SlingUsers
|
@@ -23,260 +23,47 @@ module SlingUsers
|
|
23
23
|
def initialize(sling, file_log = nil)
|
24
24
|
@sling = sling
|
25
25
|
@sling.log.level = Logger::INFO
|
26
|
-
#@sling.do_login
|
27
|
-
#@user_manager = UserManager.new(@sling)
|
28
26
|
super sling
|
29
27
|
@log.level = Logger::INFO
|
30
28
|
@file_log = file_log
|
31
29
|
end
|
32
30
|
|
33
31
|
# this method follows the series of POSTs that the UI makes to create a group with a
|
34
|
-
# full set of features including the initial sakai
|
35
|
-
def create_full_group(creator_id, groupname, title =
|
32
|
+
# full set of features including the initial sakai docs for Library and Participants
|
33
|
+
def create_full_group(creator_id, groupname, title = '', description = '')
|
36
34
|
creator = User.new(creator_id, "testuser")
|
37
35
|
@sling.switch_user(creator)
|
38
|
-
#POST 1 - creating the manager sub-group
|
39
|
-
create_pseudo_group(groupname + "-manager", groupname + " Manager", description)
|
40
36
|
|
41
|
-
|
42
|
-
create_pseudo_group(groupname + "-member", groupname + " Member", description)
|
43
|
-
|
44
|
-
#POST 3 creating the main group
|
45
|
-
group = create_target_group(groupname, title, description) #POST 3
|
46
|
-
|
47
|
-
update_uri = "/#{$USERMANAGER_URI}group/"
|
48
|
-
|
49
|
-
#POST 4 - updating the group managers
|
50
|
-
batch_post = []
|
51
|
-
batch_post[0] = {"url" => "#{update_uri}#{groupname}-member.update.json", "method" => "POST", "parameters" => {":manager" => "#{groupname}-manager","_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
52
|
-
batch_post[1] = {"url" => "#{update_uri}#{groupname}-manager.update.json", "method" => "POST", "parameters" => {":manager" => "#{groupname}-manager","_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
53
|
-
batch_post[2] = {"url" => "#{update_uri}#{groupname}.update.json", "method" => "POST", "parameters" => {":manager" => "#{groupname}-manager","_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
54
|
-
batch_post_json = JSON.generate batch_post
|
55
|
-
@log.debug("POST 4 - updating the group managersbatch post is: #{batch_post_json}")
|
56
|
-
@file_log.debug("POST 4 - updating the group managersbatch post is: #{batch_post_json}") if (@file_log)
|
57
|
-
parameters = {"requests" => batch_post_json}
|
58
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
59
|
-
@log.info("POST 4 - updating the group managers response code is: #{response.code}")
|
60
|
-
@file_log.info("POST 4 - updating the group managers response code is: #{response.code}") if (@file_log)
|
61
|
-
|
62
|
-
#POST 5 - updating the group members
|
63
|
-
batch_post = []
|
64
|
-
batch_post[0] = {"url" => "#{update_uri}#{groupname}-manager.update.json", "method" => "POST", "parameters" => {":member" => "#{creator_id}", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
65
|
-
batch_post[1] = {"url" => "#{update_uri}#{groupname}.update.json", "method" => "POST", "parameters" => {":member" => "#{groupname}-member", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
66
|
-
batch_post[2] = {"url" => "#{update_uri}#{groupname}.update.json", "method" => "POST", "parameters" => {":member" => "#{groupname}-manager", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
67
|
-
batch_post_json = JSON.generate batch_post
|
68
|
-
@log.debug("POST 5 - updating the group members batch post is: #{batch_post_json}")
|
69
|
-
@file_log.debug("POST 5 - updating the group members batch post is: #{batch_post_json}") if (@file_log)
|
70
|
-
parameters = {"requests" => batch_post_json}
|
71
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
72
|
-
@log.info("POST 5 - updating the group members response code is: #{response.code}")
|
73
|
-
@file_log.info("POST 5 - updating the group members response code is: #{response.code}") if (@file_log)
|
74
|
-
|
75
|
-
#POST 6 - creating test tags
|
76
|
-
batch_post = []
|
77
|
-
batch_post[0] = {"url" => "/tags/test-tag1", "method" => "POST", "parameters" => {"sakai:tag-name" => "test-tag1", "sling:resourceType" => "sakai/tag", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
78
|
-
batch_post[1] = {"url" => "/tags/test-tag2", "method" => "POST", "parameters" => {"sakai:tag-name" => "test-tag2", "sling:resourceType" => "sakai/tag", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
79
|
-
batch_post_json = JSON.generate batch_post
|
80
|
-
@log.debug("POST 6 - creating test tags batch post is: #{batch_post_json}")
|
81
|
-
@file_log.debug("POST 6 - creating test tags batch post is: #{batch_post_json}") if (@file_log)
|
82
|
-
parameters = {"requests" => batch_post_json}
|
83
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
84
|
-
@log.info("POST 6 - creating test tags response code is: #{response.code}")
|
85
|
-
@file_log.info("POST 6 - creating test tags response code is: #{response.code}") if (@file_log)
|
86
|
-
|
87
|
-
#POST 7 - updating group visibility, joinability and permissions
|
88
|
-
batch_post = []
|
89
|
-
batch_post[0] = {"url" => "#{update_uri}#{groupname}.update.html", "method" => "POST", "parameters" => {"rep:group-viewers@Delete" => "", "sakai:group-visible" => "public", "sakai:group-joinable" => "yes", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
90
|
-
batch_post[1] = {"url" => "/~#{groupname}.modifyAce.html", "method" => "POST", "parameters" => {"principalId" => "everyone", "privilege@jcr:read" => "granted", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
91
|
-
batch_post[2] = {"url" => "/~#{groupname}.modifyAce.html", "method" => "POST", "parameters" => {"principalId" => "anonymous", "privilege@jcr:read" => "granted", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
92
|
-
batch_post_json = JSON.generate batch_post
|
93
|
-
@log.debug("POST 7 - updating group visibility, joinability and permissions batch post is: #{batch_post_json}")
|
94
|
-
@file_log.debug("POST 7 - updating group visibility, joinability and permissions batch post is: #{batch_post_json}") if (@file_log)
|
95
|
-
parameters = {"requests" => batch_post_json}
|
96
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
97
|
-
@log.info("POST 7 - updating group visibility, joinability and permissions response code is: #{response.code}")
|
98
|
-
@file_log.info("POST 7 - updating group visibility, joinability and permissions response code is: #{response.code}") if (@file_log)
|
99
|
-
|
100
|
-
#POST 8 - creating initial sakai docs
|
101
|
-
batch_post = []
|
102
|
-
batch_post[0] = {"url" => "/system/pool/createfile", "method" => "POST", "parameters" => {"sakai:pooled-content-file-name" => "Library", "sakai:description" => "", "sakai:permissions" => "public", "sakai:copyright" => "creativecommons", \
|
103
|
-
"structure0" => "{\"library\":{\"_ref\":\"id9867543247\",\"_order\":0,\"_nonEditable\":true,\"_title\":\"Library\",\"main\":{\"_ref\":\"id9867543247\",\"_order\":0,\"_nonEditable\":true,\"_title\":\"Library\"}}}", \
|
104
|
-
"mimeType" => "x-sakai/document","_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
37
|
+
group = Group.new(groupname)
|
105
38
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
elsif ("Participants".eql? content_item_name)
|
130
|
-
participants_doc_hash = doc_hash
|
131
|
-
else
|
132
|
-
@log.warn("could not find sakai doc name to confirm doc_hash")
|
133
|
-
end
|
39
|
+
params = {"data" => JSON.generate({
|
40
|
+
"id" => groupname,
|
41
|
+
"title" => title,
|
42
|
+
"description" => description,
|
43
|
+
"joinability" => "yes",
|
44
|
+
"visibility" => "public",
|
45
|
+
"tags" => ["test-tag1", "test-tag2"],
|
46
|
+
"worldTemplate" => "/var/templates/worlds/group/simple-group",
|
47
|
+
"_charset_" => "utf-8",
|
48
|
+
"usersToAdd" => [{
|
49
|
+
"userid" => creator_id,
|
50
|
+
"name" => creator.name,
|
51
|
+
"firstname" => creator.firstName,
|
52
|
+
"role" => "manager",
|
53
|
+
"roleString" => "Manager",
|
54
|
+
"creator" => "true"
|
55
|
+
}]
|
56
|
+
})}
|
57
|
+
|
58
|
+
result = @sling.execute_post(@sling.url_for($GROUP_URI), params)
|
59
|
+
if (result.code.to_i > 299)
|
60
|
+
@log.error result.body
|
61
|
+
return nil
|
134
62
|
end
|
135
|
-
@log.info("POST 8 - creating initial sakai docs Library sakai doc hash: #{library_doc_hash}, Participants sakai doc hash #{participants_doc_hash}")
|
136
|
-
@file_log.info("POST 8 - creating initial sakai docs Library sakai doc hash: #{library_doc_hash}, Participants sakai doc hash #{participants_doc_hash}") if (@file_log)
|
137
|
-
|
138
|
-
#POST 9 - importing sakai docs content
|
139
|
-
batch_post = []
|
140
|
-
batch_post[0] = {"url" => "/p/#{library_doc_hash}.resource", "method" => "POST", "parameters" => {":operation" => "import", ":contentType" => "json", ":replace" => "true", ":replaceProperties" => "true", \
|
141
|
-
":content" => "{\"id9867543247\":{\"page\":\"<img id='widget_mylibrary_id1367865652332' class='widget_inline' style='display: block; padding: 10px; margin: 4px;' \
|
142
|
-
src='/devwidgets/mylibrary/images/mylibrary.png' data-mce-src='/devwidgets/mylibrary/images/mylibrary.png' data-mce-style='display: block; padding: 10px; margin: 4px;' border='1'><br></p>\"},\
|
143
|
-
\"id1367865652332\":{\"mylibrary\":{\"groupid\":\"#{groupname}\"}}}","_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
144
|
-
|
145
|
-
batch_post[1] = {"url" => "/p/#{participants_doc_hash}.resource", "method" => "POST", "parameters" => {":operation" => "import", ":contentType" => "json", ":replace" => "true", ":replaceProperties" => "true", \
|
146
|
-
":content" => "{\"id6573920372\":{\"page\":\"<img id='widget_participants_id439704665' class='widget_inline' style='display: block; padding: 10px; margin: 4px;' src='/devwidgets/participants/images/participants.png' \
|
147
|
-
data-mce-src='/devwidgets/participants/images/participants.png' data-mce-style='display: block; padding: 10px; margin: 4px;' border='1'><br></p>\"}, \
|
148
|
-
\"id439704665\":{\"participants\":{\"groupid\":\"#{groupname}\"}}}","_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
149
|
-
batch_post_json = JSON.generate batch_post
|
150
|
-
@log.debug("POST 9 - importing sakai docs content batch post is: #{batch_post_json}")
|
151
|
-
@file_log.debug("POST 9 - importing sakai docs content batch post is: #{batch_post_json}") if (@file_log)
|
152
|
-
parameters = {"requests" => batch_post_json}
|
153
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
154
|
-
@log.info("POST 9 - importing sakai docs content response code is: #{response.code}")
|
155
|
-
@file_log.info("POST 9 - importing sakai docs content response code is: #{response.code}") if (@file_log)
|
156
|
-
ruby_body = JSON response.body
|
157
|
-
results = ruby_body["results"]
|
158
|
-
@log.debug("POST 9 - importing sakai docs content results from importing sakai docs post: #{results}")
|
159
|
-
@file_log.debug("POST 9 - importing sakai docs content results from importing sakai docs post: #{results}") if (@file_log)
|
160
|
-
|
161
|
-
#POST 10 - applying the test tags
|
162
|
-
batch_post = []
|
163
|
-
batch_post[0] = {"url" => "/~#{groupname}/public/authprofile", "method" => "POST", "parameters" => {"key" => "/tags/test-tag1", ":operation" => "tag", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
164
|
-
batch_post[1] = {"url" => "/~#{groupname}/public/authprofile", "method" => "POST", "parameters" => {"key" => "/tags/test-tag2", ":operation" => "tag", "_charset_" => "utf-8"}, "_charset_" => "utf-8"}
|
165
|
-
@log.debug("resource batch post is: #{batch_post}")
|
166
|
-
batch_post_json = JSON.generate batch_post
|
167
|
-
@log.debug("POST 10 - applying the test tags batch post is: #{batch_post_json}")
|
168
|
-
@file_log.debug("POST 10 - applying the test tags batch post is: #{batch_post_json}") if (@file_log)
|
169
|
-
parameters = {"requests" => batch_post_json}
|
170
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
171
|
-
@log.info("POST 10 - applying the test tags response code is: #{response.code}")
|
172
|
-
@file_log.info("POST 10 - applying the test tags response code is: #{response.code}") if (@file_log)
|
173
|
-
ruby_body = JSON response.body
|
174
|
-
results = ruby_body["results"]
|
175
|
-
@log.debug("POST 10 - applying the test tags results from :operation => tag post: #{results}")
|
176
|
-
@file_log.debug("POST 10 - applying the test tags results from :operation => tag post: #{results}") if (@file_log)
|
177
|
-
|
178
|
-
|
179
|
-
#POST 11 - setting the global viewers and permissions on the sakai docs
|
180
|
-
batch_post = []
|
181
|
-
batch_post[0] = {"url" => "/p/#{library_doc_hash}.members.html", "method" => "POST", "parameters" => {":viewer" => ["everyone", "anonymous"]}}
|
182
|
-
batch_post[1] = {"url" => "/p/#{library_doc_hash}.modifyAce.html", "method" => "POST", "parameters" => {"principalId" => ["everyone", "anonymous"], "privilege@jcr:read" => "granted"}}
|
183
|
-
batch_post[2] = {"url" => "/p/#{participants_doc_hash}.members.html", "method" => "POST", "parameters" => {":viewer" => ["everyone", "anonymous"]}}
|
184
|
-
batch_post[3] = {"url" => "/p/#{participants_doc_hash}.modifyAce.html", "method" => "POST", "parameters" => {"principalId" => ["everyone", "anonymous"], "privilege@jcr:read" => "granted"}}
|
185
|
-
batch_post_json = JSON.generate batch_post
|
186
|
-
@log.debug("POST 11 - setting the global viewers and permissions on the sakai docs batch post is: #{batch_post_json}")
|
187
|
-
@file_log.debug("POST 11 - setting the global viewers and permissions on the sakai docs batch post is: #{batch_post_json}") if (@file_log)
|
188
|
-
parameters = {"requests" => batch_post_json}
|
189
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
190
|
-
@log.info("POST 11 - setting the global viewers and permissions on the sakai docs response code is: #{response.code}")
|
191
|
-
@file_log.info("POST 11 - setting the global viewers and permissions on the sakai docs response code is: #{response.code}") if (@file_log)
|
192
|
-
ruby_body = JSON response.body
|
193
|
-
results = ruby_body["results"]
|
194
|
-
@log.debug("POST 11 - setting the global viewers and permissions on the sakai docs results from setting permissions on sakai docs #{results}")
|
195
|
-
@file_log.debug("POST 11 - setting the global viewers and permissions on the sakai docs results from setting permissions on sakai docs #{results}") if (@file_log)
|
196
|
-
|
197
|
-
#POST 12 - setting the member viewer and manager viewer for the sakai docs
|
198
|
-
batch_post = []
|
199
|
-
batch_post[0] = {"url" => "/p/#{library_doc_hash}.members.html", "method" => "POST", "parameters" => {":viewer" => "#{groupname}-member", "_charset_" =>"utf-8"},"_charset_" => "utf-8"}
|
200
|
-
batch_post[1] = {"url" => "/p/#{library_doc_hash}.members.html", "method" => "POST", "parameters" => {":manager" => "#{groupname}-manager", "_charset_" =>"utf-8"},"_charset_" => "utf-8"}
|
201
|
-
batch_post[2] = {"url" => "/p/#{participants_doc_hash}.members.html", "method" => "POST", "parameters" => {":viewer" => "#{groupname}-member", "_charset_" =>"utf-8"},"_charset_" => "utf-8"}
|
202
|
-
batch_post[3] = {"url" => "/p/#{participants_doc_hash}.members.html", "method" => "POST", "parameters" => {":manager" => "#{groupname}-manager", "_charset_" =>"utf-8"},"_charset_" => "utf-8"}
|
203
|
-
batch_post_json = JSON.generate batch_post
|
204
|
-
@log.debug("POST 12 - setting the member viewer and manager viewer for the sakai docs batch post is: #{batch_post_json}")
|
205
|
-
@file_log.debug("POST 12 - setting the member viewer and manager viewer for the sakai docs batch post is: #{batch_post_json}") if (@file_log)
|
206
|
-
parameters = {"requests" => batch_post_json}
|
207
|
-
response = @sling.execute_post(@sling.url_for("#{$BATCH_URI}"), parameters)
|
208
|
-
@log.info("POST 12 - setting the member viewer and manager viewer for the sakai docs response code is: #{response.code}")
|
209
|
-
@file_log.info("POST 12 - setting the member viewer and manager viewer for the sakai docs response code is: #{response.code}") if (@file_log)
|
210
|
-
ruby_body = JSON response.body
|
211
|
-
results = response.body["results"]
|
212
|
-
@log.debug("POST 12 - setting the member viewer and manager viewer for the sakai docs results from setting viewer and manager on sakai docs #{results}")
|
213
|
-
@file_log.debug("POST 12 - setting the member viewer and manager viewer for the sakai docs results from setting viewer and manager on sakai docs #{results}") if (@file_log)
|
214
|
-
|
215
|
-
#POST 13 - setting the doc structure on the sakai docs
|
216
|
-
struct0 = {}
|
217
|
-
str = "{\"library\":{\"_title\":\"Library\",\"_order\":0,\"_nonEditable\":true,\"_view\":\"[\\\"everyone\\\",\\\"anonymous\\\",\\\"-member\\\"]\",\"_edit\":\"[\\\"-manager\\\"]\",\"_pid\":\"#{library_doc_hash}\"},\"participants\":{\"_title\":\"Participants\",\"_order\":1,\"_nonEditable\":true,\"_view\":\"[\\\"everyone\\\",\\\"anonymous\\\",\\\"-member\\\"]\",\"_edit\":\"[\\\"-manager\\\"]\",\"_pid\":\"#{participants_doc_hash}\"}}"
|
218
|
-
struct0["structure0"] = str
|
219
|
-
params = {}
|
220
|
-
params[":content"] = JSON.generate struct0
|
221
|
-
params[":contentType"] = "json"
|
222
|
-
params[":operation"] = "import"
|
223
|
-
params[":replace"] = true
|
224
|
-
params[":replaceProperties"] = true
|
225
|
-
params["_charset_"] = "utf-8"
|
226
|
-
@log.debug("POST 13 - setting the doc structure on the sakai docs post params are: " + params.inspect)
|
227
|
-
@file_log.debug("POST 13 - setting the doc structure on the sakai docs post params are: " + params.inspect) if (@file_log)
|
228
|
-
uri = "/~#{groupname}/docstructure"
|
229
|
-
response = @sling.execute_post(@sling.url_for(uri), params)
|
230
|
-
#this is an html response
|
231
|
-
@log.info("POST 13 - setting the doc structure on the sakai docs response code: #{response.code}")
|
232
|
-
@file_log.info("POST 13 - setting the doc structure on the sakai docs response code: #{response.code}") if (@file_log)
|
233
63
|
|
234
64
|
# return the group that was created in create_target_group
|
235
65
|
return group
|
236
66
|
end
|
237
|
-
|
238
|
-
# create the manager and member pseudo subgroups
|
239
|
-
def create_pseudo_group(groupname, title, description)
|
240
|
-
params = { ":name" => groupname }
|
241
|
-
params["sakai:pseudoGroup"] = true
|
242
|
-
params["sakai:excludeSearch"] = true
|
243
|
-
params["sakai:group-description"] = description || ""
|
244
|
-
params["sakai:group-id"] = groupname
|
245
|
-
params["sakai:group-title"] = title
|
246
|
-
response = @sling.execute_post(@sling.url_for($GROUP_URI), params)
|
247
|
-
@log.info("create_pseudo_group() for #{groupname} POST response code: #{response.code}")
|
248
|
-
@log.debug("create_pseudo_group() for #{groupname} POST response body: #{response.body}")
|
249
|
-
@file_log.info("create_pseudo_group() for #{groupname} POST response code: #{response.code}") if (@file_log)
|
250
|
-
@file_log.debug("create_pseudo_group() for #{groupname} POST response body: #{response.body}") if (@file_log)
|
251
|
-
if (response.code.to_i > 299)
|
252
|
-
@log.warn("create_pseudo_group() returned #{response.code} group may already exist?")
|
253
|
-
@file_log.warn("create_pseudo_group() returned #{response.code} group may already exist?") if (@file_log)
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
# create the group itself
|
258
|
-
def create_target_group(groupname, title, description)
|
259
|
-
params = { ":name" => groupname }
|
260
|
-
params["sakai:category"] = "group"
|
261
|
-
params["sakai:group-description"] = description || ""
|
262
|
-
params["sakai:group-id"] = groupname
|
263
|
-
params["sakai:group-title"] = title || ""
|
264
|
-
params["sakai:joinRole"] = "member"
|
265
|
-
params["sakai:roles"] = '[{"id":"member","title":"Member","allowManage":false},{"id":"manager","title":"Manager","allowManage":true}]'
|
266
|
-
params["sakai:templateid"] = "simplegroup"
|
267
|
-
response = @sling.execute_post(@sling.url_for($GROUP_URI), params)
|
268
|
-
@log.info("create_target_group() for #{groupname} POST response code: #{response.code}")
|
269
|
-
@log.debug("create_target_group() for #{groupname} POST response body: #{response.body}")
|
270
|
-
@file_log.info("create_target_group() for #{groupname} POST response code: #{response.code}") if (@file_log)
|
271
|
-
@file_log.debug("create_target_group() for #{groupname} POST response body: #{response.body}") if (@file_log)
|
272
|
-
if (response.code.to_i > 299)
|
273
|
-
@log.warn("create_target_group() returned #{response.code} group may already exist?")
|
274
|
-
@file_log.warn("create_target_group() returned #{response.code} group may already exist?") if (@file_log)
|
275
|
-
end
|
276
|
-
group = Group.new(groupname)
|
277
|
-
return group
|
278
|
-
end
|
279
|
-
|
280
67
|
end
|
281
68
|
|
282
69
|
if ($PROGRAM_NAME.include? 'full_group_creator.rb')
|
data/lib/nakamura/users.rb
CHANGED
@@ -4,7 +4,7 @@ require 'digest/sha1'
|
|
4
4
|
require 'logger'
|
5
5
|
|
6
6
|
$USERMANAGER_URI="system/userManager/"
|
7
|
-
$GROUP_URI="
|
7
|
+
$GROUP_URI="system/world/create"
|
8
8
|
$USER_URI="#{$USERMANAGER_URI}user.create.html"
|
9
9
|
$DEFAULT_PASSWORD="testuser"
|
10
10
|
|
@@ -330,20 +330,30 @@ module SlingUsers
|
|
330
330
|
return create_user_object(user)
|
331
331
|
end
|
332
332
|
|
333
|
-
def create_group(groupname, title =
|
333
|
+
def create_group(groupname, title = '')
|
334
334
|
@log.info "Creating group: #{groupname}"
|
335
335
|
group = Group.new(groupname)
|
336
|
-
params = { "
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
336
|
+
params = { "data" => JSON.generate({
|
337
|
+
'id' => group.name,
|
338
|
+
'title' => title,
|
339
|
+
'description' => '',
|
340
|
+
'visibility' => 'public',
|
341
|
+
'joinability' => 'yes',
|
342
|
+
'tags' => [],
|
343
|
+
'worldTemplate' => '/var/templates/worlds/group/simple-group',
|
344
|
+
'_charset_' => 'utf-8',
|
345
|
+
'usersToAdd' => [{
|
346
|
+
"userid" => "admin",
|
347
|
+
"name" => "Admin",
|
348
|
+
"firstname" => "Admin",
|
349
|
+
"role" => "manager",
|
350
|
+
"roleString" => "Manager",
|
351
|
+
"creator" => "true"
|
352
|
+
}]
|
353
|
+
})}
|
345
354
|
result = @sling.execute_post(@sling.url_for($GROUP_URI), params)
|
346
355
|
if (result.code.to_i > 299)
|
356
|
+
@log.error(result.body)
|
347
357
|
return nil
|
348
358
|
end
|
349
359
|
return group
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nakamura
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-09 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby library for interacting with Sakai Nakamura. Provides convenience
|
15
15
|
methods for adding users and groups and other similar tasks.
|
@@ -18,14 +18,14 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- lib/nakamura/test.rb
|
22
21
|
- lib/nakamura/authz.rb
|
23
|
-
- lib/nakamura/full_group_creator.rb
|
24
|
-
- lib/nakamura/users.rb
|
25
22
|
- lib/nakamura/contacts.rb
|
23
|
+
- lib/nakamura/file.rb
|
24
|
+
- lib/nakamura/full_group_creator.rb
|
26
25
|
- lib/nakamura/message.rb
|
27
26
|
- lib/nakamura/search.rb
|
28
|
-
- lib/nakamura/
|
27
|
+
- lib/nakamura/test.rb
|
28
|
+
- lib/nakamura/users.rb
|
29
29
|
- lib/nakamura.rb
|
30
30
|
homepage: http://sakaiproject.org
|
31
31
|
licenses: []
|
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
requirements:
|
49
49
|
- none
|
50
50
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.8.
|
51
|
+
rubygems_version: 1.8.10
|
52
52
|
signing_key:
|
53
53
|
specification_version: 3
|
54
54
|
summary: Ruby library for interacting with Sakai Nakamura.
|