Module: OpenTox::Authorization

Defined in:
tbaccount.rb

Overview

ToxBank-investigation specific extension to OpenTox::Authorization in opentox-client

Class Method Summary collapse

Class Method Details

.create_pi_policy(uri) ⇒ Object

Create policy for PI-user (owner of subjectid)


174
175
176
177
178
179
180
# File 'tbaccount.rb', line 174

def self.create_pi_policy uri
  user = get_user
  #piuri = RestClientWrapper.get("#{RDF::TBU.to_s}?username=#{user}", nil, {:Accept => "text/uri-list", :subjectid => subjectid}).sub("\n","")
  piuri =`curl -Lk -X GET -H "Accept:text/uri-list" -H "subjectid:#{RestClientWrapper.subjectid}" #{RDF::TBU.to_s}?username=#{user}`.chomp.sub("\n","")
  piaccount = TBAccount.new(piuri)
  piaccount.send_policy(uri, "all")
end

.reset_policies(uri, type) ⇒ Object

Delete all policies for Users or Groups of an investigation except the policy of the subjectid-owner.


186
187
188
189
190
191
192
# File 'tbaccount.rb', line 186

def self.reset_policies uri, type
  policies = self.list_uri_policies(uri)
  user = get_user
  policies.keep_if{|policy| policy =~ /^tbi-\w+-#{type}-*/ }
  policies.delete_if{|policy| policy =~ /^tbi-#{user}-users-*/ }
  policies.each{|policy| self.delete_policy(policy) }
end