ddr-core 1.2.0.rc2 → 1.4.2

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
  SHA256:
3
- metadata.gz: 2d6925972d1974e35d35effa69d27a8b8764006e1a7554236325956ab31b674d
4
- data.tar.gz: 2e1e0c7b49694c06c031bbd44736f6a567590b1fed08a48a7e76bac31d494f22
3
+ metadata.gz: de74f6e1a261f454f1bd81773d68fa839bc9afd3e923b0c1688a6aa0baf825ea
4
+ data.tar.gz: 9081c1706672122549c6c160bdcec55d636e68f8563f087b58ca1a1bab113511
5
5
  SHA512:
6
- metadata.gz: 5646fab91d66b7c9c96a2ee38d5cc86abd0052337e2b0b3bd79a53c4b8dbbfefc0db8f61eee33261d95d898a06d5c47aa865e605dbf1aea64d5d2319d68ad6ce
7
- data.tar.gz: 650f2186d40227f43b7a6e5ba6734d3358006f103bf7dc4f472a174202e866c9660969e092f92bc8f011b0d7073ef0dc4c63ba4b4d3eb10a1d51845ea942030e
6
+ metadata.gz: 060a285208fca0a6c9c672443635637b5e79d6843504fbe6ea904b73d4af3162fb90606d3c67ee152ac364cbb7a9761a0cd775930d73d08c7d3316c15107ecb8
7
+ data.tar.gz: 71639b72040c74505c198b50408868403da5c2e1ff9d5d85969027869c57838eea1aad2f36f9de6e2544f694bfab64a4547e774a48675dbe5b73f1a195a703bd
data/Rakefile CHANGED
@@ -28,3 +28,8 @@ begin
28
28
  task default: :spec
29
29
  rescue LoadError
30
30
  end
31
+
32
+ # This allows our s2i builder image to work more smoothly
33
+ task 'tmp:create' do
34
+ Rake::Task['app:tmp:create'].invoke
35
+ end
@@ -0,0 +1,28 @@
1
+ module Ddr
2
+ module Embargoable
3
+ extend ActiveSupport::Concern
4
+
5
+ def embargo
6
+ result = available.present? ? available : parent&.available
7
+ normalize(result)
8
+ end
9
+
10
+ def embargoed?
11
+ !embargo.nil? && embargo > DateTime.now
12
+ end
13
+
14
+ private
15
+
16
+ def normalize(value)
17
+ case value
18
+ when ::Time
19
+ value.to_datetime
20
+ when ::Array
21
+ value.first
22
+ else
23
+ value
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -21,6 +21,9 @@ module Ddr
21
21
  end
22
22
 
23
23
  def find_by_permanent_id(ark)
24
+ if ark.blank?
25
+ raise ArgumentError, "ARK argument must be present."
26
+ end
24
27
  query = Ddr::Index::Query.new do
25
28
  q *:*
26
29
  where permanent_id: ark
@@ -294,6 +297,14 @@ module Ddr
294
297
  resource.children
295
298
  end
296
299
 
300
+ def embargo
301
+ resource.embargo
302
+ end
303
+
304
+ def embargoed?
305
+ resource.embargoed?
306
+ end
307
+
297
308
  private
298
309
 
299
310
  def query_service
@@ -2,6 +2,7 @@ module Ddr
2
2
  class Component < Resource
3
3
 
4
4
  include Captionable
5
+ include Embargoable
5
6
  include HasContent
6
7
  include HasExtractedText
7
8
  include HasIntermediateFile
@@ -1,61 +1,53 @@
1
- # TODO: 'https://duldev.atlassian.net/browse/DDR-1755'
2
-
3
1
  module Ddr
4
2
  class FindingAid
5
3
  attr_reader :ead_id
6
4
 
7
- EAD_XMLNS = "urn:isbn:1-931666-22-9"
8
-
9
5
  def initialize(ead_id)
10
6
  @ead_id = ead_id
11
7
  end
12
8
 
9
+ # TODO: use permalinks in the future when all finding aids have ARKs
13
10
  def url
14
- doc.css("eadid").attr("url").text
11
+ [Ddr.finding_aid_base_url, '/catalog/', ead_id].join
15
12
  end
16
13
 
17
- # The finding aid title
18
14
  def title
19
- doc.css("titleproper").children.first.text.strip
15
+ doc.fetch('normalized_title_ssm',[])&.first
20
16
  end
21
17
 
22
18
  def repository
23
- collection.xpath('ead:did/ead:repository/ead:corpname', ead: EAD_XMLNS).text
19
+ doc.fetch('repository_ssm',[])&.first
24
20
  end
25
21
 
26
22
  def collection_date_span
27
- collection.xpath('ead:did/ead:unitdate[@type="inclusive"]', ead: EAD_XMLNS).text
23
+ doc.fetch('normalized_date_ssm',[])&.first
28
24
  end
29
25
 
30
26
  def collection_number
31
- collection.xpath('ead:did/ead:unitid', ead: EAD_XMLNS).text
27
+ doc.fetch('unitid_ssm',[])&.first
32
28
  end
33
29
 
34
30
  def collection_title
35
- collection.xpath('ead:did/ead:unittitle', ead: EAD_XMLNS).text
31
+ doc.fetch('title_ssm',[])&.first
36
32
  end
37
33
 
38
34
  def extent
39
- collection.xpath('ead:did/ead:physdesc/ead:extent', ead: EAD_XMLNS).map(&:text).join("; ")
35
+ doc.fetch('extent_ssm',[]).join("; ")
40
36
  end
41
37
 
42
38
  def abstract
43
- collection.xpath('ead:did/ead:abstract', ead: EAD_XMLNS).text
39
+ first_abstract = doc.fetch('abstract_tesim',[])&.first
40
+ ActionController::Base.helpers.strip_tags(first_abstract)
44
41
  end
45
42
 
46
43
  private
47
44
 
48
- def collection
49
- doc.xpath('//ead:archdesc[@level="collection"]', ead: EAD_XMLNS)
50
- end
51
-
52
- # @raise [OpenURI::HTTPError] if 404, etc.
53
45
  def doc
54
- @doc ||= Nokogiri::XML(open(ead_xml_url))
46
+ @doc ||= JSON.parse(open(arclight_collection_data_url).read)
55
47
  end
56
48
 
57
- def ead_xml_url
58
- Ddr.ead_xml_base_url + ead_id + ".xml"
49
+ def arclight_collection_data_url
50
+ [Ddr.finding_aid_base_url, '/catalog/', ead_id, '/raw.json'].join
59
51
  end
60
52
  end
61
53
  end
@@ -1,6 +1,7 @@
1
1
  module Ddr
2
2
  class Item < Resource
3
3
 
4
+ include Embargoable
4
5
  include HasChildren
5
6
  include HasParent
6
7
  include HasStructMetadata
@@ -98,6 +98,15 @@ module Ddr
98
98
  false
99
99
  end
100
100
 
101
+ # Embargoes are enforced by the `Embargoable` concern, which overrides the `embargo` and `embargoed?` methods
102
+ def embargo
103
+ nil
104
+ end
105
+
106
+ def embargoed?
107
+ false
108
+ end
109
+
101
110
  def has_admin_policy?
102
111
  governable? && admin_policy_id.present?
103
112
  end
data/lib/ddr/auth.rb CHANGED
@@ -35,6 +35,7 @@ module Ddr
35
35
  autoload :CollectionAbilityDefinitions
36
36
  autoload :ComponentAbilityDefinitions
37
37
  autoload :ItemAbilityDefinitions
38
+ autoload :EmbargoAbilityDefinitions
38
39
  autoload :PublicationAbilityDefinitions
39
40
  autoload :LockAbilityDefinitions
40
41
  autoload :RoleBasedAbilityDefinitions
@@ -8,6 +8,7 @@ module Ddr
8
8
  ComponentAbilityDefinitions,
9
9
  AttachmentAbilityDefinitions,
10
10
  RoleBasedAbilityDefinitions,
11
+ EmbargoAbilityDefinitions,
11
12
  PublicationAbilityDefinitions,
12
13
  LockAbilityDefinitions,
13
14
  AdminSetAbilityDefinitions,
@@ -0,0 +1,18 @@
1
+ module Ddr
2
+ module Auth
3
+ class EmbargoAbilityDefinitions < AbilityDefinitions
4
+
5
+ def call
6
+ cannot :read, [::SolrDocument, Ddr::Resource] do |obj|
7
+ obj.embargoed? && cannot?(:update, obj)
8
+ end
9
+
10
+ cannot :download, [::SolrDocument, Ddr::Resource] do |obj|
11
+ obj.embargoed? && cannot?(:update, obj)
12
+ end
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -11,7 +11,7 @@ module Ddr
11
11
  obj.published? || !obj.publishable?
12
12
  end
13
13
  cannot :unpublish, Ddr::Resource do |obj|
14
- !obj.published?
14
+ !obj.published? && !obj.nonpublishable?
15
15
  end
16
16
  cannot :make_nonpublishable, Ddr::Resource do |obj|
17
17
  obj.published? || !obj.publishable?
@@ -23,7 +23,8 @@ module Ddr
23
23
  "MetadataEditor",
24
24
  "The Metadata Editor role conveys responsibility for " \
25
25
  "managing the description of a resource.",
26
- [ Permissions::DISCOVER, Permissions::READ, Permissions::DOWNLOAD, Permissions::UPDATE ]
26
+ [ Permissions::DISCOVER, Permissions::READ, Permissions::DOWNLOAD,
27
+ Permissions::UPDATE ]
27
28
  )
28
29
 
29
30
  CONTRIBUTOR = RoleType.new(
@@ -49,7 +50,7 @@ module Ddr
49
50
 
50
51
  METADATA_VIEWER = RoleType.new(
51
52
  "MetadataViewer",
52
- "The MetadataViewer role coveys access to the description of a resource.",
53
+ "The MetadataViewer role conveys access to the description of a resource.",
53
54
  [ Permissions::DISCOVER ]
54
55
  )
55
56
 
data/lib/ddr/core.rb CHANGED
@@ -84,10 +84,13 @@ module Ddr
84
84
  '.aac' => 'audio/mp4',
85
85
  '.f4a' => 'audio/mp4',
86
86
  '.flv' => 'video/flv',
87
+ '.m2t' => 'video/vnd.dlna.mpeg-tts',
88
+ '.m2ts' => 'video/m2ts',
87
89
  '.m4a' => 'audio/mp4',
88
90
  '.mov' => 'video/quicktime',
89
91
  '.mp3' => 'audio/mpeg',
90
92
  '.mp4' => 'video/mp4',
93
+ '.mts' => 'video/vnd.dlna.mpeg-tts',
91
94
  '.oga' => 'audio/ogg',
92
95
  '.ogg' => 'audio/ogg',
93
96
  '.srt' => 'text/plain',
@@ -108,10 +111,15 @@ module Ddr
108
111
  ENV["DDR_AUX_API_URL"]
109
112
  end
110
113
 
114
+ # Deprecated in ddr-core 1.2.0. Remove in future.
111
115
  mattr_accessor :ead_xml_base_url do
112
116
  ENV["EAD_XML_BASE_URL"]
113
117
  end
114
118
 
119
+ mattr_accessor :finding_aid_base_url do
120
+ ENV["FINDING_AID_BASE_URL"] || 'https://archives.lib.duke.edu'
121
+ end
122
+
115
123
  module Core
116
124
 
117
125
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Core
3
- VERSION = '1.2.0.rc2'
3
+ VERSION = '1.4.2'
4
4
  end
5
5
  end
@@ -16,6 +16,7 @@ module Ddr::Index
16
16
  ASPACE_ID = Field.new :aspace_id, :stored_sortable
17
17
  ATTACHED_FILES_HAVING_CONTENT = Field.new :attached_files_having_content, :symbol
18
18
  ATTACHED_TO_ID = Field.new :attached_to_id, :symbol
19
+ AVAILABLE = Field.new :available, :symbol
19
20
  BIBLICAL_BOOK_FACET = Field.new :biblical_book_facet, :facetable
20
21
  BOX_NUMBER_FACET = Field.new :box_number_facet, :facetable
21
22
  CATEGORY_FACET = Field.new :category_facet, :facetable
@@ -16,9 +16,9 @@ module Ddr::Index
16
16
 
17
17
  values do
18
18
  attribute :field, FieldAttribute
19
- attribute :value, String
20
- attribute :quote_value, Boolean, default: false
21
- attribute :template, String, default: STANDARD_QUERY
19
+ attribute :value, String, required: true
20
+ attribute :quote_value, Boolean, default: false
21
+ attribute :template, String, default: STANDARD_QUERY
22
22
  end
23
23
 
24
24
  def to_s
@@ -46,7 +46,7 @@ module Ddr::Index
46
46
  alias_method :id, :unique_key
47
47
 
48
48
  def where(field, value)
49
- values = Array(value)
49
+ values = Array(value)
50
50
  if values.size > 1
51
51
  disjunction(field, values)
52
52
  else
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.rc2
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
8
8
  - David Chandek-Stark
9
9
  - Ayse Durmaz
10
10
  - Hugh Cayless
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-06-19 00:00:00.000000000 Z
14
+ date: 2021-03-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activeresource
@@ -306,9 +306,9 @@ files:
306
306
  - app/assets/config/ddr_core_manifest.js
307
307
  - app/controllers/users/omniauth_callbacks_controller.rb
308
308
  - app/controllers/users/sessions_controller.rb
309
- - app/models/concerns/ddr/#search_builder_behavior.rb#
310
309
  - app/models/concerns/ddr/captionable.rb
311
310
  - app/models/concerns/ddr/describable.rb
311
+ - app/models/concerns/ddr/embargoable.rb
312
312
  - app/models/concerns/ddr/governable.rb
313
313
  - app/models/concerns/ddr/has_admin_metadata.rb
314
314
  - app/models/concerns/ddr/has_attachments.rb
@@ -320,17 +320,12 @@ files:
320
320
  - app/models/concerns/ddr/has_parent.rb
321
321
  - app/models/concerns/ddr/has_struct_metadata.rb
322
322
  - app/models/concerns/ddr/has_thumbnail.rb
323
- - app/models/concerns/ddr/search_builder_behavior.rb~
324
323
  - app/models/concerns/ddr/solr_document_behavior.rb
325
324
  - app/models/concerns/ddr/streamable.rb
326
- - app/models/ddr/#admin_set.rb#
327
- - app/models/ddr/#auxiliary_resource_cache.rb#
328
325
  - app/models/ddr/admin_set.rb
329
326
  - app/models/ddr/alert.rb
330
327
  - app/models/ddr/attachment.rb
331
328
  - app/models/ddr/auxiliary_resource.rb
332
- - app/models/ddr/auxiliary_resource.rb~
333
- - app/models/ddr/cacheable_auxiliary_resource.rb~
334
329
  - app/models/ddr/collection.rb
335
330
  - app/models/ddr/component.rb
336
331
  - app/models/ddr/contact.rb
@@ -351,7 +346,6 @@ files:
351
346
  - db/migrate/20200207194453_add_default_to_lock_version.rb
352
347
  - lib/ddr-core.rb
353
348
  - lib/ddr/auth.rb
354
- - lib/ddr/auth/#duke_person.rb#
355
349
  - lib/ddr/auth/ability.rb
356
350
  - lib/ddr/auth/ability_definitions.rb
357
351
  - lib/ddr/auth/ability_definitions/admin_set_ability_definitions.rb
@@ -359,6 +353,7 @@ files:
359
353
  - lib/ddr/auth/ability_definitions/attachment_ability_definitions.rb
360
354
  - lib/ddr/auth/ability_definitions/collection_ability_definitions.rb
361
355
  - lib/ddr/auth/ability_definitions/component_ability_definitions.rb
356
+ - lib/ddr/auth/ability_definitions/embargo_ability_definitions.rb
362
357
  - lib/ddr/auth/ability_definitions/item_ability_definitions.rb
363
358
  - lib/ddr/auth/ability_definitions/lock_ability_definitions.rb
364
359
  - lib/ddr/auth/ability_definitions/publication_ability_definitions.rb
@@ -372,7 +367,6 @@ files:
372
367
  - lib/ddr/auth/auth_context.rb
373
368
  - lib/ddr/auth/auth_context_factory.rb
374
369
  - lib/ddr/auth/detached_auth_context.rb
375
- - lib/ddr/auth/duke_directory.rb~
376
370
  - lib/ddr/auth/dynamic_groups.rb
377
371
  - lib/ddr/auth/effective_permissions.rb
378
372
  - lib/ddr/auth/effective_roles.rb
@@ -447,7 +441,7 @@ licenses:
447
441
  - BSD-3-Clause
448
442
  metadata:
449
443
  allowed_push_host: https://rubygems.org
450
- post_install_message:
444
+ post_install_message:
451
445
  rdoc_options: []
452
446
  require_paths:
453
447
  - lib
@@ -458,12 +452,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
458
452
  version: '0'
459
453
  required_rubygems_version: !ruby/object:Gem::Requirement
460
454
  requirements:
461
- - - ">"
455
+ - - ">="
462
456
  - !ruby/object:Gem::Version
463
- version: 1.3.1
457
+ version: '0'
464
458
  requirements: []
465
459
  rubygems_version: 3.0.8
466
- signing_key:
460
+ signing_key:
467
461
  specification_version: 4
468
462
  summary: Models used in the Duke Digital Repository
469
463
  test_files: []
@@ -1,10 +0,0 @@
1
- module Ddr
2
- module SearchBuilderBehavior
3
-
4
- def effective_role_filter(agents)
5
- # https://lucene.apache.org/solr/guide/7_7/other-parsers.html#term-query-parser
6
- "{!terms f=#{Ddr::Index::Fields::EFFECTIVE_ROLE} method=booleanQuery}#{agents.join(',')}"
7
- end
8
-
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- module Ddr
2
- module SearchBuilderBehavior
3
-
4
- def effective_role_filter
5
-
6
- end
7
-
8
- end
9
- end
@@ -1,26 +0,0 @@
1
- module Ddr
2
- class AdminSet < AuxiliaryResource
3
-
4
- def self.call(obj)
5
- find_by_code(obj.admin_set)
6
- rescue ActiveResource::ResourceNotFound => e
7
- raise Ddr::NotFoundError, e
8
- end
9
-
10
- def self.find_by_code(code)
11
- return unless code
12
- new get(:find, code: code)
13
- end
14
-
15
- def self.keys
16
- with_cache("keys") do
17
- all.map(&:code)
18
- end
19
- end
20
-
21
- def to_s
22
- title
23
- end
24
-
25
- end
26
- end
@@ -1,34 +0,0 @@
1
- require 'active_resource'
2
-
3
- module Ddr
4
- class AuxiliaryResourceCache < ActiveSupport::Cache::MemoryStore
5
-
6
- def initialize
7
- @_cache =
8
- end
9
-
10
- def with(key, &block)
11
- begin
12
- cache.set(key, block.call)
13
- rescue ActiveResource::ServerError => e
14
- if cache.key?(key)
15
- Rails.logger.error(e)
16
- cache.get(key)
17
- else
18
- raise
19
- end
20
- end
21
- end
22
-
23
- private
24
-
25
- def get(key)
26
- @_cache[key]
27
- end
28
-
29
- def set(key, value)
30
- @_cache[key] = value
31
- end
32
-
33
- end
34
- end
@@ -1,13 +0,0 @@
1
- require 'active_resource'
2
-
3
- module Ddr
4
- #
5
- # Abstract superclass for resources bound to ddr-aux API data
6
- #
7
- class AuxiliaryResource < ActiveResource::Base
8
-
9
- # ActiveResource freezes `site` in subclasses
10
- self.site = Ddr.ddr_aux_api_url
11
-
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- module Ddr
2
- module CacheableAuxiliaryResource
3
-
4
- def with_cache(key, &block)
5
- block.call.tap { |value| cache.write(key, value) }
6
- rescue ActiveResource::ServerError => e
7
- if value = cache.fetch(key)
8
- logger.error(e) if logger
9
- value
10
- else
11
- raise
12
- end
13
- end
14
-
15
- def cache
16
- @cache ||= ActiveSupport::Cache::MemoryStore.new
17
- end
18
-
19
- end
20
- end
@@ -1,9 +0,0 @@
1
- module Ddr::Auth
2
- class DukePerson
3
-
4
- def self.get(user)
5
-
6
- end
7
-
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module Ddr::Auth
2
- class DukeDirectory
3
-
4
-
5
-
6
- end
7
- end