libis-services 0.1.0-java

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.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +36 -0
  6. data/Rakefile +6 -0
  7. data/lib/libis/services/aleph/search.rb +157 -0
  8. data/lib/libis/services/alma/web_service.rb +36 -0
  9. data/lib/libis/services/collective_access/cataloguing.rb +48 -0
  10. data/lib/libis/services/collective_access/connector.rb +151 -0
  11. data/lib/libis/services/collective_access/item_info.rb +36 -0
  12. data/lib/libis/services/collective_access/search.rb +26 -0
  13. data/lib/libis/services/collective_access/service.rb +80 -0
  14. data/lib/libis/services/collective_access.rb +1 -0
  15. data/lib/libis/services/digitool/digital_entity_manager.rb +223 -0
  16. data/lib/libis/services/digitool/digitool_connector.rb +46 -0
  17. data/lib/libis/services/digitool/meta_data_manager.rb +193 -0
  18. data/lib/libis/services/extend/http_fetch.rb +63 -0
  19. data/lib/libis/services/generic_search.rb +38 -0
  20. data/lib/libis/services/http_error.rb +21 -0
  21. data/lib/libis/services/oracle_client.rb +47 -0
  22. data/lib/libis/services/primo/limo.rb +33 -0
  23. data/lib/libis/services/primo/search.rb +46 -0
  24. data/lib/libis/services/primo.rb +2 -0
  25. data/lib/libis/services/rest_client.rb +66 -0
  26. data/lib/libis/services/rosetta/client.rb +108 -0
  27. data/lib/libis/services/rosetta/collection_handler.rb +45 -0
  28. data/lib/libis/services/rosetta/collection_info.rb +44 -0
  29. data/lib/libis/services/rosetta/deposit_activity.rb +48 -0
  30. data/lib/libis/services/rosetta/deposit_handler.rb +187 -0
  31. data/lib/libis/services/rosetta/ie.rb +19 -0
  32. data/lib/libis/services/rosetta/ie_handler.rb +29 -0
  33. data/lib/libis/services/rosetta/oai_pmh.rb +48 -0
  34. data/lib/libis/services/rosetta/oai_set.rb +21 -0
  35. data/lib/libis/services/rosetta/pds_handler.rb +60 -0
  36. data/lib/libis/services/rosetta/producer.rb +71 -0
  37. data/lib/libis/services/rosetta/producer_handler.rb +125 -0
  38. data/lib/libis/services/rosetta/service.rb +403 -0
  39. data/lib/libis/services/rosetta/sip.rb +26 -0
  40. data/lib/libis/services/rosetta/sip_handler.rb +31 -0
  41. data/lib/libis/services/rosetta/user.rb +70 -0
  42. data/lib/libis/services/rosetta/user_manager.rb +28 -0
  43. data/lib/libis/services/rosetta.rb +2 -0
  44. data/lib/libis/services/scope/search.rb +46 -0
  45. data/lib/libis/services/search_factory.rb +40 -0
  46. data/lib/libis/services/service_error.rb +16 -0
  47. data/lib/libis/services/sharepoint/connector.rb +236 -0
  48. data/lib/libis/services/sharepoint/search.rb +19 -0
  49. data/lib/libis/services/soap_client.rb +57 -0
  50. data/lib/libis/services/soap_error.rb +22 -0
  51. data/lib/libis/services/version.rb +5 -0
  52. data/lib/libis/services.rb +22 -0
  53. data/lib/libis-services.rb +1 -0
  54. data/libis-services.gemspec +40 -0
  55. data/spec/alma_service_spec.rb +104 -0
  56. data/spec/ie_data.rb +726 -0
  57. data/spec/primo_limo_spec.rb +363 -0
  58. data/spec/primo_search_spec.rb +39 -0
  59. data/spec/rosetta_collection_spec.rb +206 -0
  60. data/spec/rosetta_deposit_spec.rb +82 -0
  61. data/spec/rosetta_ie_spec.rb +54 -0
  62. data/spec/rosetta_oai_spec.rb +52 -0
  63. data/spec/rosetta_pds_spec.rb +79 -0
  64. data/spec/rosetta_producer_spec.rb +270 -0
  65. data/spec/rosetta_sip_spec.rb +39 -0
  66. data/spec/spec_helper.rb +28 -0
  67. metadata +317 -0
@@ -0,0 +1,206 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+
4
+ require 'libis/tools/config_file'
5
+ require 'libis/tools/extend/hash'
6
+
7
+ require 'libis/services/rosetta/pds_handler'
8
+ require 'libis/services/rosetta/collection_handler'
9
+
10
+ require 'rspec/matchers'
11
+ require 'equivalent-xml'
12
+
13
+ class String
14
+ def unindent
15
+ gsub(/^#{scan(/^\s*/).min_by { |l| l.length }}/, '')
16
+ end
17
+ end
18
+
19
+ RSpec::Matchers.define(:match_collection) do |target_collection|
20
+ match do |actual_collection|
21
+ actual_md = actual_collection.delete(:md_dc)
22
+ target_md = target_collection.delete(:md_dc)
23
+ expect(actual_collection).to include(target_collection)
24
+ actual_xml = actual_md.delete(:content)
25
+ target_xml = target_md.delete(:content)
26
+ expect(actual_md).to include(target_md)
27
+ match_xml(actual_xml, target_xml)
28
+ end
29
+
30
+ def match_xml(doc1, doc2)
31
+ doc1 = ::Nokogiri::XML(doc1) if doc1.is_a?(String)
32
+ doc2 = ::Nokogiri::XML(doc2) if doc2.is_a?(String)
33
+ expect(doc1.root).to be_equivalent_to(doc2.root)
34
+ end
35
+
36
+ end
37
+
38
+
39
+ describe 'Rosetta Collection Service' do
40
+
41
+ let(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml') }
42
+ let(:pds_handler) do
43
+ # noinspection RubyResolve
44
+ Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
45
+ end
46
+
47
+ let(:handle) do
48
+ # noinspection RubyResolve
49
+ pds_handler.login(
50
+ credentials.admin.user,
51
+ credentials.admin.password,
52
+ credentials.admin.institute
53
+ )
54
+ end
55
+
56
+ let(:collection_info) { Libis::Services::Rosetta::CollectionInfo.new collection_data }
57
+
58
+ let(:parent_name) { 'Test Collection' }
59
+ let(:parent_id) { '23082369' }
60
+
61
+ # noinspection RubyResolve
62
+ subject(:collection_service) do
63
+ collection_service = Libis::Services::Rosetta::CollectionHandler.new credentials.rosetta_url,
64
+ log: credentials.debug,
65
+ log_level: credentials.debug_level
66
+ collection_service.pds_handle = handle
67
+ collection_service
68
+ end
69
+
70
+ context 'existing collections' do
71
+
72
+ let(:collection_data) { {
73
+ id: '23082442',
74
+ name: 'another collection',
75
+ parent_id: parent_id,
76
+ md_dc: {
77
+ mid: '212362',
78
+ type: 'descriptive',
79
+ sub_type: 'dc',
80
+ content: <<-STR.unindent.strip
81
+ <?xml version="1.0" encoding="UTF-8"?>
82
+ <dc:record xmlns:dc="http://purl.org/dc/elements/1.1/"
83
+ xmlns:dcterms="http://purl.org/dc/terms/"
84
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
85
+ <dc:title>My pictures</dc:title>
86
+ <dcterms:created>2014-01-01 10:10:10</dcterms:created>
87
+ </dc:record>
88
+ STR
89
+ },
90
+ md_source: [],
91
+ navigate: true,
92
+ publish: true,
93
+ external_id: '5555',
94
+ external_system: 'CollectiveAccess'
95
+ } }
96
+
97
+ it 'get collection by ID' do
98
+ coll_info = collection_service.get(collection_data[:id])
99
+ expect(coll_info.to_hash).to match_collection(collection_data)
100
+ end
101
+
102
+ it 'get collection by name' do
103
+ coll_info = collection_service.find(parent_name + '/' + collection_data[:name])
104
+ expect(coll_info.to_hash).to match_collection(collection_data)
105
+ end
106
+ end
107
+
108
+ context 'collections CRUD' do
109
+
110
+ let(:collection_data) { {
111
+ name: 'My new test collection',
112
+ parent_id: parent_id,
113
+ md_dc: {
114
+ type: 'descriptive',
115
+ sub_type: 'dc',
116
+ content: <<-STR.unindent.strip
117
+ <?xml version="1.0" encoding="UTF-8"?>
118
+ <dc:record xmlns:dc="http://purl.org/dc/elements/1.1/"
119
+ xmlns:dcterms="http://purl.org/dc/terms/"
120
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
121
+ <dc:title>Something new to test</dc:title>
122
+ <dcterms:created>2015-06-25 10:00</dcterms:created>
123
+ </dc:record>
124
+ STR
125
+ },
126
+ md_source: [],
127
+ navigate: true,
128
+ publish: false,
129
+ external_id: '12345',
130
+ external_system: 'Scope'
131
+ } }
132
+
133
+ let(:new_collection) { collection_service.find(parent_name + '/' + collection_data[:name]) }
134
+
135
+ let(:new_collection_data) {
136
+ new_collection_data = {id: new_collection.id}
137
+ new_collection_data.reverse_merge!(collection_data)
138
+ new_collection_data[:md_dc][:mid] = new_collection.md_dc.mid
139
+ new_collection_data
140
+ }
141
+
142
+ let(:updated_name) { 'Stupid text' }
143
+
144
+ let(:updated_collection) { collection_service.find(parent_name + '/' + updated_name) }
145
+
146
+ let(:updated_collection_data) {
147
+ updated_collection_data = new_collection_data.dup
148
+ updated_collection_data[:name] = updated_name
149
+ updated_collection_data
150
+ }
151
+
152
+
153
+ it 'create new collection' do
154
+ new_collection_id = collection_service.create(collection_data)
155
+ expect(new_collection_id).not_to be_nil
156
+ expect(new_collection_id).to be_a String
157
+ expect(new_collection_id).to eq new_collection.id
158
+ end
159
+
160
+ it 'retrieve new collection' do
161
+ expect(new_collection.to_hash).to match_collection(new_collection_data)
162
+ end
163
+
164
+ it 'update new collection' do
165
+ result = collection_service.update(updated_collection_data)
166
+ expect(result).to be {}
167
+ expect(updated_collection.to_hash).to match_collection(updated_collection_data)
168
+ end
169
+
170
+ it 'delete new collection' do
171
+ result = collection_service.delete(updated_collection.id)
172
+ expect(result).to be {}
173
+ end
174
+
175
+ end
176
+
177
+ context 'check errors' do
178
+
179
+ it 'not authorized' do
180
+ collection_service.pds_handle = 'foobar'
181
+ expect do
182
+ collection_service.create({name: 'foo'})
183
+ end.to raise_error(Libis::Services::SoapError, /user_authorize_exception.*Invalid PDS Handle Number:foobar/)
184
+ end
185
+
186
+ it 'invalid collection info' do
187
+ expect do
188
+ collection_service.create({name: 'foo', parent_id: 0})
189
+ end.to raise_error(Libis::Services::SoapError, /invalid_collection_info_exception.*Invalid Parent Id: 0/)
190
+ end
191
+
192
+ it 'not found by id' do
193
+ expect do
194
+ collection_service.get(0)
195
+ end.to raise_error(Libis::Services::SoapError, /no_collection_found_exception.*collection with id: 0 not found/)
196
+ end
197
+
198
+ it 'not found by name' do
199
+ expect do
200
+ collection_service.find('foo')
201
+ end.to raise_error(Libis::Services::SoapError, /no_collection_found_exception.*collection with name: foo not found/)
202
+ end
203
+
204
+ end
205
+
206
+ end
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+ require 'yaml'
4
+
5
+ require 'libis/tools/config_file'
6
+
7
+ require 'libis/services/rosetta/pds_handler'
8
+ require 'libis/services/rosetta/deposit_handler'
9
+
10
+ describe 'Rosetta Deposit Service' do
11
+
12
+ let(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml') }
13
+ let(:pds_handler) do
14
+ # noinspection RubyResolve
15
+ Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
16
+ end
17
+
18
+ let(:handle) do
19
+ # noinspection RubyResolve
20
+ pds_handler.login(
21
+ credentials.admin.user,
22
+ credentials.admin.password,
23
+ credentials.admin.institute
24
+ )
25
+ end
26
+
27
+ subject(:deposit_handler) do
28
+ # noinspection RubyResolve
29
+ Libis::Services::Rosetta::DepositHandler.new credentials.rosetta_url,
30
+ log: credentials.debug,
31
+ log_level: credentials.debug_level
32
+ end
33
+
34
+ before :each do
35
+ deposit_handler.pds_handle = handle
36
+ end
37
+
38
+ it 'should get list of deposits by date' do
39
+
40
+ deposits = deposit_handler.get_by_submit_date('13/10/2015', '13/10/2015', status: 'All')
41
+
42
+ # noinspection RubyResolve
43
+ expect(deposits.to_hash[:records]).to eq [
44
+ {
45
+ deposit_activity_id: 55662,
46
+ creation_date: '13/10/2015',
47
+ status: 'Approved',
48
+ title: 'test ingest - 1',
49
+ producer_agent_id: credentials.admin.user_id.to_i,
50
+ submit_date: '13/10/2015',
51
+ update_date: '13/10/2015',
52
+ sip_id: 55010,
53
+ producer_id: 23106349,
54
+ sip_reason: 'Files Rejected'
55
+ }
56
+ ]
57
+ end
58
+
59
+ it 'should get list of deposits by date and material flow' do
60
+
61
+ # noinspection RubyResolve
62
+ deposits = deposit_handler.get_by_submit_flow('13/10/2015', '13/10/2015', credentials.material_flow.manual.id, status: 'All')
63
+
64
+ # noinspection RubyResolve
65
+ expect(deposits.to_hash[:records]).to eq [
66
+ {
67
+ deposit_activity_id: 55662,
68
+ creation_date: '13/10/2015',
69
+ status: 'Approved',
70
+ title: 'test ingest - 1',
71
+ producer_agent_id: credentials.admin.user_id.to_i,
72
+ submit_date: '13/10/2015',
73
+ update_date: '13/10/2015',
74
+ sip_id: 55010,
75
+ producer_id: 23106349,
76
+ sip_reason: 'Files Rejected'
77
+ }
78
+ ]
79
+ end
80
+
81
+
82
+ end
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+ require 'yaml'
4
+ require 'awesome_print'
5
+ require 'pp'
6
+
7
+ require 'libis/tools/config_file'
8
+ require 'libis/services/rosetta/pds_handler'
9
+ require 'libis/services/rosetta/ie_handler'
10
+
11
+ require_relative 'ie_data'
12
+ describe 'Rosetta IE Service' do
13
+
14
+ let(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml') }
15
+ let(:pds_handler) do
16
+ # noinspection RubyResolve
17
+ Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
18
+ end
19
+
20
+ let(:handle) do
21
+ # noinspection RubyResolve
22
+ pds_handler.login(
23
+ credentials.admin.user,
24
+ credentials.admin.password,
25
+ credentials.admin.institute
26
+ )
27
+ end
28
+
29
+ subject(:ie_handler) do
30
+ # noinspection RubyResolve
31
+ Libis::Services::Rosetta::IeHandler.new credentials.rosetta_url,
32
+ log: credentials.debug,
33
+ log_level: credentials.debug_level
34
+ end
35
+
36
+ before :each do
37
+ ie_handler.pds_handle = handle
38
+ end
39
+
40
+ it 'should get IE info' do
41
+
42
+ mets = ie_handler.get_mets('IE403595')
43
+ expect(mets).not_to be_nil
44
+ check_container expected_mets, mets
45
+ end
46
+
47
+ it 'should get IE metadata' do
48
+
49
+ metadata = ie_handler.get_metadata('IE403595')
50
+ expect(metadata).not_to be_nil
51
+ check_container(expected_ies, metadata)
52
+ end
53
+
54
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+
4
+ require 'libis/tools/config_file'
5
+ require 'libis/services/rosetta/oai_pmh'
6
+
7
+ describe 'Rosetta OAI-PMH Service' do
8
+
9
+ let(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml'), debug: true }
10
+
11
+ subject(:oai_handler) do
12
+ # noinspection RubyResolve
13
+ Libis::Services::Rosetta::OaiPmh.new credentials.rosetta_url
14
+ end
15
+
16
+ let(:expected_sets) {
17
+ {name:'TESTINS-collections', spec: 'TESTINS-collections'}
18
+ }
19
+
20
+ let(:expected_collections) {
21
+ [
22
+ 'My pictures',
23
+ 'Test Collection',
24
+ ]
25
+ }
26
+
27
+ let(:expected_records) {
28
+ [
29
+ {
30
+ id: 'oai:d4I1-pubam:IE403595',
31
+ }
32
+ ]
33
+ }
34
+
35
+ it 'should get set list' do
36
+ sets = oai_handler.sets
37
+ expect(sets).to include(expected_sets)
38
+ end
39
+
40
+ it 'should get list of collections' do
41
+ status = {}
42
+ collections = oai_handler.collections('TESTINS', status)
43
+ check_container expected_collections, collections
44
+ end
45
+
46
+ it 'should get list of records' do
47
+ status = {}
48
+ records = oai_handler.records('test_data', status)
49
+ check_container(expected_records, records)
50
+ end
51
+
52
+ end
@@ -0,0 +1,79 @@
1
+ # encoding: utf-8
2
+ require_relative 'spec_helper'
3
+ require 'yaml'
4
+
5
+ require 'libis/tools/config_file'
6
+
7
+ require 'libis/services/rosetta/pds_handler'
8
+ require 'libis/services/rosetta/producer_handler'
9
+ require 'libis/services/rosetta/deposit_handler'
10
+
11
+ describe 'Rosetta PDS Service' do
12
+
13
+ let!(:credentials) { Libis::Tools::ConfigFile.new File.join(File.dirname(__FILE__), 'credentials-test.yml') }
14
+ let!(:pds_handler) do
15
+ # noinspection RubyResolve
16
+ Libis::Services::Rosetta::PdsHandler.new(credentials.pds_url)
17
+ end
18
+
19
+ let(:handle) { pds_handler.login(admin_usr, admin_pwd, admin_ins) }
20
+
21
+ # noinspection RubyResolve
22
+ let(:admin) { credentials.admin }
23
+ # noinspection RubyResolve
24
+ let(:admin_usr) { admin.user }
25
+ # noinspection RubyResolve
26
+ let(:admin_pwd) {admin.password}
27
+ # noinspection RubyResolve
28
+ let(:admin_ins) {admin.institute}
29
+
30
+ it 'should login and return a handle' do
31
+ expect(handle).to_not be_nil
32
+ end
33
+
34
+ it 'should not login with wrong user' do
35
+ expect( pds_handler.login(
36
+ 'deadbeaf',
37
+ admin_pwd,
38
+ admin_ins
39
+ )
40
+ ).to be_nil
41
+ end
42
+
43
+ it 'should not login with wrong pasword' do
44
+ expect( pds_handler.login(
45
+ admin_usr,
46
+ 'deadbeaf',
47
+ admin_ins
48
+ )
49
+ ).to be_nil
50
+ end
51
+
52
+ it 'should not login with wrong institution' do
53
+ expect( pds_handler.login(
54
+ admin_usr,
55
+ admin_pwd,
56
+ 'deadbeaf'
57
+ )
58
+ ).to be_nil
59
+ end
60
+
61
+ it 'should return patron info' do
62
+ bor_info = pds_handler.user_info handle
63
+ expect(bor_info[:bor_info][:id]).to eq admin_usr
64
+ expect(bor_info[:bor_info][:name]).to eq admin_usr
65
+ expect(bor_info[:bor_info][:institute]).to eq admin_ins
66
+
67
+ end
68
+
69
+ it 'should logout using a valid handle' do
70
+ expect(pds_handler.logout(handle)).to be_truthy
71
+ end
72
+
73
+ it 'should logout using an invalid handle' do
74
+ # Disabled: Rosetta PDS error
75
+ # expect(pds_handler.logout('abcdef')).to be_falsy
76
+ expect(pds_handler.logout('abcdef')).to be_truthy
77
+ end
78
+
79
+ end