soar_sr 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f70f5737b75f2535a7eed5c47a97af944d14b01b
4
- data.tar.gz: b9720f29b51743d365fc31f878da44e33438fce5
3
+ metadata.gz: 7a81f40d80e885c259c37c7634558069df0eea50
4
+ data.tar.gz: ca96964491c938cbb08ef2afb84cc70d0bb939aa
5
5
  SHA512:
6
- metadata.gz: 08077201d88fccb5e45e8c83425f81755bfd224d6abd8f20d92832f1a7e2843fd3563b2207b83f45549469b0433e9ed26b44c56cb618be97e27d12c81511eddd
7
- data.tar.gz: 02696cd744a6ffb140bbe1e09b53c942f78288d7172a398dfc8f4a6b144b7183567593dcec5dfdac49e9f59718791ea4a43a7467957f57b44ccb266f29a57c90
6
+ metadata.gz: f8a94c966ac25a99fbf580a5949279d8ec8c823e8aba206dad8364471d34a1dfa22cb3a10f43f0ef2b30a7fd77f133d606824d9d63ccea4312adc91593d7f44e
7
+ data.tar.gz: 24b7d84430cfa5b489079e53aa8f5d547e66b507ef8dd2771d051c7e3558d7cb7bc7d95b4178b4fe6ae0d91c8ae92d95885cc3db697d463a9fbb15d685b84ba6
@@ -40,6 +40,28 @@ module SoarSr
40
40
  has_data?(result, 'registered') and result['data']['registered']
41
41
  end
42
42
 
43
+ def type_registered?(element, type)
44
+ return is_registered?(@registry.domain_perspectives.domain_perspective_registered?(element)) if (type == 'domains')
45
+ return is_registered?(@registry.service_components.service_component_registered?(element)) if (type == 'service-components')
46
+ return is_registered?(@registry.services.service_registered?(element)) if (type == 'services')
47
+ return is_registered?(@registry.teams.team_registered?(element)) if (type == 'teams')
48
+ false
49
+ end
50
+
51
+ def not_registered?(element, type)
52
+ raise ValidationError, "#{one_of(type)} already exists" if type_registered?(element, type)
53
+ true
54
+ end
55
+
56
+ def any_registered?(domain_perspective)
57
+ raise ValidationError, "unknown domain perspective provided" if (not type_registered?(domain_perspective, 'domains')) and (not type_registered?(domain_perspective, 'teams'))
58
+ end
59
+
60
+ def registered?(element, type)
61
+ raise ValidationError, "unknown #{one_of(type)} provided" if not type_registered?(element, type)
62
+ true
63
+ end
64
+
43
65
  def validate
44
66
  provided?(@urns, "urns") and provided?(@uddi, "UDDI provider") and credentials?(@credentials)
45
67
  end
@@ -4,16 +4,16 @@ require 'persistent-cache'
4
4
 
5
5
  module SoarSr
6
6
  class JUDDIProvider
7
+ attr_reader :broker
8
+ attr_reader :urns
9
+ attr_reader :cache
10
+
7
11
  def initialize(urns, broker, cache_freshness)
8
12
  @urns = urns
9
13
  @broker = broker
10
14
  @cache = Persistent::Cache.new("uddi-broker", cache_freshness, Persistent::Cache::STORAGE_RAM)
11
15
  end
12
16
 
13
- def broker
14
- @broker
15
- end
16
-
17
17
  def assign_service_to_business(name, business_key = @urns['company'])
18
18
  @broker.authorize
19
19
  result = get_service(name)
@@ -109,12 +109,6 @@ module SoarSr
109
109
  @broker.save_element_bindings(service_component, [uri], @urns['service-components'], "service component")
110
110
  end
111
111
 
112
- def delete_existing_bindings(bindings)
113
- bindings.each do |binding, detail|
114
- @broker.delete_binding(binding)
115
- end
116
- end
117
-
118
112
  def find_service_component_uri(service_component)
119
113
  cached = @cache["find_service_component_uri:#{service_component}"]; return cached if cached
120
114
  value = @broker.find_element_bindings(service_component, @urns['service-components'])
@@ -147,12 +141,14 @@ module SoarSr
147
141
  @broker.delete_business(key)
148
142
  end
149
143
 
150
- def business_eq?(business, comparison)
151
- business == "#{@urns['domains']}#{comparison}"
152
- end
153
-
154
144
  private
155
145
 
146
+ def delete_existing_bindings(bindings)
147
+ bindings.each do |binding, detail|
148
+ @broker.delete_binding(binding)
149
+ end
150
+ end
151
+
156
152
  def has_bindings?(result)
157
153
  result and result['data'] and result['data']['bindings'] and (result['data']['bindings'].size > 0)
158
154
  end
@@ -14,6 +14,7 @@ module SoarSr
14
14
  attr_reader :contacts
15
15
 
16
16
  def initialize(uri, company, company_name, credentials, cache_freshness = 60)
17
+ validate(uri, company, company_name, credentials)
17
18
  @urns = initialize_urns(company, company_name)
18
19
  @uddi = initialize_uddi_provider(uri, @urns, credentials, cache_freshness)
19
20
  initialize_handlers(@urns, @uddi, credentials)
@@ -22,9 +23,7 @@ module SoarSr
22
23
  def check_dss(name)
23
24
  end
24
25
 
25
- private
26
-
27
- def initialize_urns(fqdn, company_name)
26
+ def self.build_urns(fqdn, company_name)
28
27
  base = "uddi:#{fqdn}"
29
28
  @urns = { 'base' => base,
30
29
  'company' => "#{base}:#{company_name}",
@@ -35,6 +34,20 @@ module SoarSr
35
34
  @urns
36
35
  end
37
36
 
37
+ private
38
+
39
+ def validate(uri, company, company_name, credentials)
40
+ validator = SoarSr::Validator.new
41
+ validator.provided?(uri, 'URI') and validator.uri?(uri)
42
+ validator.provided?(company, 'company FQDN')
43
+ validator.provided?(company_name, 'company name')
44
+ validator.provided?(credentials, 'credentials') and validator.credentials?(credentials)
45
+ end
46
+
47
+ def initialize_urns(fqdn, company_name)
48
+ SoarSr::ServiceRegistry::build_urns(fqdn, company_name)
49
+ end
50
+
38
51
  def initialize_uddi_provider(uri, urns, credentials, cache_freshness)
39
52
  @broker = ::Soap4juddi::Broker.new(urns)
40
53
  @broker.set_uri(uri)
@@ -32,7 +32,7 @@ module SoarSr
32
32
  end
33
33
 
34
34
  def credentials?(credentials)
35
- provided?(credentials['username'], 'username') and provided?(credentials['password'], 'password')
35
+ provided?(credentials, 'credentials') and provided?(credentials['username'], 'username') and provided?(credentials['password'], 'password')
36
36
  end
37
37
 
38
38
  def authorized?(result)
@@ -74,31 +74,10 @@ module SoarSr
74
74
  true
75
75
  end
76
76
 
77
- def type_registered?(element, type)
78
- return is_registered?(@registry.domain_perspectives.domain_perspective_registered?(element)) if (type == 'domains')
79
- return is_registered?(@registry.service_components.service_component_registered?(element)) if (type == 'service-components')
80
- return is_registered?(@registry.services.service_registered?(element)) if (type == 'services')
81
- return is_registered?(@registry.teams.team_registered?(element)) if (type == 'teams')
82
- false
83
- end
84
-
85
- def not_registered?(element, type)
86
- raise ValidationError, "#{one_of(type)} already exists" if type_registered?(element, type)
87
- true
88
- end
89
-
90
- def any_registered?(domain_perspective)
91
- raise ValidationError, "unknown domain perspective provided" if (not type_registered?(domain_perspective, 'domains')) and (not type_registered?(domain_perspective, 'teams'))
92
- end
93
-
94
- def registered?(element, type)
95
- raise ValidationError, "unknown #{one_of(type)} provided" if not type_registered?(element, type)
96
- true
97
- end
98
-
99
77
  def one_of(type)
100
78
  result = type[0..-2]
101
79
  result = 'domain perspective' if result == 'domain'
80
+ result = 'service component' if result == 'service-component'
102
81
  result
103
82
  end
104
83
  end
@@ -1,3 +1,3 @@
1
1
  module SoarSr
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_sr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst van Graan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: persistent-cache