ddr-core 1.2.0 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- 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 +8 -0
- data/app/models/ddr/component.rb +1 -0
- 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/roles/role_types.rb +3 -2
- data/lib/ddr/core.rb +3 -0
- data/lib/ddr/core/version.rb +1 -1
- data/lib/ddr/index/connection.rb +0 -2
- data/lib/ddr/index/fields.rb +1 -0
- data/lib/ddr/index/query_result.rb +4 -3
- metadata +7 -13
- 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: f2125d4f5a524908cfa90a6412b4356d6f861841ecf73a55c16998d3d8d7707d
|
4
|
+
data.tar.gz: 0b4ba5890036dc79159b5fca1803066008c29159a99f7150bc24e3de527041c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2faaf22d64deac1fc22226a9ff958acd4385b4b2b266262c3a70cb156f65ddd86b85ef931724c17ed0004977ebe6996ac598ade8e487db8672f47cbac20243c
|
7
|
+
data.tar.gz: 7c4dda4cd1efe933faaa2fe75c5780dc85396ca6b456c45f0b1af362909c98e4abfde5f3e7cfb04aa5cbc1eb91b1709a5cf1c3125552bda8e9c8c9784d652bfb
|
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
|
data/app/models/ddr/component.rb
CHANGED
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
|
@@ -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',
|
data/lib/ddr/core/version.rb
CHANGED
data/lib/ddr/index/connection.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
|
@@ -92,9 +92,10 @@ module Ddr::Index
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def page(num)
|
95
|
-
|
96
|
-
page_size =
|
97
|
-
|
95
|
+
data = params.dup
|
96
|
+
page_size = data.delete(:rows) || PAGE_SIZE
|
97
|
+
opts = { method: :post, data: data }
|
98
|
+
response = Connection.page(num, page_size, 'select', opts)
|
98
99
|
response.docs
|
99
100
|
end
|
100
101
|
|
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.
|
4
|
+
version: 1.4.4
|
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-04-08 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
|
@@ -463,7 +457,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
463
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
|