opentox-client 0.0.1pre → 0.0.2pre

Sign up to get free protection for your applications and to get access to all the features.
data/lib/policy.rb CHANGED
@@ -1,28 +1,29 @@
1
1
  module OpenTox
2
2
  require "rexml/document"
3
3
 
4
- #Module for policy-processing
4
+ #Module for policy-processing
5
5
  # @see also http://www.opentox.org/dev/apis/api-1.2/AA for opentox API specs
6
6
  # Class Policies corresponds to <policies> container of an xml-policy-fle
7
- class Policies
8
-
9
- attr_accessor :name, :policies
10
-
7
+ class Policies
8
+
9
+ #Hash for policy objects see {Policy Policy}
10
+ attr_accessor :policies, :name
11
+
11
12
  def initialize()
12
13
  @policies = {}
13
14
  end
14
-
15
+
15
16
  #create new policy instance with name
16
17
  # @param [String]name of the policy
17
18
  def new_policy(name)
18
19
  @policies[name] = Policy.new(name)
19
20
  end
20
-
21
+
21
22
  #drop a specific policy in a policies instance
22
23
  # @param [String]name of the policy
23
24
  # @return [Boolean]
24
25
  def drop_policy(name)
25
- return true if @policies.delete(name)
26
+ return true if @policies.delete(name)
26
27
  end
27
28
 
28
29
  #drop all policies in a policies instance
@@ -32,58 +33,63 @@ module OpenTox
32
33
  end
33
34
  return true
34
35
  end
35
-
36
+
36
37
  # @return [Array] set of arrays affected by policies
37
38
  def uris
38
- @policies.collect{ |k,v| v.uris }.flatten.uniq
39
+ @policies.collect{ |k,v| v.uri }.flatten.uniq
39
40
  end
40
41
 
41
- #drop all policies in a policies instance
42
+ #list all policy names in a policies instance
43
+ # @return [Array]
42
44
  def names
43
45
  out = []
44
46
  @policies.each do |name, policy|
45
- out << name
47
+ out << name
46
48
  end
47
49
  return out
48
50
  end
49
51
 
50
- #loads a default policy template in policies instance
51
- def load_default_policy(user, uri, group="member")
52
+ # Loads a default policy template in a policies instance
53
+ # @param [String]user username in LDAP string of user policy: 'uid=<user>,ou=people,dc=opentox,dc=org'
54
+ # @param [String]uri URI
55
+ # @param [String]group groupname in LDAP string of group policy: 'cn=<group>,ou=groups,dc=opentox,dc=org'
56
+ def load_default_policy(user, uri, group="member")
52
57
  template = case user
53
58
  when "guest", "anonymous" then "default_guest_policy"
54
- else "default_policy"
59
+ else "default_policy"
55
60
  end
56
61
  xml = File.read(File.join(File.dirname(__FILE__), "templates/#{template}.xml"))
57
62
  self.load_xml(xml)
58
63
  datestring = Time.now.strftime("%Y-%m-%d-%H-%M-%S-x") + rand(1000).to_s
59
-
64
+
60
65
  @policies["policy_user"].name = "policy_user_#{user}_#{datestring}"
61
- @policies["policy_user"].rules["rule_user"].uri = uri
62
- @policies["policy_user"].rules["rule_user"].name = "rule_user_#{user}_#{datestring}"
63
- @policies["policy_user"].subjects["subject_user"].name = "subject_user_#{user}_#{datestring}"
64
- @policies["policy_user"].subjects["subject_user"].value = "uid=#{user},ou=people,dc=opentox,dc=org"
66
+ @policies["policy_user"].rule.uri = uri
67
+ @policies["policy_user"].rule.name = "rule_user_#{user}_#{datestring}"
68
+ @policies["policy_user"].subject.name = "subject_user_#{user}_#{datestring}"
69
+ @policies["policy_user"].subject.value = "uid=#{user},ou=people,dc=opentox,dc=org"
65
70
  @policies["policy_user"].subject_group = "subjects_user_#{user}_#{datestring}"
66
-
67
- @policies["policy_group"].name = "policy_group_#{group}_#{datestring}"
68
- @policies["policy_group"].rules["rule_group"].uri = uri
69
- @policies["policy_group"].rules["rule_group"].name = "rule_group_#{group}_#{datestring}"
70
- @policies["policy_group"].subjects["subject_group"].name = "subject_group_#{group}_#{datestring}"
71
- @policies["policy_group"].subjects["subject_group"].value = "cn=#{group},ou=groups,dc=opentox,dc=org"
72
- @policies["policy_group"].subject_group = "subjects_#{group}_#{datestring}"
71
+
72
+ @policies["policy_group"].name = "policy_group_#{group}_#{datestring}"
73
+ @policies["policy_group"].rule.uri = uri
74
+ @policies["policy_group"].rule.name = "rule_group_#{group}_#{datestring}"
75
+ @policies["policy_group"].subject.name = "subject_group_#{group}_#{datestring}"
76
+ @policies["policy_group"].subject.value = "cn=#{group},ou=groups,dc=opentox,dc=org"
77
+ @policies["policy_group"].subject_group = "subjects_#{group}_#{datestring}"
73
78
  return true
74
- end
79
+ end
75
80
 
76
- #loads a xml template
81
+ #loads a xml template
77
82
  def load_xml(xml)
78
83
  rexml = REXML::Document.new(xml)
79
84
  rexml.elements.each("Policies/Policy") do |pol| #Policies
80
85
  policy_name = pol.attributes["name"]
81
86
  new_policy(policy_name)
82
- #@policies[policy_name] = Policy.new(policy_name)
87
+ #@policies[policy_name] = Policy.new(policy_name)
83
88
  rexml.elements.each("Policies/Policy[@name='#{policy_name}']/Rule") do |r| #Rules
84
- rule_name = r.attributes["name"]
89
+ rule_name = r.attributes["name"]
85
90
  uri = rexml.elements["Policies/Policy[@name='#{policy_name}']/Rule[@name='#{rule_name}']/ResourceName"].attributes["name"]
86
- @policies[policy_name].rules[rule_name] = @policies[policy_name].new_rule(rule_name, uri)
91
+ @policies[policy_name].rule.name = rule_name
92
+ @policies[policy_name].uri = uri
87
93
  rexml.elements.each("Policies/Policy[@name='#{policy_name}']/Rule[@name='#{rule_name}']/AttributeValuePair") do |attribute_pairs|
88
94
  action=nil; value=nil;
89
95
  attribute_pairs.each_element do |elem|
@@ -93,163 +99,234 @@ module OpenTox
93
99
  if action and value
94
100
  case action
95
101
  when "GET"
96
- @policies[policy_name].rules[rule_name].get = value
102
+ @policies[policy_name].rule.get = value
97
103
  when "POST"
98
- @policies[policy_name].rules[rule_name].post = value
104
+ @policies[policy_name].rule.post = value
99
105
  when "PUT"
100
- @policies[policy_name].rules[rule_name].put = value
101
- when "DELETE"
102
- @policies[policy_name].rules[rule_name].delete = value
106
+ @policies[policy_name].rule.put = value
107
+ when "DELETE"
108
+ @policies[policy_name].rule.delete = value
103
109
  end
104
110
  end
105
- end
111
+ end
106
112
  end
107
113
  rexml.elements.each("Policies/Policy[@name='#{policy_name}']/Subjects") do |subjects| #Subjects
108
- @policies[policy_name].subject_group = subjects.attributes["name"]
114
+ @policies[policy_name].subject_group = subjects.attributes["name"]
109
115
  rexml.elements.each("Policies/Policy[@name='#{policy_name}']/Subjects[@name='#{@policies[policy_name].subject_group}']/Subject") do |s| #Subject
110
116
  subject_name = s.attributes["name"]
111
117
  subject_type = s.attributes["type"]
112
118
  subject_value = rexml.elements["Policies/Policy[@name='#{policy_name}']/Subjects[@name='#{@policies[policy_name].subject_group}']/Subject[@name='#{subject_name}']/AttributeValuePair/Value"].text
113
- @policies[policy_name].new_subject(subject_name, subject_type, subject_value) if subject_name and subject_type and subject_value
119
+ if subject_name and subject_type and subject_value
120
+ @policies[policy_name].subject.name = subject_name
121
+ @policies[policy_name].type = subject_type
122
+ @policies[policy_name].value = subject_value
123
+ end
114
124
  end
115
- end
116
- end
125
+ end
126
+ end
117
127
  end
118
-
128
+
119
129
  #generates xml from policies instance
120
130
  def to_xml
121
131
  doc = REXML::Document.new()
122
132
  doc << REXML::DocType.new("Policies", "PUBLIC \"-//Sun Java System Access Manager7.1 2006Q3\n Admin CLI DTD//EN\" \"jar://com/sun/identity/policy/policyAdmin.dtd\"")
123
133
  doc.add_element(REXML::Element.new("Policies"))
124
-
134
+
125
135
  @policies.each do |name, pol|
126
136
  policy = REXML::Element.new("Policy")
127
137
  policy.attributes["name"] = pol.name
128
138
  policy.attributes["referralPolicy"] = false
129
139
  policy.attributes["active"] = true
130
- @policies[name].rules.each do |r,rl|
131
- rule = @policies[name].rules[r]
132
- out_rule = REXML::Element.new("Rule")
133
- out_rule.attributes["name"] = rule.name
134
- servicename = REXML::Element.new("ServiceName")
135
- servicename.attributes["name"]="iPlanetAMWebAgentService"
136
- out_rule.add_element(servicename)
137
- rescourcename = REXML::Element.new("ResourceName")
138
- rescourcename.attributes["name"] = rule.uri
139
- out_rule.add_element(rescourcename)
140
-
141
- ["get","post","delete","put"].each do |act|
142
- if rule.method(act).call
143
- attribute = REXML::Element.new("Attribute")
144
- attribute.attributes["name"] = act.upcase
145
- attributevaluepair = REXML::Element.new("AttributeValuePair")
146
- attributevaluepair.add_element(attribute)
147
- attributevalue = REXML::Element.new("Value")
148
- attributevaluepair.add_element(attributevalue)
149
- attributevalue.add_text REXML::Text.new(rule.method(act).call)
150
- out_rule.add_element(attributevaluepair)
151
-
152
- end
140
+ rule = @policies[name].rule
141
+ out_rule = REXML::Element.new("Rule")
142
+ out_rule.attributes["name"] = rule.name
143
+ servicename = REXML::Element.new("ServiceName")
144
+ servicename.attributes["name"]="iPlanetAMWebAgentService"
145
+ out_rule.add_element(servicename)
146
+ rescourcename = REXML::Element.new("ResourceName")
147
+ rescourcename.attributes["name"] = rule.uri
148
+ out_rule.add_element(rescourcename)
149
+
150
+ ["get","post","delete","put"].each do |act|
151
+ if rule.method(act).call
152
+ attribute = REXML::Element.new("Attribute")
153
+ attribute.attributes["name"] = act.upcase
154
+ attributevaluepair = REXML::Element.new("AttributeValuePair")
155
+ attributevaluepair.add_element(attribute)
156
+ attributevalue = REXML::Element.new("Value")
157
+ attributevaluepair.add_element(attributevalue)
158
+ attributevalue.add_text REXML::Text.new(rule.method(act).call)
159
+ out_rule.add_element(attributevaluepair)
153
160
  end
154
- policy.add_element(out_rule)
155
- end
161
+ end
162
+ policy.add_element(out_rule)
156
163
 
157
164
  subjects = REXML::Element.new("Subjects")
158
165
  subjects.attributes["name"] = pol.subject_group
159
166
  subjects.attributes["description"] = ""
160
- @policies[name].subjects.each do |subj, subjs|
161
- subject = REXML::Element.new("Subject")
162
- subject.attributes["name"] = pol.subjects[subj].name
163
- subject.attributes["type"] = pol.subjects[subj].type
164
- subject.attributes["includeType"] = "inclusive"
165
- attributevaluepair = REXML::Element.new("AttributeValuePair")
166
- attribute = REXML::Element.new("Attribute")
167
- attribute.attributes["name"] = "Values"
168
- attributevaluepair.add_element(attribute)
169
- attributevalue = REXML::Element.new("Value")
170
- attributevalue.add_text REXML::Text.new(pol.subjects[subj].value)
171
- attributevaluepair.add_element(attributevalue)
172
- subject.add_element(attributevaluepair)
173
- subjects.add_element(subject)
174
- end
167
+ subj = @policies[name].subject.name
168
+ subject = REXML::Element.new("Subject")
169
+ subject.attributes["name"] = pol.subject.name
170
+ subject.attributes["type"] = pol.subject.type
171
+ subject.attributes["includeType"] = "inclusive"
172
+ attributevaluepair = REXML::Element.new("AttributeValuePair")
173
+ attribute = REXML::Element.new("Attribute")
174
+ attribute.attributes["name"] = "Values"
175
+ attributevaluepair.add_element(attribute)
176
+ attributevalue = REXML::Element.new("Value")
177
+ attributevalue.add_text REXML::Text.new(pol.subject.value)
178
+ attributevaluepair.add_element(attributevalue)
179
+ subject.add_element(attributevaluepair)
180
+ subjects.add_element(subject)
175
181
  policy.add_element(subjects)
176
182
  doc.root.add_element(policy)
177
- end
183
+ end
178
184
  out = ""
179
185
  doc.write(out, 2)
180
186
  return out
181
- end
182
-
187
+ end
188
+
183
189
  end
184
-
185
- #single policy in a policies instance
186
- class Policy
187
-
188
- attr_accessor :name, :rules, :subject_group, :subjects
189
-
190
+
191
+ #single policy in a {Policies Policies} instance
192
+ class Policy
193
+
194
+ attr_accessor :name, :rule, :subject_group, :subject, :value, :type, :uri, :group, :user
195
+
190
196
  def initialize(name)
191
197
  @name = name
192
- @rules = {}
193
- @subject_group = ""
194
- @subjects = {}
198
+ @rule = Rule.new("#{name}_rule", nil)
199
+ @subject_group = "#{name}_subjects"
200
+ @subject = Subject.new("#{name}_subject", nil, nil)
195
201
  end
196
-
197
- #create a new rule instance for the policy
198
- def new_rule(name, uri)
199
- @rules[name] = Rule.new(name, uri)
202
+
203
+ # Subject type LDAPUsers or LDAPGroups
204
+ def type
205
+ @subject.type
200
206
  end
201
-
202
- #create a new subject instance for the policy
203
- def new_subject(name, type, value)
204
- @subjects[name] = Subject.new(name, type, value)
207
+
208
+ # Set subject type <LDAPUsers, LDAPGroups>
209
+ # @param [String],type
210
+ def type=(type)
211
+ @subject.type = type
205
212
  end
206
-
207
- # @return [Array] set of uris affected by policy
208
- def uris
209
- @rules.collect{ |k,v| v.uri }.uniq
213
+
214
+ # returns LDAP Distinguished Name (DN) e.g. uid=username,ou=people,dc=opentox,dc=org or cn=membergroup,ou=groups,dc=opentox,dc=org
215
+ def value
216
+ @subject.value
217
+ end
218
+
219
+ # sets LDAP Distinguished Name (DN) for policy e.g.
220
+ # @param [String],LDAPString
221
+ def value=(value)
222
+ @subject.value = value
223
+ end
224
+
225
+ # uri affected by policy
226
+ # @return uri affected by policy
227
+ def uri
228
+ @rule.uri
229
+ end
230
+
231
+ # sets uri affected by policy
232
+ # @param [String] set URI
233
+ def uri=(uri)
234
+ @rule.uri = uri
235
+ end
236
+
237
+ # Get the groupname from within the LDAP Distinguished Name (DN)
238
+ def group
239
+ return false if !value && type != "LDAPGroups"
240
+ value.split(",").each{|part| return part.gsub("cn=","") if part.match("cn=")}
241
+ end
242
+
243
+ # Get the username from within the LDAP Distinguished Name (DN)
244
+ def user
245
+ return false if !value && type != "LDAPUsers"
246
+ value.split(",").each{|part| return part.gsub("uid=","") if part.match("uid=")}
247
+ end
248
+
249
+ # helper method sets value and type to opentox LDAP Distinguished Name (DN) of a user
250
+ def set_ot_user(username)
251
+ self.value = "uid=#{username},ou=people,dc=opentox,dc=org"
252
+ self.type = "LDAPUsers"
253
+ true
254
+ end
255
+
256
+ def set_ot_group(groupname)
257
+ self.value = "cn=#{groupname},ou=groups,dc=opentox,dc=org"
258
+ self.type = "LDAPGroups"
259
+ true
210
260
  end
211
-
261
+
212
262
  #rule inside a policy
213
263
  class Rule
214
-
215
- attr_accessor :name, :uri, :get, :post, :put, :delete
216
-
264
+
265
+ attr_accessor :name, :uri, :get, :post, :put, :delete, :read, :readwrite
266
+
217
267
  def initialize(name, uri)
218
268
  @name = name
219
269
  @uri = uri
220
270
  end
221
-
222
- def rename(new, old)
223
- self[new] = self.delete(old)
224
- self[new].name = new
225
- end
226
-
271
+
272
+ #Set Rule attribute for request-method GET
273
+ # @param [String]value (allow,deny,nil)
227
274
  def get=(value)
228
275
  @get = check_value(value, @get)
229
276
  end
230
-
277
+
278
+ #Set Rule attribute for request-method POST
279
+ # @param [String]value (allow,deny,nil)
231
280
  def post=(value)
232
281
  @post = check_value(value, @post)
233
282
  end
234
-
283
+
284
+ #Set Rule attribute for request-method DELETE
285
+ # @param [String]value (allow,deny,nil)
235
286
  def delete=(value)
236
287
  @delete = check_value(value, @delete)
237
288
  end
238
-
289
+
290
+ #Set Rule attribute for request-method PUT
291
+ # @param [String]value (allow,deny,nil)
239
292
  def put=(value)
240
293
  @put = check_value(value, @put)
241
294
  end
242
-
295
+
296
+ def read
297
+ return true if @get == "allow" && (@put == "deny" || !@put) && (@post == "deny" || !@post)
298
+ end
299
+
300
+ def readwrite
301
+ return true if @get == "allow" && @put == "allow" && @post == "allow"
302
+ end
303
+
304
+ def read=(value)
305
+ if value
306
+ @get = "allow"; @put = nil; @post = nil
307
+ else
308
+ @get = nil; @put = nil; @post = nil
309
+ end
310
+ end
311
+
312
+ def readwrite=(value)
313
+ if value
314
+ @get = "allow"; @put = "allow"; @post = "allow"
315
+ else
316
+ @get = nil; @put = nil; @post = nil
317
+ end
318
+ end
319
+
243
320
  private
244
- #checks if value is allow or deny. returns old value if not valid.
321
+ #checks if value is allow, deny or nil. returns old value if not valid.
245
322
  def check_value(new_value, old_value)
246
- return (new_value=="allow" || new_value=="deny" || new_value==nil) ? new_value : old_value
323
+ return (new_value=="allow" || new_value=="deny" || new_value==nil) ? new_value : old_value
247
324
  end
248
325
  end
249
-
326
+
250
327
  class Subject
251
328
 
252
- attr_accessor :name, :type, :value
329
+ attr_accessor :name, :type, :value
253
330
 
254
331
  def initialize(name, type, value)
255
332
  @name = name
@@ -258,4 +335,4 @@ module OpenTox
258
335
  end
259
336
  end
260
337
  end
261
- end
338
+ end
@@ -16,12 +16,16 @@ module OpenTox
16
16
  define_singleton_method method do |uri,payload={},headers={}|
17
17
 
18
18
  # check input
19
+ @subjectid = headers[:subjectid] ? headers[:subjectid] : nil
19
20
  bad_request_error "Invalid URI: '#{uri}'" unless URI.valid? uri
20
- not_found_error "URI '#{uri}' not found." unless URI.accessible? uri
21
+ not_found_error "URI '#{uri}' not found." unless URI.accessible?(uri, @subjectid) unless URI.ssl?(uri)
21
22
  bad_request_error "Headers are not a hash: #{headers.inspect}" unless headers==nil or headers.is_a?(Hash)
22
23
  # make sure that no header parameters are set in the payload
23
24
  [:accept,:content_type,:subjectid].each do |header|
24
- bad_request_error "#{header} should be submitted in the headers" if payload and payload.is_a?(Hash) and payload[header]
25
+ if defined? $aa || URI(uri).host == URI($aa[:uri]).host
26
+ else
27
+ bad_request_error "#{header} should be submitted in the headers" if payload and payload.is_a?(Hash) and payload[header]
28
+ end
25
29
  end
26
30
 
27
31
  # create request
@@ -33,13 +37,16 @@ module OpenTox
33
37
  headers.each{ |k,v| headers.delete(k) if v==nil } if headers #remove keys with empty values, as this can cause problems
34
38
  args[:headers] = headers
35
39
 
36
- # perform request
37
40
  @request = RestClient::Request.new(args)
38
- # do not throw RestClient exceptions in order to create a @response object (needed for error reports) in every case
39
- @response = @request.execute { |response, request, result| return response }
40
41
  # ignore error codes from Task services (may return error codes >= 400 according to API, which causes exceptions in RestClient and RDF::Reader)
41
- raise OpenTox::RestCallError.new @request, @response, "Response code is #{@response.code}." unless @response.code < 400 or URI.task? uri
42
- @response
42
+ @response = @request.execute do |response, request, result|
43
+ if [301, 302, 307].include? response.code and request.method == :get
44
+ response.follow_redirection(request, result)
45
+ else
46
+ raise OpenTox::RestCallError.new response.to_s, request, uri unless response.code < 400 or URI.task? uri
47
+ response
48
+ end
49
+ end
43
50
  end
44
51
  end
45
52
 
data/lib/task.rb CHANGED
@@ -1,4 +1,3 @@
1
- require File.join(File.dirname(__FILE__),'error')
2
1
  DEFAULT_TASK_MAX_DURATION = 36000
3
2
  module OpenTox
4
3
 
@@ -9,17 +8,14 @@ module OpenTox
9
8
 
10
9
  def self.create service_uri, params={}
11
10
 
12
- # TODO set/enforce request uri
13
- # TODO: run observer in same process?
14
11
  task = Task.new RestClientWrapper.post(service_uri,params).chomp
15
12
  pid = fork do
16
13
  begin
17
14
  result_uri = yield
18
15
  task.completed result_uri
19
16
  rescue
20
- RestClientWrapper.put(File.join(task.uri,'Error'),{:errorReport => $!.report.to_yaml})
17
+ RestClientWrapper.put(File.join(task.uri,'Error'),{:errorReport => $!.report.to_yaml}) if $!.respond_to? :report
21
18
  task.kill
22
- #raise $!
23
19
  end
24
20
  end
25
21
  Process.detach(pid)
@@ -43,7 +39,7 @@ module OpenTox
43
39
  def kill
44
40
  Process.kill(9,@pid)
45
41
  Process.kill(9,@observer_pid)
46
- rescue # no need to raise an exeption if processes are not running
42
+ rescue # no need to raise an exeption if processes are not running
47
43
  end
48
44
 
49
45
  def description
@@ -62,23 +58,27 @@ module OpenTox
62
58
  end
63
59
 
64
60
  def completed(uri)
65
- not_found_error "Result URI \"#{uri}\" does not exist." unless URI.accessible? uri
61
+ #not_found_error "Result URI \"#{uri}\" does not exist." unless URI.accessible? uri
66
62
  RestClientWrapper.put(File.join(@uri,'Completed'),{:resultURI => uri})
67
63
  end
68
64
 
69
65
  # waits for a task, unless time exceeds or state is no longer running
70
66
  # @param [optional,Numeric] dur seconds pausing before checking again for completion
71
- def wait(dur=0.3)
72
- due_to_time = Time.new + DEFAULT_TASK_MAX_DURATION
73
- while running?
67
+ # TODO: add waiting task
68
+ def wait
69
+ start_time = Time.new
70
+ due_to_time = start_time + DEFAULT_TASK_MAX_DURATION
71
+ dur = 0
72
+ while running?
74
73
  sleep dur
74
+ dur = [[(Time.new - start_time)/20.0,0.3].max,300.0].min
75
75
  time_out_error "max wait time exceeded ("+DEFAULT_TASK_MAX_DURATION.to_s+"sec), task: '"+@uri.to_s+"'" if (Time.new > due_to_time)
76
76
  end
77
77
  end
78
78
 
79
79
  end
80
80
 
81
- # get only header for ststus requests
81
+ # get only header for status requests
82
82
  def running?
83
83
  RestClientWrapper.head(@uri).code == 202
84
84
  end
@@ -96,28 +96,19 @@ module OpenTox
96
96
  code >= 400 and code != 503
97
97
  end
98
98
 
99
- def method_missing(method,*args)
100
- method = method.to_s
101
- begin
102
- case method
103
- when /=/
104
- res = RestClientWrapper.put(File.join(@uri,method.sub(/=/,'')),{})
105
- super unless res.code == 200
106
- else
107
- pull
108
- response = self.[](RDF::OT[method])
109
- response = self.[](RDF::OT1[method]) if response.empty? # API 1.1 compatibility
110
- internal_server_error "No #{method} metadata for #{@uri} " if response.empty?
111
- return response.uniq.first.to_s
112
- end
113
- rescue OpenTox::Error
114
- raise $!
115
- rescue
116
- $logger.error "Unknown #{self.class} method #{method}"
117
- super
99
+ def errorReport
100
+ # TODO: fix rdf output at task service
101
+ not_implemented_error "RDF output of errorReports has to be fixed at task service"
102
+ end
103
+
104
+ [:hasStatus, :resultURI].each do |method|
105
+ define_method method do
106
+ response = self.[](RDF::OT[method])
107
+ response = self.[](RDF::OT1[method]) unless response # API 1.1 compatibility
108
+ response
118
109
  end
119
110
  end
120
111
 
121
- #TODO: subtasks
112
+ #TODO: subtasks (only for progress)
122
113
 
123
114
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "opentox-client"
6
- s.version = "0.0.1pre"
6
+ s.version = "0.0.2pre"
7
7
  s.authors = ["Christoph Helma, Martin Guetlein, Andreas Maunz, Micha Rautenberg, David Vorgrimmler"]
8
8
  s.email = ["helma@in-silico.ch"]
9
9
  s.homepage = "http://github.com/opentox/opentox-client"
@@ -24,4 +24,8 @@ Gem::Specification.new do |s|
24
24
  s.add_runtime_dependency "rdf"
25
25
  s.add_runtime_dependency "rdf-raptor"
26
26
  s.add_runtime_dependency "open4"
27
+
28
+ # external requirements
29
+ ["libraptor-dev"].each{|r| s.requirements << r}
30
+ s.post_install_message = "Please check the version of your libraptor library, if installation of rdf.rb fails"
27
31
  end