Class: SlingUsers::FullGroupCreator

Inherits:
UserManager show all
Defined in:
lib/nakamura/full_group_creator.rb

Overview

a subclass of the library UserManager for creating fully featured groups unlike the skeleton groups that super.create_group creates

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from UserManager

#create_group, #create_test_user, #create_user, #create_user_object, #delete_group, #delete_test_user, #delete_user, #get_group_props, #get_user_props

Constructor Details

#initialize(sling, file_log = nil) ⇒ FullGroupCreator

Returns a new instance of FullGroupCreator.



23
24
25
26
27
# File 'lib/nakamura/full_group_creator.rb', line 23

def initialize(sling, file_log = nil)
  @sling = sling
  super sling
  @file_log = file_log
end

Instance Attribute Details

#file_logObject (readonly)

Returns the value of attribute file_log.



21
22
23
# File 'lib/nakamura/full_group_creator.rb', line 21

def file_log
  @file_log
end

#logObject (readonly)

Returns the value of attribute log.



21
22
23
# File 'lib/nakamura/full_group_creator.rb', line 21

def log
  @log
end

Instance Method Details

#create_full_group(creator, groupname, title = '', description = '') ⇒ Object

this method follows the series of POSTs that the UI makes to create a group with a full set of features including the initial sakai docs for Library and Participants



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/nakamura/full_group_creator.rb', line 31

def create_full_group(creator, groupname, title = '', description = '')
  @sling.switch_user(creator)

  group = Group.new(groupname)

  params = {"data" => JSON.generate({
    "id" => groupname,
    "title" => title,
    "description" => description,
    "joinability" => "yes",
    "visibility" => "public",
    "tags" => ["test-tag1", "test-tag2"],
    "worldTemplate" => "/var/templates/worlds/group/simple-group",
    "_charset_" => "utf-8",
    "usersToAdd" => [{
      "userid" => creator.name,
      "name" => creator.name,
      "firstname" => creator.firstName,
      "role" => "manager",
      "roleString" => "Manager",
      "creator" => "true"
    }]
  })}

  result = @sling.execute_post(@sling.url_for($GROUP_WORLD_URI), params)
  @sling.switch_user(User.admin_user)
  if (result.code.to_i > 299)
    @log.error result.body
    return nil
  end

  # return the group that was created in create_target_group
  return group
end