ddr-models 2.11.0 → 3.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +7 -6
  4. data/Gemfile +2 -3
  5. data/Rakefile +5 -5
  6. data/app/controllers/users/sessions_controller.rb +5 -0
  7. data/app/helpers/models_helper.rb +7 -0
  8. data/app/models/attachment.rb +3 -5
  9. data/app/models/collection.rb +12 -79
  10. data/app/models/component.rb +8 -67
  11. data/app/models/item.rb +8 -73
  12. data/app/models/target.rb +6 -5
  13. data/config/initializers/active_fedora_base.rb +11 -30
  14. data/config/initializers/{active_fedora_datastream.rb → active_fedora_file.rb} +1 -1
  15. data/config/initializers/devise.rb +2 -3
  16. data/config/initializers/subscriptions.rb +2 -19
  17. data/ddr-models.gemspec +10 -14
  18. data/lib/ddr/actions/fixity_check.rb +1 -1
  19. data/lib/ddr/actions/virus_check.rb +17 -10
  20. data/lib/ddr/auth.rb +6 -38
  21. data/lib/ddr/auth/ability.rb +1 -5
  22. data/lib/ddr/auth/ability_definitions/collection_ability_definitions.rb +0 -16
  23. data/lib/ddr/auth/ability_definitions/datastream_ability_definitions.rb +10 -4
  24. data/lib/ddr/auth/ability_definitions/role_based_ability_definitions.rb +16 -9
  25. data/lib/ddr/auth/ability_factory.rb +25 -2
  26. data/lib/ddr/auth/abstract_ability.rb +1 -2
  27. data/lib/ddr/auth/auth_context.rb +0 -18
  28. data/lib/ddr/auth/auth_context_factory.rb +2 -0
  29. data/lib/ddr/auth/group.rb +0 -6
  30. data/lib/ddr/auth/grouper_gateway.rb +0 -24
  31. data/lib/ddr/auth/permissions.rb +1 -12
  32. data/lib/ddr/auth/role_based_access_controls_enforcement.rb +5 -5
  33. data/lib/ddr/auth/roles.rb +1 -11
  34. data/lib/ddr/auth/roles/role_set.rb +0 -7
  35. data/lib/ddr/auth/roles/roles_datastream.rb +9 -0
  36. data/lib/ddr/contacts.rb +25 -0
  37. data/lib/ddr/datastreams.rb +10 -28
  38. data/lib/ddr/datastreams/datastream_behavior.rb +30 -100
  39. data/lib/ddr/datastreams/descriptive_metadata_datastream.rb +28 -31
  40. data/lib/ddr/datastreams/fits_datastream.rb +9 -22
  41. data/lib/ddr/datastreams/metadata_datastream.rb +17 -31
  42. data/lib/ddr/derivatives.rb +13 -16
  43. data/lib/ddr/derivatives/derivative.rb +68 -0
  44. data/lib/ddr/derivatives/{generator.rb → generators/generator.rb} +11 -7
  45. data/lib/ddr/derivatives/generators/png_generator.rb +23 -0
  46. data/lib/ddr/derivatives/generators/ptif_generator.rb +56 -0
  47. data/lib/ddr/derivatives/multires_image.rb +59 -0
  48. data/lib/ddr/derivatives/thumbnail.rb +36 -0
  49. data/lib/ddr/events.rb +0 -1
  50. data/lib/ddr/events/deletion_event.rb +9 -5
  51. data/lib/ddr/events/event.rb +8 -13
  52. data/lib/ddr/events/fixity_check_event.rb +0 -6
  53. data/lib/ddr/events/ingestion_event.rb +9 -5
  54. data/lib/ddr/events/update_event.rb +4 -17
  55. data/lib/ddr/index.rb +4 -4
  56. data/lib/ddr/index/abstract_query_result.rb +4 -3
  57. data/lib/ddr/index/connection.rb +9 -28
  58. data/lib/ddr/index/csv_query_result.rb +32 -47
  59. data/lib/ddr/index/field.rb +1 -11
  60. data/lib/ddr/index/fields.rb +16 -99
  61. data/lib/ddr/index/filter.rb +30 -103
  62. data/lib/ddr/index/filters.rb +19 -0
  63. data/lib/ddr/index/query.rb +11 -58
  64. data/lib/ddr/index/query_builder.rb +36 -147
  65. data/lib/ddr/index/query_clause.rb +19 -79
  66. data/lib/ddr/index/query_result.rb +4 -36
  67. data/lib/ddr/index/query_value.rb +18 -0
  68. data/lib/ddr/index/response.rb +2 -19
  69. data/lib/ddr/jobs.rb +12 -0
  70. data/lib/ddr/jobs/fits_file_characterization.rb +51 -0
  71. data/lib/ddr/jobs/permanent_id.rb +23 -0
  72. data/lib/ddr/managers.rb +1 -0
  73. data/lib/ddr/managers/derivatives_manager.rb +53 -93
  74. data/lib/ddr/managers/permanent_id_manager.rb +91 -0
  75. data/lib/ddr/managers/technical_metadata_manager.rb +10 -24
  76. data/lib/ddr/managers/workflow_manager.rb +10 -29
  77. data/lib/ddr/models.rb +50 -101
  78. data/lib/ddr/models/access_controllable.rb +12 -0
  79. data/lib/ddr/models/admin_set.rb +5 -16
  80. data/lib/ddr/models/base.rb +45 -165
  81. data/lib/ddr/models/describable.rb +19 -21
  82. data/lib/ddr/models/engine.rb +11 -39
  83. data/lib/ddr/models/error.rb +0 -3
  84. data/lib/ddr/models/file_management.rb +36 -72
  85. data/lib/ddr/models/finding_aid.rb +2 -35
  86. data/lib/ddr/models/fixity_checkable.rb +4 -0
  87. data/lib/ddr/models/governable.rb +3 -1
  88. data/lib/ddr/models/has_admin_metadata.rb +82 -56
  89. data/lib/ddr/models/has_attachments.rb +3 -1
  90. data/lib/ddr/models/has_children.rb +3 -7
  91. data/lib/ddr/models/has_content.rb +35 -32
  92. data/lib/ddr/models/has_multires_image.rb +7 -12
  93. data/lib/ddr/models/has_struct_metadata.rb +44 -6
  94. data/lib/ddr/models/has_thumbnail.rb +1 -4
  95. data/lib/ddr/models/indexing.rb +97 -186
  96. data/lib/ddr/models/licenses/admin_policy_license.rb +11 -0
  97. data/lib/ddr/models/licenses/effective_license.rb +9 -0
  98. data/lib/ddr/models/licenses/inherited_license.rb +9 -0
  99. data/lib/ddr/models/licenses/license.rb +21 -0
  100. data/lib/ddr/models/licenses/parent_license.rb +11 -0
  101. data/lib/ddr/models/metadata/descriptive_metadata.rb +50 -0
  102. data/lib/ddr/models/metadata/metadata.rb +37 -0
  103. data/lib/ddr/models/metadata/metadata_mapper.rb +32 -0
  104. data/lib/ddr/models/metadata/metadata_mappers.rb +18 -0
  105. data/lib/ddr/models/metadata/metadata_term.rb +24 -0
  106. data/lib/ddr/models/metadata/metadata_vocabularies.rb +18 -0
  107. data/lib/ddr/models/metadata/metadata_vocabulary.rb +34 -0
  108. data/lib/ddr/models/solr_document.rb +24 -156
  109. data/lib/ddr/models/struct_div.rb +63 -0
  110. data/lib/ddr/models/structure.rb +39 -175
  111. data/lib/ddr/models/version.rb +1 -1
  112. data/lib/ddr/models/year_facet.rb +118 -60
  113. data/lib/ddr/notifications.rb +12 -10
  114. data/lib/ddr/utils.rb +15 -28
  115. data/lib/ddr/vocab.rb +17 -15
  116. data/lib/ddr/vocab/asset.rb +17 -42
  117. data/lib/ddr/vocab/contact.rb +7 -5
  118. data/lib/ddr/vocab/display.rb +8 -6
  119. data/lib/ddr/vocab/duke_terms.rb +10 -8
  120. data/lib/ddr/vocab/rdf_vocabulary_parser.rb +39 -37
  121. data/lib/ddr/vocab/roles.rb +19 -17
  122. data/lib/ddr/vocab/sources/duketerms.rdf +8 -22
  123. data/lib/ddr/vocab/vocabulary.rb +26 -26
  124. data/spec/auth/ability_factory_spec.rb +1 -18
  125. data/spec/auth/ability_spec.rb +15 -119
  126. data/spec/auth/effective_permissions_spec.rb +1 -1
  127. data/spec/auth/effective_roles_spec.rb +1 -1
  128. data/spec/auth/ldap_gateway_spec.rb +9 -0
  129. data/spec/contacts/contacts_spec.rb +26 -0
  130. data/spec/controllers/including_role_based_access_controls_enforcement_spec.rb +5 -5
  131. data/spec/derivatives/multires_image_spec.rb +48 -0
  132. data/spec/derivatives/png_generator_spec.rb +8 -13
  133. data/spec/derivatives/ptif_generator_spec.rb +11 -9
  134. data/spec/derivatives/thumbnail_spec.rb +48 -0
  135. data/spec/dummy/config/environments/test.rb +1 -1
  136. data/spec/dummy/db/schema.rb +23 -25
  137. data/spec/factories/attachment_factories.rb +2 -2
  138. data/spec/factories/collection_factories.rb +2 -3
  139. data/spec/factories/component_factories.rb +2 -2
  140. data/spec/factories/item_factories.rb +2 -2
  141. data/spec/factories/structure_factories.rb +2 -8
  142. data/spec/factories/test_model_factories.rb +12 -4
  143. data/spec/fixtures/fits/document.xml +44 -42
  144. data/spec/fixtures/fits/image.xml +41 -42
  145. data/spec/helpers/models_helper_spec.rb +11 -0
  146. data/spec/index/filter_spec.rb +30 -208
  147. data/spec/index/filters_spec.rb +17 -0
  148. data/spec/index/query_spec.rb +10 -82
  149. data/spec/jobs/fits_file_characterization_spec.rb +52 -0
  150. data/spec/managers/derivatives_manager_spec.rb +105 -107
  151. data/spec/managers/technical_metadata_manager_spec.rb +27 -34
  152. data/spec/models/active_fedora_base_spec.rb +105 -5
  153. data/spec/models/active_fedora_datastream_spec.rb +39 -106
  154. data/spec/models/admin_set_spec.rb +10 -43
  155. data/spec/models/attachment_spec.rb +2 -3
  156. data/spec/models/collection_spec.rb +11 -225
  157. data/spec/models/component_spec.rb +4 -106
  158. data/spec/models/descriptive_metadata_spec.rb +38 -0
  159. data/spec/models/effective_license_spec.rb +64 -0
  160. data/spec/models/events_spec.rb +59 -52
  161. data/spec/models/file_management_spec.rb +13 -113
  162. data/spec/models/finding_aid_spec.rb +8 -31
  163. data/spec/models/has_admin_metadata_spec.rb +122 -131
  164. data/spec/models/has_children_spec.rb +3 -3
  165. data/spec/models/has_struct_metadata_spec.rb +37 -50
  166. data/spec/models/indexing_spec.rb +23 -160
  167. data/spec/models/item_spec.rb +2 -133
  168. data/spec/models/license_spec.rb +24 -0
  169. data/spec/models/solr_document_spec.rb +47 -236
  170. data/spec/models/struct_div_spec.rb +70 -0
  171. data/spec/models/structure_spec.rb +11 -89
  172. data/spec/models/target_spec.rb +2 -4
  173. data/spec/models/year_facet_spec.rb +23 -50
  174. data/spec/spec_helper.rb +13 -17
  175. data/spec/support/ezid_mock_identifier.rb +2 -2
  176. data/spec/support/shared_examples_for_auth_contexts.rb +0 -33
  177. data/spec/support/shared_examples_for_ddr_models.rb +94 -142
  178. data/spec/support/shared_examples_for_describables.rb +36 -31
  179. data/spec/support/shared_examples_for_governables.rb +2 -3
  180. data/spec/support/shared_examples_for_has_content.rb +46 -101
  181. data/spec/support/shared_examples_for_indexing.rb +6 -6
  182. data/spec/support/shared_examples_for_non_collection_models.rb +1 -32
  183. data/spec/support/structural_metadata_helper.rb +59 -230
  184. data/spec/utils_spec.rb +2 -0
  185. metadata +96 -229
  186. data/.ruby-version +0 -1
  187. data/config/initializers/rsolr_monkey_patches.rb +0 -7
  188. data/config/initializers/rubydora_monkey_patch.rb +0 -11
  189. data/config/locales/ddr-models.en.yml +0 -81
  190. data/db/migrate/20161021201011_add_permanent_id_to_events.rb +0 -8
  191. data/lib/ddr/auth/ability_definitions/admin_set_ability_definitions.rb +0 -9
  192. data/lib/ddr/auth/ability_definitions/lock_ability_definitions.rb +0 -13
  193. data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +0 -16
  194. data/lib/ddr/datastreams/administrative_metadata_datastream.rb +0 -75
  195. data/lib/ddr/datastreams/caption_datastream.rb +0 -5
  196. data/lib/ddr/datastreams/content_datastream.rb +0 -17
  197. data/lib/ddr/datastreams/delete_external_files.rb +0 -29
  198. data/lib/ddr/datastreams/external_file_datastream.rb +0 -80
  199. data/lib/ddr/datastreams/intermediate_file_datastream.rb +0 -5
  200. data/lib/ddr/datastreams/multires_image_datastream.rb +0 -5
  201. data/lib/ddr/datastreams/streamable_media_datastream.rb +0 -5
  202. data/lib/ddr/derivatives/png_generator.rb +0 -17
  203. data/lib/ddr/derivatives/ptif_generator.rb +0 -55
  204. data/lib/ddr/derivatives/update_derivatives.rb +0 -25
  205. data/lib/ddr/events/deaccession_event.rb +0 -8
  206. data/lib/ddr/index/field_attribute.rb +0 -22
  207. data/lib/ddr/index/query_params.rb +0 -40
  208. data/lib/ddr/index/sort_order.rb +0 -28
  209. data/lib/ddr/models/cache.rb +0 -20
  210. data/lib/ddr/models/captionable.rb +0 -37
  211. data/lib/ddr/models/contact.rb +0 -23
  212. data/lib/ddr/models/file_characterization.rb +0 -37
  213. data/lib/ddr/models/has_intermediate_file.rb +0 -41
  214. data/lib/ddr/models/language.rb +0 -31
  215. data/lib/ddr/models/media_type.rb +0 -22
  216. data/lib/ddr/models/permanent_id.rb +0 -240
  217. data/lib/ddr/models/rights_statement.rb +0 -25
  218. data/lib/ddr/models/streamable.rb +0 -37
  219. data/lib/ddr/models/structures/agent.rb +0 -49
  220. data/lib/ddr/models/structures/component_type_term.rb +0 -29
  221. data/lib/ddr/models/structures/div.rb +0 -64
  222. data/lib/ddr/models/structures/f_locat.rb +0 -54
  223. data/lib/ddr/models/structures/file.rb +0 -52
  224. data/lib/ddr/models/structures/file_grp.rb +0 -35
  225. data/lib/ddr/models/structures/file_sec.rb +0 -22
  226. data/lib/ddr/models/structures/fptr.rb +0 -31
  227. data/lib/ddr/models/structures/mets_hdr.rb +0 -37
  228. data/lib/ddr/models/structures/mptr.rb +0 -49
  229. data/lib/ddr/models/structures/struct_map.rb +0 -40
  230. data/lib/ddr/models/with_content_file.rb +0 -37
  231. data/spec/datastreams/external_file_datastream_spec.rb +0 -48
  232. data/spec/dummy/config/structure_component_type.yml +0 -18
  233. data/spec/fixtures/abcd1234.vtt +0 -38
  234. data/spec/fixtures/arrow1rightred_e0.gif +0 -0
  235. data/spec/fixtures/extractedText1.txt +0 -1
  236. data/spec/fixtures/extractedText2.txt +0 -1
  237. data/spec/fixtures/extractedText3.txt +0 -3
  238. data/spec/fixtures/imageA.jpg +0 -0
  239. data/spec/fixtures/imageB.jpg +0 -0
  240. data/spec/index/csv_query_result_spec.rb +0 -44
  241. data/spec/index/fields_spec.rb +0 -380
  242. data/spec/index/query_builder_spec.rb +0 -140
  243. data/spec/index/query_clause_spec.rb +0 -68
  244. data/spec/models/cache_spec.rb +0 -32
  245. data/spec/models/contact_spec.rb +0 -56
  246. data/spec/models/descriptive_metadata_datastream_spec.rb +0 -139
  247. data/spec/models/file_characterization_spec.rb +0 -39
  248. data/spec/models/language_spec.rb +0 -59
  249. data/spec/models/media_type_spec.rb +0 -46
  250. data/spec/models/permanent_id_spec.rb +0 -432
  251. data/spec/models/rights_statement_spec.rb +0 -55
  252. data/spec/models/structures/agent_spec.rb +0 -30
  253. data/spec/models/structures/component_type_term_spec.rb +0 -14
  254. data/spec/models/structures/div_spec.rb +0 -26
  255. data/spec/models/structures/f_locat_spec.rb +0 -78
  256. data/spec/models/structures/file_grp_spec.rb +0 -23
  257. data/spec/models/structures/file_sec_spec.rb +0 -22
  258. data/spec/models/structures/file_spec.rb +0 -60
  259. data/spec/models/structures/fptr_spec.rb +0 -23
  260. data/spec/models/structures/mets_hdr_spec.rb +0 -26
  261. data/spec/models/structures/mptr_spec.rb +0 -25
  262. data/spec/models/structures/struct_map_spec.rb +0 -24
  263. data/spec/models/with_content_file_spec.rb +0 -37
  264. data/spec/support/shared_examples_for_associations.rb +0 -8
  265. data/spec/support/shared_examples_for_captionable.rb +0 -23
  266. data/spec/support/shared_examples_for_has_intermediate_file.rb +0 -28
  267. data/spec/support/shared_examples_for_publication.rb +0 -43
  268. data/spec/support/shared_examples_for_streamable_media.rb +0 -23
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora
2
- class Datastream
2
+ class File
3
3
  include Ddr::Datastreams::DatastreamBehavior
4
4
  end
5
5
  end
@@ -218,15 +218,14 @@ Devise.setup do |config|
218
218
  # Explicit require is needed here for devise to find strategy
219
219
  require "omniauth-shibboleth"
220
220
  config.omniauth :shibboleth, {
221
- uid_field: lambda { |rpm| rpm.call("eppn") || rpm.call("duDukeID") },
221
+ uid_field: "eppn",
222
222
  name_field: "displayName",
223
223
  info_fields: {
224
224
  email: "mail",
225
225
  first_name: "givenName",
226
226
  last_name: "sn",
227
227
  nickname: "eduPersonNickname"
228
- },
229
- extra_fields: ["duDukeID"],
228
+ }
230
229
  }
231
230
 
232
231
  # ==> Warden configuration
@@ -8,28 +8,11 @@ ActiveSupport::Notifications.subscribe(Ddr::Notifications::FIXITY_CHECK, Ddr::Ev
8
8
  # Virus Checks
9
9
  ActiveSupport::Notifications.subscribe(Ddr::Notifications::VIRUS_CHECK, Ddr::Events::VirusCheckEvent)
10
10
 
11
- # Ingestion/Creation
11
+ # Creation
12
12
  ActiveSupport::Notifications.subscribe(Ddr::Notifications::CREATION, Ddr::Events::CreationEvent)
13
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::INGEST, Ddr::Events::IngestionEvent)
14
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::INGEST, Ddr::Derivatives::UpdateDerivatives)
15
13
 
16
14
  # Update
17
15
  ActiveSupport::Notifications.subscribe(Ddr::Notifications::UPDATE, Ddr::Events::UpdateEvent)
18
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::UPDATE, Ddr::Events::UpdateEvent)
19
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::UPDATE, Ddr::Models::PermanentId)
20
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::UPDATE, Ddr::Derivatives::UpdateDerivatives)
21
16
 
22
- # Delete
17
+ # Deletion
23
18
  ActiveSupport::Notifications.subscribe(Ddr::Notifications::DELETION, Ddr::Events::DeletionEvent)
24
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DELETE, Ddr::Models::PermanentId)
25
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DELETE, Ddr::Events::DeletionEvent)
26
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DELETE, Ddr::Datastreams::DeleteExternalFiles)
27
-
28
- # Deaccession
29
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DEACCESSION, Ddr::Models::PermanentId)
30
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DEACCESSION, Ddr::Events::DeaccessionEvent)
31
- ActiveSupport::Notifications.subscribe(Ddr::Models::Base::DEACCESSION, Ddr::Datastreams::DeleteExternalFiles)
32
-
33
- # Files
34
- ActiveSupport::Notifications.subscribe(Ddr::Datastreams::DELETE, Ddr::Derivatives::UpdateDerivatives)
35
- ActiveSupport::Notifications.subscribe(Ddr::Datastreams::DELETE, Ddr::Datastreams::DeleteExternalFiles)
@@ -18,32 +18,28 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.require_paths = ["lib", "app/models"]
20
20
 
21
- s.add_dependency "rails", ">= 4.2.7", "< 5" # Hydra 7.x not compatible/tested with Rails 5
22
- s.add_dependency "activeresource"
23
- s.add_dependency "active-fedora", ">= 7.3.1", "< 8"
24
- s.add_dependency "rubydora", "~> 2.0"
25
- s.add_dependency "hydra-core", "~> 7.2"
21
+ s.add_dependency "rails", "~> 4.1.13"
22
+ s.add_dependency "active-triples", "~> 0.7.2"
23
+ s.add_dependency "active-fedora", "~> 9.5"
24
+ s.add_dependency "hydra-core", "~> 9.3"
26
25
  s.add_dependency "hydra-validations", "~> 0.5"
27
26
  s.add_dependency "devise", "~> 3.4"
28
27
  s.add_dependency "omniauth-shibboleth", "~> 1.2.0"
29
28
  s.add_dependency "grouper-rest-client"
30
- s.add_dependency "ezid-client", "~> 1.6"
29
+ s.add_dependency "ezid-client", "~> 1.1", ">= 1.1.1"
31
30
  s.add_dependency "resque", "~> 1.25"
32
31
  s.add_dependency "rdf-vocab", "~> 0.8"
33
- s.add_dependency "net-ldap", "~> 0.16"
32
+ s.add_dependency "net-ldap", "~> 0.11"
34
33
  s.add_dependency "cancancan", "~> 1.12"
35
- s.add_dependency "ddr-antivirus", "~> 2.1.1"
36
- s.add_dependency "virtus", "~> 1.0.5"
37
- s.add_dependency "hashie", "~> 3.4", "< 3.4.4"
38
- s.add_dependency "edtf", "~> 3.0"
34
+ s.add_dependency "ddr-aux-client", "~> 1.2", ">= 1.2.2"
35
+ s.add_dependency "ddr-antivirus", "2.0.0"
39
36
 
40
- s.add_development_dependency "bundler", "~> 1.11"
37
+ s.add_development_dependency "bundler", "~> 1.10"
41
38
  s.add_development_dependency "rake"
42
39
  s.add_development_dependency "sqlite3"
43
40
  s.add_development_dependency "rspec-rails", "~> 3.1"
44
41
  s.add_development_dependency "rspec-its"
45
42
  s.add_development_dependency "factory_girl_rails", "~> 4.4"
46
- s.add_development_dependency "jettywrapper", "~> 1.8"
43
+ s.add_development_dependency "jettywrapper", "~> 2.0"
47
44
  s.add_development_dependency "database_cleaner"
48
- s.add_development_dependency "byebug"
49
45
  end
@@ -12,7 +12,7 @@ module Ddr
12
12
  # Return result of fixity check
13
13
  def self._execute(object)
14
14
  Result.new(pid: object.pid).tap do |r|
15
- object.datastreams_having_content.each do |dsid, ds|
15
+ object.datastreams_to_validate.each do |dsid, ds|
16
16
  r.success &&= ds.dsChecksumValid
17
17
  r.results[dsid] = ds.profile
18
18
  end
@@ -1,20 +1,27 @@
1
+ require "open3"
2
+ require "ostruct"
3
+ require "shellwords"
4
+
1
5
  module Ddr::Actions
2
6
  class VirusCheck
3
7
 
4
8
  # @return [Hash] result data
5
9
  # @raises [Ddr::Antivirus::VirusFoundError]
6
10
  def self.call(file_path)
7
- Hash.new.tap do |result|
8
- begin
9
- scan_result = Ddr::Antivirus.scan(file_path)
10
- rescue Ddr::Antivirus::ScannerError => e
11
- result[:exception] = [e.class.name, e.to_s]
12
- scan_result = e.result
13
- end
14
- result[:event_date_time] = scan_result.scanned_at
15
- result[:software] = scan_result.version
16
- result[:detail] = scan_result.output
11
+ unless File.exist?(file_path)
12
+ raise Error, "File not found: #{file_path}"
13
+ end
14
+ result = {}
15
+ begin
16
+ scan_result = Ddr::Antivirus.scan(file_path)
17
+ rescue Ddr::Antivirus::ScannerError => e
18
+ result[:exception] = [e.class.name, e.to_s]
19
+ scan_result = e.result
17
20
  end
21
+ result[:event_date_time] = scan_result.scanned_at
22
+ result[:software] = scan_result.version
23
+ result[:detail] = scan_result.output
24
+ result
18
25
  end
19
26
 
20
27
  end
@@ -1,7 +1,6 @@
1
1
  module Ddr
2
2
  module Auth
3
3
  extend ActiveSupport::Autoload
4
- extend Deprecation
5
4
 
6
5
  autoload :Ability
7
6
  autoload :AbilityDefinitions
@@ -32,7 +31,6 @@ module Ddr
32
31
  autoload :WebAuthContext
33
32
 
34
33
  autoload_under 'ability_definitions' do
35
- autoload :AdminSetAbilityDefinitions
36
34
  autoload :AliasAbilityDefinitions
37
35
  autoload :AttachmentAbilityDefinitions
38
36
  autoload :CollectionAbilityDefinitions
@@ -40,8 +38,6 @@ module Ddr
40
38
  autoload :DatastreamAbilityDefinitions
41
39
  autoload :EventAbilityDefinitions
42
40
  autoload :ItemAbilityDefinitions
43
- autoload :PublicationAbilityDefinitions
44
- autoload :LockAbilityDefinitions
45
41
  autoload :RoleBasedAbilityDefinitions
46
42
  autoload :SuperuserAbilityDefinitions
47
43
  end
@@ -52,40 +48,15 @@ module Ddr
52
48
  # Name of group whose members are authorized to create Collections
53
49
  mattr_accessor :collection_creators_group
54
50
 
55
- # Name of group whose members are authorized to act as a metadata manager
56
- mattr_accessor :metadata_managers_group
57
-
58
- # Group of which everyone (including anonymous users) is a member
59
- def self.everyone_group
60
- Deprecation.warn(Ddr::Auth,
61
- "`Ddr::Auth.everyone_group` is deprecated and will be removed in ddr-models 3.0." \
62
- " Use `Ddr::Auth::Groups::PUBLIC` instead.")
63
- Groups::PUBLIC
64
- end
65
-
66
- # Group of authenticated users
67
- def self.authenticated_users_group
68
- Deprecation.warn(Ddr::Auth,
69
- "`Ddr::Auth.authenticated_users_group` is deprecated and will be removed in ddr-models 3.0." \
70
- " Use `Ddr::Auth::Groups::REGISTERED` instead.")
71
- Groups::REGISTERED
72
- end
73
-
74
- def self.const_missing(name)
75
- if name == :Superuser
76
- Deprecation.warn(Ddr::Auth,
77
- "`Ddr::Auth::Superuser` is deprecated and will be removed in ddr-models 3.0." \
78
- " Use `Ddr::Auth::SuperuserAbility` instead.")
79
- return SuperuserAbility
80
- end
81
- super
82
- end
83
-
84
51
  # Whether to require Shibboleth authentication
85
52
  mattr_accessor :require_shib_user_authn do
86
53
  false
87
54
  end
88
55
 
56
+ mattr_accessor :sso_logout_url do
57
+ "/Shibboleth.sso/Logout?return=https://shib.oit.duke.edu/cgi-bin/logout.pl"
58
+ end
59
+
89
60
  # Grouper gateway implementation
90
61
  mattr_accessor :grouper_gateway do
91
62
  GrouperGateway
@@ -100,11 +71,8 @@ module Ddr
100
71
  "::Ability"
101
72
  end
102
73
 
103
- def self.repository_group_filter
104
- if filter = ENV["REPOSITORY_GROUP_FILTER"]
105
- return filter
106
- end
107
- raise Ddr::Models::Error, "The \"REPOSITORY_GROUP_FILTER\" environment variable is not set."
74
+ mattr_accessor :repository_group_filter do
75
+ ENV["REPOSITORY_GROUP_FILTER"]
108
76
  end
109
77
 
110
78
  end
@@ -9,11 +9,7 @@ module Ddr
9
9
  AttachmentAbilityDefinitions,
10
10
  RoleBasedAbilityDefinitions,
11
11
  DatastreamAbilityDefinitions,
12
- EventAbilityDefinitions,
13
- PublicationAbilityDefinitions,
14
- LockAbilityDefinitions,
15
- AdminSetAbilityDefinitions,
16
- ]
12
+ EventAbilityDefinitions ]
17
13
 
18
14
  end
19
15
  end
@@ -6,22 +6,6 @@ module Ddr
6
6
  if member_of? Ddr::Auth.collection_creators_group
7
7
  can :create, ::Collection
8
8
  end
9
- can :export, ::Collection do |obj|
10
- has_policy_permission?(obj, Permissions::READ)
11
- end
12
- end
13
-
14
- private
15
-
16
- def policy_permissions(obj)
17
- obj.roles
18
- .in_policy_scope
19
- .agent(agents)
20
- .permissions
21
- end
22
-
23
- def has_policy_permission?(obj, perm)
24
- policy_permissions(obj).include?(perm)
25
9
  end
26
10
 
27
11
  end
@@ -9,22 +9,28 @@ module Ddr
9
9
  # course by the :manage ability.
10
10
  DATASTREAM_DOWNLOAD_ABILITIES = {
11
11
  Ddr::Datastreams::CONTENT => :download,
12
- Ddr::Datastreams::DESC_METADATA => :read,
13
12
  Ddr::Datastreams::EXTRACTED_TEXT => :download,
14
13
  Ddr::Datastreams::FITS => :read,
15
- Ddr::Datastreams::MULTIRES_IMAGE => :read,
16
14
  Ddr::Datastreams::STRUCT_METADATA => :read,
17
15
  Ddr::Datastreams::THUMBNAIL => :read,
18
16
  }.freeze
19
17
 
20
18
  def call
21
- can :download, ActiveFedora::Datastream do |ds|
22
- can_download_datastream?(ds.dsid, ds.pid)
19
+ can :download, ActiveFedora::File do |file|
20
+ can_download_datastream?(_dsid(file), _pid(file))
23
21
  end
24
22
  end
25
23
 
26
24
  private
27
25
 
26
+ def _dsid(file)
27
+ File.basename(file.id)
28
+ end
29
+
30
+ def _pid(file)
31
+ File.dirname(file.id)
32
+ end
33
+
28
34
  def can_download_datastream?(dsid, pid)
29
35
  can? DATASTREAM_DOWNLOAD_ABILITIES.fetch(dsid), pid
30
36
  rescue KeyError
@@ -12,20 +12,19 @@ module Ddr
12
12
 
13
13
  private
14
14
 
15
- def has_permission?(permission, object_or_id)
16
- permissions(object_or_id).include? permission
15
+ def has_permission?(permission, obj)
16
+ permissions(obj).include? permission
17
17
  end
18
18
 
19
- def permissions(object_or_id)
20
- case object_or_id
19
+ def permissions(obj)
20
+ case obj
21
21
  when Ddr::Models::Base, SolrDocument
22
- cached_permissions(object_or_id.id) do
23
- object_or_id.effective_permissions(agents)
22
+ cached_permissions obj.pid do
23
+ obj.effective_permissions(agents)
24
24
  end
25
25
  when String
26
- cached_permissions(object_or_id) do
27
- doc = SolrDocument.find(object_or_id) # raises SolrDocument::NotFound
28
- doc.effective_permissions(agents)
26
+ cached_permissions obj do
27
+ permissions_doc(obj).effective_permissions(agents)
29
28
  end
30
29
  end
31
30
  end
@@ -34,6 +33,14 @@ module Ddr
34
33
  cache[pid] ||= block.call
35
34
  end
36
35
 
36
+ def permissions_doc(pid)
37
+ roles_query_result = ActiveFedora::SolrService.query("id:\"#{pid}\"", rows: 1).first
38
+ if roles_query_result.nil?
39
+ raise "Solr document not found for PID \"#{pid}\"."
40
+ end
41
+ SolrDocument.new roles_query_result
42
+ end
43
+
37
44
  end
38
45
  end
39
46
  end
@@ -1,9 +1,32 @@
1
1
  module Ddr::Auth
2
2
  class AbilityFactory
3
3
 
4
+ private_class_method :new
5
+
4
6
  def self.call(user = nil, env = nil)
5
- auth_context = AuthContextFactory.call(user, env)
6
- auth_context.ability
7
+ new(user, env).call
8
+ end
9
+
10
+ attr_reader :auth_context
11
+
12
+ delegate :anonymous?, :superuser?, to: :auth_context
13
+
14
+ def initialize(user, env)
15
+ @auth_context = AuthContextFactory.call(user, env)
16
+ end
17
+
18
+ def call
19
+ if anonymous?
20
+ AnonymousAbility.new(auth_context)
21
+ elsif superuser?
22
+ SuperuserAbility.new(auth_context)
23
+ else
24
+ default_ability.new(auth_context)
25
+ end
26
+ end
27
+
28
+ def default_ability
29
+ Ddr::Auth::default_ability.constantize
7
30
  end
8
31
 
9
32
  end
@@ -17,8 +17,7 @@ module Ddr::Auth
17
17
 
18
18
  attr_reader :auth_context
19
19
 
20
- delegate :anonymous?, :authenticated?, :metadata_manager?,
21
- :user, :groups, :agents, :member_of?,
20
+ delegate :anonymous?, :authenticated?, :user, :groups, :agents, :member_of?,
22
21
  :authorized_to_act_as_superuser?,
23
22
  to: :auth_context
24
23
 
@@ -9,20 +9,6 @@ module Ddr::Auth
9
9
  @env = env
10
10
  end
11
11
 
12
- def ability
13
- if anonymous?
14
- AnonymousAbility.new(self)
15
- elsif superuser?
16
- SuperuserAbility.new(self)
17
- else
18
- default_ability_class.new(self)
19
- end
20
- end
21
-
22
- def default_ability_class
23
- Ddr::Auth::default_ability.constantize
24
- end
25
-
26
12
  # Return whether a user is absent from the auth context.
27
13
  # @return [Boolean]
28
14
  def anonymous?
@@ -41,10 +27,6 @@ module Ddr::Auth
41
27
  env && env.key?("warden") && env["warden"].authenticate?(scope: :superuser)
42
28
  end
43
29
 
44
- def metadata_manager?
45
- member_of? Ddr::Auth.metadata_managers_group
46
- end
47
-
48
30
  # Return the user agent for this context.
49
31
  # @return [String] or nil, if auth context is anonymous/
50
32
  def agent
@@ -1,6 +1,8 @@
1
1
  module Ddr::Auth
2
2
  class AuthContextFactory
3
3
 
4
+ private_class_method :new
5
+
4
6
  def self.call(user = nil, env = nil)
5
7
  if env
6
8
  WebAuthContext.new(user, env)
@@ -4,7 +4,6 @@ module Ddr
4
4
  module Auth
5
5
  # Wraps a String
6
6
  class Group < SimpleDelegator
7
- extend Deprecation
8
7
 
9
8
  attr_reader :rule
10
9
 
@@ -32,11 +31,6 @@ module Ddr
32
31
  to_s
33
32
  end
34
33
 
35
- def to_agent
36
- Deprecation.warn(self.class, "`to_agent` is deprecated. Use `agent` instead.")
37
- agent
38
- end
39
-
40
34
  def inspect
41
35
  "#<#{self.class.name} id=#{id.inspect}, label=#{label.inspect}>"
42
36
  end