libis-services 1.0.5 → 1.0.6

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: 2ce00b4bcc3a7510bba4c67012c0a1552952d952
4
- data.tar.gz: 96428f5da531d60378045967800aeeab05091a5d
3
+ metadata.gz: e86c48659570ebc77fd13a1c4186f4d794351efe
4
+ data.tar.gz: 3d682731a78736379ca16070b52fcbff449d9eec
5
5
  SHA512:
6
- metadata.gz: a2540a1835aace4888073336db20174a2a06e8073db83e7a6c58f623045d6b102f712f923416bc18e8b23c8e07a3a366322439d92dfd72c9ca720f6a9a441d5a
7
- data.tar.gz: 95eb2d53eca5febf20098eaf1f917ec1133f00f4a08589e40bd1052a545bfb7d765a2558fe99d8e93eb3144fb4e5f74b49b7c527d8944d51c8b4b7a8f9c5b515
6
+ metadata.gz: 7d598c681ee61e44f661d65ef13dfc2977cce7ed6d1e6de3d468aea9ac827913d6633bd6c5cac0fc05cc7aaa32d7648c4fa5975c9dd056d23cb8879c2f252c9f
7
+ data.tar.gz: 87d1c00e6963419cb380a16321af52412d76f2bc8eab5f1a2df8e3094ece01f6decf31472eb95f257d77399217fd013b39caefbc6287f14046176b914fc4b531
@@ -19,6 +19,7 @@ module Libis
19
19
  include ::Libis::Tools::Logger
20
20
 
21
21
  def initialize(section, service, options = {})
22
+ @clear_soap_action = true
22
23
  basic_auth = options.delete(:basic_auth)
23
24
  if basic_auth
24
25
  options[:basic_auth] = [
@@ -46,16 +47,18 @@ module Libis
46
47
 
47
48
  protected
48
49
 
50
+ attr_reader :clear_soap_action
51
+
49
52
  def call_raw(operation, args = {})
50
- data = if @auth
51
- request operation.to_s.to_sym, args, headers: {'Authorization' => @auth}
52
- else
53
- request operation.to_s.to_sym, args
54
- end
53
+ opts = {}
54
+ opts[:soap_action] = nil if clear_soap_action
55
+ opts[:headers] = {:Authorization => @auth} if @auth
56
+ data = request operation.to_s.to_sym, args, opts
55
57
 
56
58
  # remove wrapper
57
59
  data = data["#{operation}_response".to_sym]
58
- data.delete(:'@xmlns:ns1')
60
+ data.delete_if {|key, _value| key.to_s =~ /^@/}
61
+ # data.delete(:'@xmlns:ns1')
59
62
 
60
63
  # drill down the returned Hash
61
64
  data = data.first.last while data.is_a?(Hash) && 1 == data.size
@@ -26,7 +26,8 @@ module Libis
26
26
 
27
27
  def create(collection_info)
28
28
  collection_info = collection_info.to_hash.cleanup if collection_info.is_a? CollectionInfo
29
- call :create_collection, pds_handle: @pds_handle, collection: collection_info
29
+ result = call :create_collection, pds_handle: @pds_handle, collection: collection_info
30
+ result[:return]
30
31
  end
31
32
 
32
33
  def delete(id)
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'libis/tools/xml_document'
4
+ require 'libis/tools/mets_file'
4
5
  require_relative 'client'
5
6
 
6
7
  module Libis
@@ -15,12 +16,12 @@ module Libis
15
16
 
16
17
  def get_mets(ie, flags = 0)
17
18
  result = call_raw :get_ie, pds_handle: @pds_handle, ie_pid: ie, flags: flags
18
- Libis::Tools::MetsFile.parse(result)
19
+ Libis::Tools::MetsFile.parse(result[:get_ie])
19
20
  end
20
21
 
21
22
  def get_metadata(ie)
22
23
  result = call_raw :get_md, pds_handle: @pds_handle, 'PID' => ie
23
- Libis::Tools::MetsFile.parse(result)
24
+ Libis::Tools::MetsFile.parse(result[:get_md])
24
25
  end
25
26
 
26
27
  end
@@ -61,8 +61,9 @@ module Libis
61
61
  strip_namespaces: true,
62
62
  delete_namespace_attributes: true,
63
63
  empty_tag_value: nil,
64
- convert_tags_to: lambda { |tag| tag.to_sym }
64
+ convert_tags_to: lambda(&:to_sym)
65
65
  )
66
+ # noinspection RubyArgCount
66
67
  self.new(hash[:producer_info])
67
68
  end
68
69
  end
@@ -0,0 +1,56 @@
1
+ require 'virtus'
2
+
3
+ module Libis
4
+ module Services
5
+ module Rosetta
6
+ class ProducerAgent
7
+ # noinspection RubyResolve
8
+ include Virtus.model(nullify_blank: true)
9
+
10
+ attribute :first_name, String
11
+ attribute :last_name, String
12
+ attribute :user_name, String
13
+ attribute :job_title, String
14
+ attribute :street, String
15
+ attribute :suburb, String
16
+ attribute :city, String
17
+ attribute :country, String
18
+ attribute :address_5, String
19
+ attribute :zip, String
20
+ attribute :email_address, String
21
+ attribute :web_site_url, String
22
+ attribute :telephone_1, String
23
+ attribute :telephone_2, String
24
+ attribute :user_group, String
25
+
26
+ def to_hash
27
+ attributes.cleanup
28
+ end
29
+
30
+ def to_xml
31
+ Libis::Tools::XmlDocument.build do |xml|
32
+ # noinspection RubyResolve
33
+ xml.user_info {
34
+ xml.parent.default_namespace = 'http://www.exlibrisgroup.com/xsd/dps/backoffice/service'
35
+ self.attributes.each do |name, value|
36
+ xml.send(name, xmlns: '').text(value) if value
37
+ end
38
+ }
39
+ end.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::DEFAULT_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
40
+ end
41
+
42
+ def self.from_xml(xml)
43
+ xml_doc = Libis::Tools::XmlDocument.parse(xml)
44
+ hash = xml_doc.to_hash(
45
+ strip_namespaces: true,
46
+ delete_namespace_attributes: true,
47
+ empty_tag_value: nil,
48
+ convert_tags_to: lambda(&:to_sym)
49
+ )
50
+ # noinspection RubyArgCount
51
+ self.new(hash[:producer_info])
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -2,6 +2,7 @@
2
2
  require 'libis/tools/extend/hash'
3
3
  require 'libis/tools/xml_document'
4
4
  require_relative 'producer'
5
+ require_relative 'producer_agent'
5
6
  require_relative 'user'
6
7
 
7
8
  require_relative 'client'
@@ -39,6 +40,7 @@ module Libis
39
40
  end
40
41
 
41
42
  def new_producer(producer_info)
43
+ # noinspection RubyArgCount
42
44
  producer_info = Rosetta::Producer.new(producer_info) unless producer_info.is_a?(Rosetta::Producer)
43
45
  call :create_producer, arg0: @pds_handle, arg1: producer_info.to_xml
44
46
  end
@@ -51,17 +53,18 @@ module Libis
51
53
  if agent_info
52
54
  info = agent(agent_id)
53
55
  return nil if info.nil?
54
- (agent_info.is_a?(Rosetta::User) ? agent_info.attributes : agent_info).each do |name, value|
56
+ (agent_info.is_a?(Rosetta::ProducerAgent) ? agent_info.attributes : agent_info).each do |name, value|
55
57
  info[name] = value
56
58
  end
57
59
  call :update_producer_agent, arg0: @pds_handle, arg1: agent_id, arg2: info.to_xml
58
60
  else
59
- request_object :get_producer_agent, Rosetta::User, arg0: @pds_handle, arg1: agent_id
61
+ request_object :get_producer_agent, Rosetta::ProducerAgent, arg0: @pds_handle, arg1: agent_id
60
62
  end
61
63
  end
62
64
 
63
65
  def new_agent(agent_info)
64
- agent_info = Rosetta::User.new(agent_info) unless agent_info.is_a?(Rosetta::User)
66
+ # noinspection RubyArgCount
67
+ agent_info = Rosetta::ProducerAgent.new(agent_info) unless agent_info.is_a?(Rosetta::ProducerAgent)
65
68
  call :create_producer_agent, arg0: @pds_handle, arg1: agent_info.to_xml
66
69
  end
67
70
 
@@ -99,6 +102,7 @@ module Libis
99
102
  end
100
103
 
101
104
  def new_contact(contact_info)
105
+ # noinspection RubyArgCount
102
106
  contact_info = Rosetta::User.new(contact_info) unless contact_info.is_a?(Rosetta::User)
103
107
  call :create_contact, arg0: @pds_handle, arg1: contact_info.to_xml
104
108
  end
@@ -108,6 +112,7 @@ module Libis
108
112
  end
109
113
 
110
114
  def link_contact(contact_id, producer_id, primary = true)
115
+ # noinspection RubySimplifyBooleanInspection
111
116
  call :link_contact_to_producer, arg0: @pds_handle, arg1: producer_id, arg2: contact_id, arg3: (!!primary).to_s.upcase
112
117
  end
113
118
 
@@ -60,8 +60,9 @@ module Libis
60
60
  strip_namespaces: true,
61
61
  delete_namespace_attributes: true,
62
62
  empty_tag_value: nil,
63
- convert_tags_to: lambda { |tag| tag.to_sym }
63
+ convert_tags_to: lambda(&:to_sym)
64
64
  )
65
+ # noinspection RubyArgCount
65
66
  self.new(hash[:producer_info])
66
67
  end
67
68
  end
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Services
3
- VERSION = '1.0.5'
3
+ VERSION = '1.0.6'
4
4
  end
5
5
  end
@@ -24,7 +24,7 @@ def expected_ies
24
24
  "status" => "ACTIVE",
25
25
  "submissionReason" => "Ingest",
26
26
  "IEEntityType" => "KADOC_PhotoAlbum",
27
- "Version" => "100200300",
27
+ "Version" => "13",
28
28
  "UserDefinedA" => "AAAA",
29
29
  "UserDefinedB" => "BBBB",
30
30
  "UserDefinedC" => "CCCC"
@@ -65,7 +65,6 @@ def expected_ies
65
65
  }
66
66
  },
67
67
  :dmd => {
68
- "text" => "\n ",
69
68
  "title" => "Denemarken 2015"
70
69
  },
71
70
  }
@@ -542,7 +541,6 @@ def expected_mets
542
541
  }
543
542
  },
544
543
  :dmd => {
545
- "text" => "\n ",
546
544
  "spatial" => "Sinebjerg",
547
545
  "coverage" => "Denemarken 2015",
548
546
  "subject" => "Jitse"
@@ -63,10 +63,15 @@ describe 'Rosetta Collection Service' do
63
63
  collection_service = Libis::Services::Rosetta::CollectionHandler.new credentials.rosetta_url,
64
64
  log: credentials.debug,
65
65
  log_level: credentials.debug_level
66
- collection_service.pds_handle = handle
66
+ # collection_service.pds_handle = handle
67
67
  collection_service
68
68
  end
69
69
 
70
+ before :each do
71
+ # noinspection RubyResolve
72
+ collection_service.authenticate(credentials.admin.user, credentials.admin.password, credentials.admin.institute)
73
+ end
74
+
70
75
  context 'existing collections' do
71
76
 
72
77
  let(:collection_data) { {
@@ -108,7 +113,7 @@ describe 'Rosetta Collection Service' do
108
113
  context 'collections CRUD' do
109
114
 
110
115
  let(:collection_data) { {
111
- name: 'New test collection',
116
+ name: 'Test API collection',
112
117
  parent_id: parent_id,
113
118
  collection_order: 0,
114
119
  md_dc: {
@@ -126,9 +131,7 @@ describe 'Rosetta Collection Service' do
126
131
  },
127
132
  md_source: [],
128
133
  navigate: true,
129
- publish: false,
130
- external_id: '54321',
131
- external_system: 'Scope'
134
+ publish: false
132
135
  } }
133
136
 
134
137
  let(:new_collection) { collection_service.find(parent_name + '/' + collection_data[:name]) }
@@ -173,8 +176,8 @@ describe 'Rosetta Collection Service' do
173
176
  end
174
177
 
175
178
  it 'retrieve new collection' do
176
- puts new_collection.to_hash
177
- puts new_collection_data
179
+ # puts new_collection.to_hash
180
+ # puts new_collection_data
178
181
  expect(new_collection.to_hash).to match_collection(new_collection_data)
179
182
  end
180
183
 
@@ -41,7 +41,7 @@ describe 'Rosetta IE Service' do
41
41
 
42
42
  mets = ie_handler.get_mets('IE403595')
43
43
  expect(mets).not_to be_nil
44
- ap mets
44
+ # ap mets
45
45
  expect(mets).to deep_include(expected_mets)
46
46
  # check_container expected_mets, mets
47
47
  end
@@ -50,6 +50,7 @@ describe 'Rosetta IE Service' do
50
50
 
51
51
  metadata = ie_handler.get_metadata('IE403595')
52
52
  expect(metadata).not_to be_nil
53
+ # ap metadata
53
54
  expect(metadata).to deep_include(expected_ies)
54
55
  # check_container(expected_ies, metadata)
55
56
  end
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require_relative 'spec_helper'
3
3
  require 'yaml'
4
+ require 'awesome_print'
4
5
 
5
6
  require 'libis/tools/config_file'
6
7
 
@@ -43,8 +44,10 @@ describe 'Rosetta Producer Service' do
43
44
  end
44
45
 
45
46
  context 'user info' do
47
+ # noinspection RubyBlockToMethodReference
46
48
  let(:user_id) {admin_uid}
47
49
 
50
+ # noinspection RubyBlockToMethodReference
48
51
  let(:user_name) {admin_usr}
49
52
 
50
53
  it 'gets user id' do
@@ -69,6 +72,7 @@ describe 'Rosetta Producer Service' do
69
72
 
70
73
  let(:producer_id) {credentials.producer.id}
71
74
  let(:producer_data) {credentials.producer.data.to_hash}
75
+ # noinspection RubyArgCount
72
76
  let(:producer_info) {::Libis::Services::Rosetta::Producer.new(producer_data).to_hash}
73
77
  let(:updated_info) {{email: 'nomail@mail.com', telephone_2: '0032 16 32 22 22'}}
74
78
  let(:new_producer_info) {
@@ -86,6 +90,7 @@ describe 'Rosetta Producer Service' do
86
90
 
87
91
  it 'get producer' do
88
92
  result = producer_handler.producer(producer_id)
93
+ # ap result
89
94
  expect(result).not_to be_nil
90
95
  expect(result.to_hash).to match producer_data
91
96
  expect(producer_data).to match result.to_hash
@@ -136,19 +141,21 @@ describe 'Rosetta Producer Service' do
136
141
  email_address: 'test@mail.com',
137
142
  street: 'Willem de Croylaan 54',
138
143
  city: 'Heverlee',
139
- zip: 3001,
144
+ zip: '3001',
140
145
  country: 'Belgium',
141
146
  telephone_1: '0032 16 32 22 66',
142
147
  user_group: 'producer_agents'
143
148
  }}
144
149
  let(:new_agent) {
145
150
  data = new_agent_data.dup
146
- data[:password] = data[:password_verify] = 'abc123ABC'
147
- Libis::Services::Rosetta::User.new(data).to_hash
151
+ # data[:password] = data[:password_verify] = 'abc123ABC'
152
+ # noinspection RubyArgCount
153
+ Libis::Services::Rosetta::ProducerAgent.new(data).to_hash
148
154
  }
149
155
 
150
156
  # noinspection RubyResolve
151
157
  let(:agent_data) {credentials.producer_agent.data.to_hash}
158
+ # noinspection RubyArgCount
152
159
  let(:agent) {::Libis::Services::Rosetta::User.new(agent_data)}
153
160
  # noinspection RubyResolve
154
161
  let(:agent_id) {credentials.producer_agent.user_id}
@@ -163,7 +170,9 @@ describe 'Rosetta Producer Service' do
163
170
  it 'get info' do
164
171
  result = producer_handler.agent(agent_id)
165
172
  expect(result).not_to be_nil
166
- expect(result.to_hash).to include agent_data
173
+ # ap result.to_hash
174
+ # ap agent_data
175
+ expect(result.to_hash).to match agent_data
167
176
  end
168
177
 
169
178
  it 'create' do
@@ -176,7 +185,7 @@ describe 'Rosetta Producer Service' do
176
185
  it 'get info' do
177
186
  result = producer_handler.agent(new_agent_id)
178
187
  expect(result).not_to be_nil
179
- expect(result.to_hash).to include new_agent_data
188
+ expect(result.to_hash).to match new_agent_data
180
189
  end
181
190
 
182
191
  it 'update info' do
@@ -205,6 +214,7 @@ describe 'Rosetta Producer Service' do
205
214
  it 'get producers' do
206
215
  result = producer_handler.agent_producers agent_id, agent_ins
207
216
  expect(result).not_to be_nil
217
+ # noinspection RubyResolve
208
218
  expect(result).to eq [{id: credentials.producer.id, description: credentials.producer.data.authoritative_name}]
209
219
  end
210
220
 
@@ -215,6 +225,7 @@ describe 'Rosetta Producer Service' do
215
225
  let(:contact_id) {credentials.contact.user_id}
216
226
  let(:contact_info) {credentials.contact.data.to_hash}
217
227
  let(:new_contact) {
228
+ # noinspection RubyArgCount
218
229
  ::Libis::Services::Rosetta::User.new(
219
230
  first_name: 'New',
220
231
  last_name: 'Contact',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-08 00:00:00.000000000 Z
11
+ date: 2019-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -267,6 +267,7 @@ files:
267
267
  - lib/libis/services/rosetta/oai_set.rb
268
268
  - lib/libis/services/rosetta/pds_handler.rb
269
269
  - lib/libis/services/rosetta/producer.rb
270
+ - lib/libis/services/rosetta/producer_agent.rb
270
271
  - lib/libis/services/rosetta/producer_handler.rb
271
272
  - lib/libis/services/rosetta/service.rb
272
273
  - lib/libis/services/rosetta/sip.rb