hydra-access-controls 7.2.0 → 7.2.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5d5102b10b6d153f696ab99a80b4a7e6997b908
|
4
|
+
data.tar.gz: c609a6d44d6143918a340708aacd31b4ed2b41c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 965849b283e9754b4f2248a5c0d409622921b21cde480755e34efbcb7f9fa31d324d640855064d0d8bc672cbc630139f23905c645f83996dff7a9a40b068e55f
|
7
|
+
data.tar.gz: cd37db01c12f66a4c1563a71c26f92f5420e4a84ea00274d23bf6ef0f2eb52a727b87c01685db5f49c4e3eb0b2caef9306cb50a772ef0abb9612e6a08293b413
|
@@ -2,9 +2,12 @@ module Hydra
|
|
2
2
|
module AccessControls
|
3
3
|
module Embargoable
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
include Hydra::AccessControls::WithAccessRight
|
6
5
|
|
7
6
|
included do
|
7
|
+
include Hydra::AccessControls::WithAccessRight
|
8
|
+
# We include EmbargoableMethods so that it can override the methods included above,
|
9
|
+
# and doesn't create a ActiveSupport::Concern::MultipleIncludedBlocks
|
10
|
+
include EmbargoableMethods
|
8
11
|
validates :embargo_release_date, :lease_expiration_date, :'hydra/future_date' => true
|
9
12
|
|
10
13
|
has_attributes :visibility_during_embargo, :visibility_after_embargo, :embargo_release_date,
|
@@ -14,144 +17,146 @@ module Hydra
|
|
14
17
|
has_attributes :embargo_history, :lease_history, datastream: 'rightsMetadata', multiple:true
|
15
18
|
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def active_lease?
|
22
|
-
rightsMetadata.active_lease?
|
23
|
-
end
|
20
|
+
module EmbargoableMethods
|
21
|
+
def under_embargo?
|
22
|
+
rightsMetadata.under_embargo?
|
23
|
+
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
def visibility=(value)
|
28
|
-
# If changing from embargo or lease, deactivate the lease/embargo and wipe out the associated metadata before proceeding
|
29
|
-
if !embargo_release_date.nil?
|
30
|
-
deactivate_embargo! unless value == visibility_during_embargo
|
25
|
+
def active_lease?
|
26
|
+
rightsMetadata.active_lease?
|
31
27
|
end
|
32
|
-
|
33
|
-
|
28
|
+
|
29
|
+
# If changing away from embargo or lease, this will deactivate the lease/embargo before proceeding.
|
30
|
+
# The lease_visibility! and embargo_visibility! methods rely on this to deactivate the lease when applicable.
|
31
|
+
def visibility=(value)
|
32
|
+
# If changing from embargo or lease, deactivate the lease/embargo and wipe out the associated metadata before proceeding
|
33
|
+
if !embargo_release_date.nil?
|
34
|
+
deactivate_embargo! unless value == visibility_during_embargo
|
35
|
+
end
|
36
|
+
if !lease_expiration_date.nil?
|
37
|
+
deactivate_lease! unless value == visibility_during_lease
|
38
|
+
end
|
39
|
+
super
|
34
40
|
end
|
35
|
-
super
|
36
|
-
end
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
def apply_embargo(release_date, visibility_during=nil, visibility_after=nil)
|
43
|
+
self.embargo_release_date = release_date
|
44
|
+
self.visibility_during_embargo = visibility_during unless visibility_during.nil?
|
45
|
+
self.visibility_after_embargo = visibility_after unless visibility_after.nil?
|
46
|
+
embargo_visibility!
|
47
|
+
end
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
def deactivate_embargo!
|
50
|
+
return unless embargo_release_date
|
51
|
+
embargo_state = under_embargo? ? "active" : "expired"
|
52
|
+
embargo_record = embargo_history_message(embargo_state, Date.today, embargo_release_date, visibility_during_embargo, visibility_after_embargo)
|
53
|
+
self.embargo_release_date = nil
|
54
|
+
self.visibility_during_embargo = nil
|
55
|
+
self.visibility_after_embargo = nil
|
56
|
+
self.embargo_history += [embargo_record]
|
57
|
+
end
|
54
58
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
59
|
+
def validate_embargo
|
60
|
+
if embargo_release_date
|
61
|
+
if under_embargo?
|
62
|
+
expected_visibility = visibility_during_embargo
|
63
|
+
failure_message = "An embargo is in effect for this object until #{embargo_release_date}. Until that time the "
|
64
|
+
else
|
65
|
+
expected_visibility = visibility_after_embargo
|
66
|
+
failure_message = "The embargo expired on #{embargo_release_date}. The "
|
67
|
+
end
|
68
|
+
if visibility == expected_visibility
|
69
|
+
return true
|
70
|
+
else
|
71
|
+
failure_message << "visibility should be #{expected_visibility} but it is currently #{visibility}. Call embargo_visibility! on this object to repair."
|
72
|
+
self.errors[:embargo] << failure_message
|
73
|
+
return false
|
74
|
+
end
|
60
75
|
else
|
61
|
-
expected_visibility = visibility_after_embargo
|
62
|
-
failure_message = "The embargo expired on #{embargo_release_date}. The "
|
63
|
-
end
|
64
|
-
if visibility == expected_visibility
|
65
76
|
return true
|
66
|
-
else
|
67
|
-
failure_message << "visibility should be #{expected_visibility} but it is currently #{visibility}. Call embargo_visibility! on this object to repair."
|
68
|
-
self.errors[:embargo] << failure_message
|
69
|
-
return false
|
70
77
|
end
|
71
|
-
else
|
72
|
-
return true
|
73
78
|
end
|
74
|
-
end
|
75
79
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
# Set the current visibility to match what is described in the embargo.
|
81
|
+
def embargo_visibility!
|
82
|
+
if embargo_release_date
|
83
|
+
if under_embargo?
|
84
|
+
self.visibility_during_embargo = visibility_during_embargo ? visibility_during_embargo : Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
85
|
+
self.visibility_after_embargo = visibility_after_embargo ? visibility_after_embargo : Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
86
|
+
self.visibility = visibility_during_embargo
|
87
|
+
else
|
88
|
+
self.visibility = visibility_after_embargo ? visibility_after_embargo : Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
89
|
+
end
|
85
90
|
end
|
86
91
|
end
|
87
|
-
end
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
93
|
+
def validate_lease
|
94
|
+
if lease_expiration_date
|
95
|
+
if active_lease?
|
96
|
+
expected_visibility = visibility_during_lease
|
97
|
+
failure_message = "A lease is in effect for this object until #{lease_expiration_date}. Until that time the "
|
98
|
+
else
|
99
|
+
expected_visibility = visibility_after_lease
|
100
|
+
failure_message = "The lease expired on #{lease_expiration_date}. The "
|
101
|
+
end
|
102
|
+
if visibility == expected_visibility
|
103
|
+
return true
|
104
|
+
else
|
105
|
+
failure_message << "visibility should be #{expected_visibility} but it is currently #{visibility}. Call lease_visibility! on this object to repair."
|
106
|
+
self.errors[:lease] << failure_message
|
107
|
+
return false
|
108
|
+
end
|
94
109
|
else
|
95
|
-
expected_visibility = visibility_after_lease
|
96
|
-
failure_message = "The lease expired on #{lease_expiration_date}. The "
|
97
|
-
end
|
98
|
-
if visibility == expected_visibility
|
99
110
|
return true
|
100
|
-
else
|
101
|
-
failure_message << "visibility should be #{expected_visibility} but it is currently #{visibility}. Call lease_visibility! on this object to repair."
|
102
|
-
self.errors[:lease] << failure_message
|
103
|
-
return false
|
104
111
|
end
|
105
|
-
else
|
106
|
-
return true
|
107
112
|
end
|
108
|
-
end
|
109
113
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
114
|
+
def apply_lease(release_date, visibility_during=nil, visibility_after=nil)
|
115
|
+
self.lease_expiration_date = release_date
|
116
|
+
self.visibility_during_lease = visibility_during unless visibility_during.nil?
|
117
|
+
self.visibility_after_lease = visibility_after unless visibility_after.nil?
|
118
|
+
self.lease_visibility!
|
119
|
+
end
|
116
120
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
121
|
+
def deactivate_lease!
|
122
|
+
return unless lease_expiration_date
|
123
|
+
lease_state = active_lease? ? "active" : "expired"
|
124
|
+
lease_record = lease_history_message(lease_state, Date.today, lease_expiration_date, visibility_during_lease, visibility_after_lease)
|
125
|
+
self.lease_expiration_date = nil
|
126
|
+
self.visibility_during_lease = nil
|
127
|
+
self.visibility_after_lease = nil
|
128
|
+
self.lease_history += [lease_record]
|
129
|
+
end
|
126
130
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
# Set the current visibility to match what is described in the lease.
|
132
|
+
def lease_visibility!
|
133
|
+
if lease_expiration_date
|
134
|
+
if active_lease?
|
135
|
+
self.visibility_during_lease = visibility_during_lease ? visibility_during_lease : Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
136
|
+
self.visibility_after_lease = visibility_after_lease ? visibility_after_lease : Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
137
|
+
self.visibility = visibility_during_lease
|
138
|
+
else
|
139
|
+
self.visibility = visibility_after_lease ? visibility_after_lease : Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
|
140
|
+
end
|
136
141
|
end
|
137
142
|
end
|
138
|
-
end
|
139
143
|
|
140
|
-
|
144
|
+
protected
|
141
145
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
146
|
+
# Create the log message used when deactivating an embargo
|
147
|
+
# This method may be overriden in order to transform the values of the passed parameters.
|
148
|
+
def embargo_history_message(state, deactivate_date, release_date, visibility_during, visibility_after)
|
149
|
+
I18n.t 'hydra.embargo.history_message', state: state, deactivate_date: deactivate_date, release_date: release_date,
|
150
|
+
visibility_during: visibility_during, visibility_after: visibility_after
|
151
|
+
end
|
148
152
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
153
|
+
# Create the log message used when deactivating a lease
|
154
|
+
# This method may be overriden in order to transform the values of the passed parameters.
|
155
|
+
def lease_history_message(state, deactivate_date, expiration_date, visibility_during, visibility_after)
|
156
|
+
I18n.t 'hydra.lease.history_message', state: state, deactivate_date: deactivate_date, expiration_date: expiration_date,
|
157
|
+
visibility_during: visibility_during, visibility_after: visibility_after
|
158
|
+
end
|
159
|
+
end
|
155
160
|
end
|
156
161
|
end
|
157
162
|
end
|
@@ -3,9 +3,9 @@ module Hydra
|
|
3
3
|
module Permissions
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
extend Deprecation
|
6
|
-
include Hydra::AccessControls::Visibility
|
7
6
|
|
8
7
|
included do
|
8
|
+
include Hydra::AccessControls::Visibility
|
9
9
|
has_metadata "rightsMetadata", type: Hydra::Datastream::RightsMetadata
|
10
10
|
end
|
11
11
|
|
@@ -2,7 +2,10 @@ module Hydra
|
|
2
2
|
module AccessControls
|
3
3
|
module WithAccessRight
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
|
5
|
+
|
6
|
+
included do
|
7
|
+
include Hydra::AccessControls::Permissions
|
8
|
+
end
|
6
9
|
|
7
10
|
delegate :open_access?, :open_access_with_embargo_release_date?,
|
8
11
|
:authenticated_only_access?, :private_access?, to: :access_rights
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-access-controls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.2.
|
4
|
+
version: 7.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project:
|
239
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.4.1
|
240
240
|
signing_key:
|
241
241
|
specification_version: 4
|
242
242
|
summary: Access controls for project hydra
|