ddr-core 1.2.0.rc2 → 1.4.2
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.
- checksums.yaml +4 -4
- data/Rakefile +5 -0
- data/app/models/concerns/ddr/embargoable.rb +28 -0
- data/app/models/concerns/ddr/solr_document_behavior.rb +11 -0
- data/app/models/ddr/component.rb +1 -0
- data/app/models/ddr/finding_aid.rb +13 -21
- data/app/models/ddr/item.rb +1 -0
- data/app/models/ddr/resource.rb +9 -0
- data/lib/ddr/auth.rb +1 -0
- data/lib/ddr/auth/ability.rb +1 -0
- data/lib/ddr/auth/ability_definitions/embargo_ability_definitions.rb +18 -0
- data/lib/ddr/auth/ability_definitions/publication_ability_definitions.rb +1 -1
- data/lib/ddr/auth/roles/role_types.rb +3 -2
- data/lib/ddr/core.rb +8 -0
- data/lib/ddr/core/version.rb +1 -1
- data/lib/ddr/index/fields.rb +1 -0
- data/lib/ddr/index/query_clause.rb +4 -4
- metadata +9 -15
- data/app/models/concerns/ddr/#search_builder_behavior.rb# +0 -10
- data/app/models/concerns/ddr/search_builder_behavior.rb~ +0 -9
- data/app/models/ddr/#admin_set.rb# +0 -26
- data/app/models/ddr/#auxiliary_resource_cache.rb# +0 -34
- data/app/models/ddr/auxiliary_resource.rb~ +0 -13
- data/app/models/ddr/cacheable_auxiliary_resource.rb~ +0 -20
- data/lib/ddr/auth/#duke_person.rb# +0 -9
- data/lib/ddr/auth/duke_directory.rb~ +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de74f6e1a261f454f1bd81773d68fa839bc9afd3e923b0c1688a6aa0baf825ea
|
4
|
+
data.tar.gz: 9081c1706672122549c6c160bdcec55d636e68f8563f087b58ca1a1bab113511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 060a285208fca0a6c9c672443635637b5e79d6843504fbe6ea904b73d4af3162fb90606d3c67ee152ac364cbb7a9761a0cd775930d73d08c7d3316c15107ecb8
|
7
|
+
data.tar.gz: 71639b72040c74505c198b50408868403da5c2e1ff9d5d85969027869c57838eea1aad2f36f9de6e2544f694bfab64a4547e774a48675dbe5b73f1a195a703bd
|
data/Rakefile
CHANGED
@@ -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
|
data/app/models/ddr/component.rb
CHANGED
@@ -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
|
-
|
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.
|
15
|
+
doc.fetch('normalized_title_ssm',[])&.first
|
20
16
|
end
|
21
17
|
|
22
18
|
def repository
|
23
|
-
|
19
|
+
doc.fetch('repository_ssm',[])&.first
|
24
20
|
end
|
25
21
|
|
26
22
|
def collection_date_span
|
27
|
-
|
23
|
+
doc.fetch('normalized_date_ssm',[])&.first
|
28
24
|
end
|
29
25
|
|
30
26
|
def collection_number
|
31
|
-
|
27
|
+
doc.fetch('unitid_ssm',[])&.first
|
32
28
|
end
|
33
29
|
|
34
30
|
def collection_title
|
35
|
-
|
31
|
+
doc.fetch('title_ssm',[])&.first
|
36
32
|
end
|
37
33
|
|
38
34
|
def extent
|
39
|
-
|
35
|
+
doc.fetch('extent_ssm',[]).join("; ")
|
40
36
|
end
|
41
37
|
|
42
38
|
def abstract
|
43
|
-
|
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 ||=
|
46
|
+
@doc ||= JSON.parse(open(arclight_collection_data_url).read)
|
55
47
|
end
|
56
48
|
|
57
|
-
def
|
58
|
-
Ddr.
|
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
|
data/app/models/ddr/item.rb
CHANGED
data/app/models/ddr/resource.rb
CHANGED
@@ -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
|
data/lib/ddr/auth/ability.rb
CHANGED
@@ -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,
|
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
|
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
|
data/lib/ddr/core/version.rb
CHANGED
data/lib/ddr/index/fields.rb
CHANGED
@@ -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:
|
21
|
-
attribute :template, String, default:
|
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
|
-
|
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
|
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:
|
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:
|
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,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
|