soar_sr 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/soar_sr/associations.rb +125 -0
- data/lib/soar_sr/contacts.rb +77 -0
- data/lib/soar_sr/domain_perspectives.rb +164 -0
- data/lib/soar_sr/failure_error.rb +3 -0
- data/lib/soar_sr/handler.rb +56 -0
- data/lib/soar_sr/juddi_provider.rb +172 -0
- data/lib/soar_sr/search.rb +104 -0
- data/lib/soar_sr/service_components.rb +92 -0
- data/lib/soar_sr/service_definitions.rb +39 -0
- data/lib/soar_sr/service_registry.rb +71 -0
- data/lib/soar_sr/services.rb +157 -0
- data/lib/soar_sr/teams.rb +20 -0
- data/lib/soar_sr/validation_error.rb +4 -0
- data/lib/soar_sr/validator.rb +93 -0
- data/lib/soar_sr/version.rb +3 -0
- data/lib/soar_sr.rb +19 -0
- data/soar_sr.gemspec +27 -0
- metadata +128 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c3885966ad4efc683dff78fe7e7ed1f5241dc9f2
|
4
|
+
data.tar.gz: 3dde17feea00287e828f5ba120f5c2f2df5646d2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f93c51e6fdd6259da50944ea10012edd26ad1f4264e660300544c4608f1ed6c494c6e75dea260b935804234131239e17de25edf1bc61097640fe50aabcc4e784
|
7
|
+
data.tar.gz: 6c80ad0090793d19b97b33053e14921f1b684600b6cb85de296b02018214fbfad26b196cc5266855b17f7249464b31e53d40516277067ae2edd0bbfe001630aa
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Ernst van Graan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# SoarSr
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/soar_sr`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'soar_sr'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install soar_sr
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/soar_sr. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "soar_sr"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'jsender'
|
2
|
+
require 'soap4juddi'
|
3
|
+
|
4
|
+
module SoarSr
|
5
|
+
class Associations < SoarSr::Handler
|
6
|
+
include Jsender
|
7
|
+
|
8
|
+
def service_component_has_domain_perspective_associations?(service_component)_{
|
9
|
+
provided?(service_component, 'service component')
|
10
|
+
service_component_id = compile_domain_id('service-components', service_component)
|
11
|
+
domain_perspectives = @registry.domain_perspectives.list_domain_perspectives['data']['domain_perspectives']
|
12
|
+
domain_perspectives.each do |name, detail|
|
13
|
+
service_components = domain_perspective_associations(name)['data']['associations']['service_components']
|
14
|
+
service_components.each do |id, value|
|
15
|
+
return true if (id == service_component_id) and (value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
false
|
19
|
+
}end
|
20
|
+
|
21
|
+
def associate_service_component_with_service(service, access_point, description = '')_{
|
22
|
+
authorize
|
23
|
+
provided?(service, 'service') and provided?(access_point, 'access point') and uri?(access_point)
|
24
|
+
result = @uddi.add_service_uri(service, access_point)
|
25
|
+
authorized?(result) and identifier?(result, 'service')
|
26
|
+
success('service or access point')
|
27
|
+
}end
|
28
|
+
|
29
|
+
def domain_perspective_associations(domain_perspective)_{
|
30
|
+
# byebug
|
31
|
+
provided?(domain_perspective, 'domain perspective')
|
32
|
+
meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective)
|
33
|
+
meta = @registry.domain_perspectives.meta_for_domain_perspective('teams', domain_perspective) if no_meta?(meta)
|
34
|
+
success_data(meta)
|
35
|
+
}end
|
36
|
+
|
37
|
+
def domain_perspective_has_associations?(domain_perspective)
|
38
|
+
associations = domain_perspective_associations(domain_perspective)['data']['associations']
|
39
|
+
(associations['service_components'].size > 0) or (associations['services'].size > 0)
|
40
|
+
end
|
41
|
+
|
42
|
+
def associate_service_component_with_domain_perspective(service_component, domain_perspective)_{
|
43
|
+
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domain perspective')
|
44
|
+
provided?(service_component, 'service component') and registered?(service_component, 'service component')
|
45
|
+
|
46
|
+
service_component_id = compile_domain_id('service-components', service_component)
|
47
|
+
meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective)
|
48
|
+
|
49
|
+
raise ValidationError, 'already associated' if meta['associations']['service_components'][service_component_id]
|
50
|
+
|
51
|
+
meta['associations']['service_components'][service_component_id] = true
|
52
|
+
result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta)
|
53
|
+
authorized?(result) and identifier?(result, 'domain perspective')
|
54
|
+
success
|
55
|
+
}end
|
56
|
+
|
57
|
+
def associate_service_with_domain_perspective(service, domain_perspective)_{
|
58
|
+
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domain perspective')
|
59
|
+
provided?(service, 'service') and registered?(service, 'service')
|
60
|
+
|
61
|
+
service_id = compile_domain_id('services', service)
|
62
|
+
meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective)
|
63
|
+
|
64
|
+
raise ValidationError, 'already associated' if meta['associations']['services'][service_id]
|
65
|
+
|
66
|
+
meta['associations']['services'][service_id] = true
|
67
|
+
result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta)
|
68
|
+
authorized?(result) and identifier?(result, 'domain perspective')
|
69
|
+
success
|
70
|
+
}end
|
71
|
+
|
72
|
+
def disassociate_service_component_from_domain_perspective(domain_perspective, service_component)_{
|
73
|
+
# byebug
|
74
|
+
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domain perspective')
|
75
|
+
provided?(service_component, 'service component') and registered?(service_component, 'service component')
|
76
|
+
|
77
|
+
service_component_id = compile_domain_id('service-components', service_component)
|
78
|
+
meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective)
|
79
|
+
|
80
|
+
raise ValidationError, 'not associated' if not meta['associations']['service_components'][service_component_id]
|
81
|
+
|
82
|
+
meta['associations']['service_components'].delete(service_component_id)
|
83
|
+
result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta)
|
84
|
+
authorized?(result) and identifier?(result, 'domain perspective')
|
85
|
+
success
|
86
|
+
}end
|
87
|
+
|
88
|
+
def disassociate_service_from_domain_perspective(domain_perspective, service)_{
|
89
|
+
# byebug
|
90
|
+
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domain perspective')
|
91
|
+
provided?(service, 'service') and registered?(service, 'service')
|
92
|
+
|
93
|
+
service_id = compile_domain_id('services', service)
|
94
|
+
meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective)
|
95
|
+
|
96
|
+
raise ValidationError, 'not associated' if not meta['associations']['services'][service_id]
|
97
|
+
|
98
|
+
meta['associations']['services'].delete(service_id)
|
99
|
+
result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta)
|
100
|
+
authorized?(result) and identifier?(result, 'domain perspective')
|
101
|
+
success
|
102
|
+
}end
|
103
|
+
|
104
|
+
def delete_all_domain_perspective_associations(domain_perspective)_{
|
105
|
+
# byebug
|
106
|
+
provided?(domain_perspective, 'domain perspective')
|
107
|
+
associations = domain_perspective_associations(domain_perspective)['data']['associations']
|
108
|
+
associations['service_components'] ||= {}
|
109
|
+
associations['services'] ||= {}
|
110
|
+
associations['service_components'].each do |id, value|
|
111
|
+
disassociate_service_component_from_domain_perspective(domain_perspective, extract_domain_name('service-components', id))
|
112
|
+
end
|
113
|
+
associations['services'].each do |id, value|
|
114
|
+
disassociate_service_from_domain_perspective(domain_perspective, extract_domain_name('services', id))
|
115
|
+
end
|
116
|
+
success
|
117
|
+
}end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def no_meta?(meta)
|
122
|
+
(meta['associations']['service_components'] == {}) and (meta['associations']['services'] == {})
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module SoarSr
|
2
|
+
class Contacts < SoarSr::Handler
|
3
|
+
def add_contact_to_domain_perspective(domain_perspective, contact)_{
|
4
|
+
authorize
|
5
|
+
provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
|
6
|
+
provided?(contact, 'contact details') and contact?(contact)
|
7
|
+
details = {}.merge!(contact)
|
8
|
+
details = ensure_required_contact_details(details)
|
9
|
+
|
10
|
+
result = @registry.domain_perspectives.domain_perspective_registered?(domain_perspective)
|
11
|
+
result = @registry.teams.team_registered?(domain_perspective) if result['data']['id'].nil?
|
12
|
+
|
13
|
+
id = result['data']['id']
|
14
|
+
domain_perspective = @uddi.get_business(id)['data'].first[1]
|
15
|
+
|
16
|
+
domain_perspective['contacts'] ||= []
|
17
|
+
|
18
|
+
return fail('contact already exists - remove first to update') if contacts_include?(domain_perspective['contacts'], details)
|
19
|
+
|
20
|
+
domain_perspective['contacts'] << details
|
21
|
+
|
22
|
+
@uddi.save_business(id, domain_perspective['name'], domain_perspective['description'], domain_perspective['contacts'])
|
23
|
+
}end
|
24
|
+
|
25
|
+
def contact_details_for_domain(domain_perspective)_{
|
26
|
+
provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
|
27
|
+
result = @registry.domain_perspectives.domain_perspective_registered?(domain_perspective)
|
28
|
+
result = @registry.teams.team_registered?(domain_perspective) if result['data']['id'].nil?
|
29
|
+
id = result['data']['id']
|
30
|
+
domain_perspective = @uddi.get_business(id)['data'].first[1]
|
31
|
+
domain_perspective['contacts'] ||= []
|
32
|
+
domain_perspective['contacts'].each do |contact|
|
33
|
+
contact['description'] = '' if contact['description'] == 'n/a'
|
34
|
+
contact['email'] = '' if contact['email'] == 'n/a'
|
35
|
+
contact['phone'] = '' if contact['phone'] == 'n/a'
|
36
|
+
end
|
37
|
+
success_data('contacts' => domain_perspective['contacts'])
|
38
|
+
}end
|
39
|
+
|
40
|
+
def remove_contact_from_domain_perspective(domain_perspective, contact)_{
|
41
|
+
authorize
|
42
|
+
provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
|
43
|
+
provided?(contact, 'contact details') and contact?(contact)
|
44
|
+
|
45
|
+
result = @registry.domain_perspectives.domain_perspective_registered?(domain_perspective)
|
46
|
+
result = @registry.teams.team_registered?(domain_perspective) if result['data']['id'].nil?
|
47
|
+
|
48
|
+
id = result['data']['id']
|
49
|
+
domain_perspective = @uddi.get_business(id)['data'].first[1]
|
50
|
+
|
51
|
+
domain_perspective['contacts'] ||= []
|
52
|
+
|
53
|
+
return fail('unknown contact') if not contacts_include?(domain_perspective['contacts'], contact)
|
54
|
+
|
55
|
+
domain_perspective['contacts'].delete(contact)
|
56
|
+
domain_perspective['contacts'] = nil if domain_perspective['contacts'] == []
|
57
|
+
|
58
|
+
@uddi.save_business(id, domain_perspective['name'], domain_perspective['description'], domain_perspective['contacts'])
|
59
|
+
}end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def ensure_required_contact_details(details)
|
64
|
+
details['description'] = 'n/a' if details['description'].nil? or details['description'].strip == ""
|
65
|
+
details['email'] = 'n/a' if details['email'].nil? or details['email'].strip == ""
|
66
|
+
details['phone'] = 'n/a' if details['phone'].nil? or details['phone'].strip == ""
|
67
|
+
details
|
68
|
+
end
|
69
|
+
|
70
|
+
def contacts_include?(contacts, contact)
|
71
|
+
contacts.each do |compare|
|
72
|
+
return true if (compare['name'] == contact['name']) and (compare['email'] == contact['email']) and (compare['description'] == contact['description']) and (compare['phone'] == contact['phone'])
|
73
|
+
end
|
74
|
+
false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'jsender'
|
2
|
+
require 'soap4juddi'
|
3
|
+
require 'json'
|
4
|
+
# require 'byebug'
|
5
|
+
|
6
|
+
module SoarSr
|
7
|
+
class DomainPerspectives < SoarSr::Handler
|
8
|
+
include Jsender
|
9
|
+
|
10
|
+
def delete_all_domain_perspectives()_{
|
11
|
+
authorize
|
12
|
+
result = list_domain_perspectives
|
13
|
+
if has_data?(result, 'domain_perspectives')
|
14
|
+
result['data']['domain_perspectives'].each do |name, detail|
|
15
|
+
@uddi.delete_business(detail['id'])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
}end
|
19
|
+
|
20
|
+
def domain_perspective_by_name(type, domain_perspective)
|
21
|
+
provided?(domain_perspective, 'domain perspective')
|
22
|
+
@uddi.get_business(compile_domain_id(type, domain_perspective))
|
23
|
+
end
|
24
|
+
|
25
|
+
def list_domain_perspectives()_{
|
26
|
+
result = @uddi.find_businesses
|
27
|
+
result['data']['domain_perspectives'] = {}
|
28
|
+
|
29
|
+
if has_data?(result, 'businesses')
|
30
|
+
result['data']['businesses'].each do |business, detail|
|
31
|
+
hetz = false
|
32
|
+
SoarSr::DOMAIN_TYPES.each do |type|
|
33
|
+
hetz = true if detail['id'].include?(type)
|
34
|
+
end
|
35
|
+
result['data']['domain_perspectives'][business] = detail if hetz
|
36
|
+
end
|
37
|
+
end
|
38
|
+
result['data'].delete('businesses')
|
39
|
+
result
|
40
|
+
}end
|
41
|
+
|
42
|
+
def domain_perspective_registered?(domain_perspective)_{
|
43
|
+
domain_registered?('domains', domain_perspective)
|
44
|
+
}end
|
45
|
+
|
46
|
+
def register_domain_perspective(domain_perspective)_{
|
47
|
+
register_domain('domains', domain_perspective)
|
48
|
+
}end
|
49
|
+
|
50
|
+
def deregister_domain_perspective(domain_perspective)_{
|
51
|
+
deregister_domain('domains', domain_perspective)
|
52
|
+
}end
|
53
|
+
|
54
|
+
def configure_meta_for_domain_perspective(type, domain_perspective, meta)_{
|
55
|
+
authorize
|
56
|
+
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domain perspective')
|
57
|
+
provided?(type, 'element type') and type?(type)
|
58
|
+
provided?(meta, 'meta') and meta?(meta)
|
59
|
+
|
60
|
+
detail = extract_detail_for_domain_perspective(type, domain_perspective)
|
61
|
+
descriptions = extract_non_meta_descriptions_for_domain_perspective(detail)
|
62
|
+
# byebug
|
63
|
+
detail['description'] = compile_meta_into_descriptions(descriptions, meta)
|
64
|
+
|
65
|
+
result = @uddi.save_business(detail['id'], detail['name'], detail['description'])
|
66
|
+
authorized?(result) and identifier?(result, 'domain perspective')
|
67
|
+
success('meta updated', result['data'])
|
68
|
+
}end
|
69
|
+
|
70
|
+
def meta_for_domain_perspective(type, domain_perspective)_{
|
71
|
+
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domain perspective')
|
72
|
+
provided?(type, 'element type') and type?(type)
|
73
|
+
|
74
|
+
meta = extract_meta_for_domain_perspective(extract_detail_for_domain_perspective(type, domain_perspective))
|
75
|
+
meta['associations'] ||= {}
|
76
|
+
meta['associations']['service_components'] ||= {}
|
77
|
+
meta['associations']['services'] ||= {}
|
78
|
+
meta
|
79
|
+
}end
|
80
|
+
|
81
|
+
protected
|
82
|
+
|
83
|
+
def domain_registered?(type, domain_perspective)
|
84
|
+
provided?(domain_perspective, 'domain perspective')
|
85
|
+
result = @uddi.find_businesses(domain_perspective)
|
86
|
+
registered = false
|
87
|
+
id = nil
|
88
|
+
if has_data?(result, 'businesses')
|
89
|
+
result['data']['businesses'].each do |business, detail|
|
90
|
+
if (domain_perspective.downcase == business.downcase) and (detail['id'].include?(type))
|
91
|
+
registered = true
|
92
|
+
id = detail['id']
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
success_data({'registered' => registered, 'id' => id})
|
97
|
+
end
|
98
|
+
|
99
|
+
def register_domain(type, domain_perspective)_{
|
100
|
+
authorize
|
101
|
+
provided?(domain_perspective, 'domain perspective') and not_registered?(domain_perspective, 'domain perspective')
|
102
|
+
id = compile_domain_id(type, domain_perspective)
|
103
|
+
result = @uddi.save_business(id, domain_perspective)
|
104
|
+
authorized?(result) and identifier?(result, 'domain perspective')
|
105
|
+
success('domain perspective registered')
|
106
|
+
}end
|
107
|
+
|
108
|
+
def deregister_domain(type, domain_perspective)_{
|
109
|
+
authorize
|
110
|
+
provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domain perspective')
|
111
|
+
raise ValidationError, 'domain perspective has associations' if @registry.associations.domain_perspective_has_associations?(domain_perspective)
|
112
|
+
result = @uddi.delete_business(compile_domain_id(type, domain_perspective))
|
113
|
+
authorized?(result) and identifier?(result, 'domain perspective')
|
114
|
+
success('domain perspective deregistered')
|
115
|
+
}end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
def extract_non_meta_descriptions_for_domain_perspective(detail)
|
120
|
+
descriptions = []
|
121
|
+
detail['description'] ||= []
|
122
|
+
detail['description'].each do |desc|
|
123
|
+
descriptions << desc if not description_is_meta?(desc)
|
124
|
+
end
|
125
|
+
descriptions
|
126
|
+
end
|
127
|
+
|
128
|
+
def extract_detail_for_domain_perspective(type, domain_perspective)
|
129
|
+
provided?(domain_perspective, 'domain perspective') and provided?(type, 'domain type')
|
130
|
+
id = compile_domain_id(type, domain_perspective)
|
131
|
+
detail = @uddi.get_business(id)['data'][domain_perspective]
|
132
|
+
detail ||= {}
|
133
|
+
detail['id'] = id
|
134
|
+
detail
|
135
|
+
end
|
136
|
+
|
137
|
+
def extract_meta_for_domain_perspective(detail)
|
138
|
+
meta = {}
|
139
|
+
if detail['description']
|
140
|
+
detail['description'].each do |desc|
|
141
|
+
meta.merge!(JSON.parse(CGI.unescape(desc))) if (description_is_meta?(desc))
|
142
|
+
end
|
143
|
+
end
|
144
|
+
meta
|
145
|
+
end
|
146
|
+
|
147
|
+
def compile_meta_into_descriptions(descriptions, meta)
|
148
|
+
associations = {}
|
149
|
+
associations.merge!(meta['associations']) if meta['associations']
|
150
|
+
associations['service_components'] ||= {}
|
151
|
+
associations['services'] ||= {}
|
152
|
+
meta.delete('associations')
|
153
|
+
associations['service_components'].each do |id, value|
|
154
|
+
descriptions << CGI.escape({'associations' => {'service_components' => {id => value}}}.to_json)
|
155
|
+
end
|
156
|
+
associations['services'].each do |id, value|
|
157
|
+
descriptions << CGI.escape({'associations' => {'services' => {id => value}}}.to_json)
|
158
|
+
end
|
159
|
+
|
160
|
+
descriptions << CGI.escape(meta.to_json) if meta.count > 0
|
161
|
+
descriptions
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'jsender'
|
2
|
+
require 'soap4juddi'
|
3
|
+
|
4
|
+
module SoarSr
|
5
|
+
class Handler < Validator
|
6
|
+
include Jsender
|
7
|
+
|
8
|
+
attr_accessor :registry
|
9
|
+
|
10
|
+
def initialize(urns, uddi, credentials, registry)
|
11
|
+
@urns = urns
|
12
|
+
@uddi = uddi
|
13
|
+
@credentials = credentials
|
14
|
+
@registry = registry
|
15
|
+
validate
|
16
|
+
end
|
17
|
+
|
18
|
+
def authorize
|
19
|
+
@uddi.broker.authenticate(@credentials['username'], @credentials['password'])
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def _(&block)
|
25
|
+
yield
|
26
|
+
rescue => ex
|
27
|
+
# byebug
|
28
|
+
return fail(ex.message) if ex.is_a? ValidationError
|
29
|
+
return error('request could not be completed')
|
30
|
+
end
|
31
|
+
|
32
|
+
def description_is_meta?(meta)
|
33
|
+
JSON.parse(CGI.unescape(meta))
|
34
|
+
true
|
35
|
+
rescue => ex
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
def is_registered?(result)
|
40
|
+
has_data?(result, 'registered') and result['data']['registered']
|
41
|
+
end
|
42
|
+
|
43
|
+
def validate
|
44
|
+
provided?(@urns, "urns") and provided?(@uddi, "UDDI provider") and credentials?(@credentials)
|
45
|
+
end
|
46
|
+
|
47
|
+
def compile_domain_id(type, element)
|
48
|
+
return element if element.include?(@urns[type])
|
49
|
+
"#{@urns[type]}#{element}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def extract_domain_name(type, element)
|
53
|
+
element.gsub("#{@urns[type]}", "")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|