Class: SoarSr::ServiceComponents
- Inherits:
-
Handler
show all
- Includes:
- Jsender
- Defined in:
- lib/soar_sr/service_components.rb
Instance Attribute Summary
Attributes inherited from Handler
#registry
Instance Method Summary
collapse
Methods inherited from Handler
#authorize, #initialize
Methods inherited from Validator
#authorized?, #contact?, #credentials?, #identifier?, #key_provided?, #length_at_least?, #meta?, #one_of, #present?, #provided?, #type?, #uri?, #wadl?
Instance Method Details
79
80
81
82
83
84
85
86
|
# File 'lib/soar_sr/service_components.rb', line 79
def configure_service_component_uri(service_component, uri)_{
service_component = standardize(service_component)
authorize
provided?(service_component, 'service component') and provided?(uri, 'URI') and uri?(uri) and registered?(service_component, 'service-components')
result = @uddi.save_service_component_uri(service_component, uri)
authorized?(result) and identifier?(result, 'service component')
success
}end
|
#delete_all_service_components ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'lib/soar_sr/service_components.rb', line 8
def delete_all_service_components()_{
authorize
result = list_service_components
if has_data?(result, 'service_components')
result['data']['service_components'].each do |name, detail|
@uddi.delete_service_component(name)
end
end
}end
|
#deregister_service_component(service_component) ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/soar_sr/service_components.rb', line 68
def deregister_service_component(service_component)_{
service_component = standardize(service_component)
authorize
provided?(service_component, 'service component') and registered?(service_component, 'service-components')
raise ValidationError, 'service component has domain perspective associations' if @registry.associations.service_component_has_domain_perspective_associations?(service_component)
result = @uddi.delete_service_component(service_component)
authorized?(result) and identifier?(result, 'service component')
success('service component deregistered')
}end
|
#list_service_components(domain_perspective = nil) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/soar_sr/service_components.rb', line 18
def list_service_components(domain_perspective = nil)_{
domain_perspective = standardize(domain_perspective)
return fail('unknown domain perspective provided') if domain_perspective and (not is_registered?(@registry.domain_perspectives.domain_perspective_registered?(domain_perspective)))
result = @uddi.find_service_components
service_components = has_data?(result, 'services') ? result['data']['services'] : {}
found = []
if not domain_perspective.nil?
associations = @registry.associations.domain_perspective_associations(domain_perspective)['data']['associations']['service_components']
return success_data({'service_components' => []}) if associations.count == 0
associations.each do |id, associated|
if associated
service_components.each do |sid, service_component|
found << sid if compile_domain_id('service-components', sid) == id
end
end
end
else
service_components.each do |sid, service_component|
found << sid
end
end
success_data('service_components' => found)
}end
|
#register_service_component(service_component) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'lib/soar_sr/service_components.rb', line 58
def register_service_component(service_component)_{
service_component = standardize(service_component)
authorize
provided?(service_component, 'service component') and not_registered?(service_component, 'service-components')
result = @uddi.save_service_component(service_component)
authorized?(result) and identifier?(result, 'service component')
success('service component registered')
}end
|
#service_component_registered?(service_component) ⇒ Boolean
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/soar_sr/service_components.rb', line 46
def service_component_registered?(service_component)_{
service_component = standardize(service_component)
result = @uddi.find_service_components(service_component)
registered = false
if has_data?(result, 'services')
result['data']['services'].each do |service_key, description|
registered = (service_component.downcase == service_key.downcase)
end
end
success_data({'registered' => registered})
}end
|
#service_component_uri(service_component) ⇒ Object
88
89
90
91
92
93
94
95
96
|
# File 'lib/soar_sr/service_components.rb', line 88
def service_component_uri(service_component)_{
service_component = standardize(service_component)
provided?(service_component, 'service component') and registered?(service_component, 'service-components')
result = @uddi.find_service_component_uri(service_component)
identifier?(result, 'service component')
uri = (has_data?(result, 'bindings') and (result['data']['bindings'].size > 0)) ? result['data']['bindings'].first[1]['access_point'] : nil
result['data']['uri'] = uri
success_data(result['data'])
}end
|