sufia-models 6.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/jobs/audit_job.rb +0 -1
- data/app/jobs/batch_update_job.rb +2 -2
- data/app/models/batch.rb +1 -1
- data/app/models/concerns/sufia/ability.rb +14 -7
- data/app/models/concerns/sufia/collection_behavior.rb +36 -3
- data/app/models/concerns/sufia/generic_file/characterization.rb +47 -18
- data/app/models/concerns/sufia/generic_file/metadata.rb +3 -0
- data/app/models/concerns/sufia/user.rb +36 -2
- data/app/models/datastreams/fits_datastream.rb +1 -5
- data/app/models/file_usage.rb +20 -3
- data/app/services/sufia/generic_file_audit_service.rb +24 -0
- data/app/services/sufia/generic_file_indexing_service.rb +3 -0
- data/app/services/sufia/noid.rb +7 -6
- data/lib/generators/sufia/models/abstract_migration_generator.rb +1 -1
- data/lib/generators/sufia/models/arkivo_api_generator.rb +39 -0
- data/lib/generators/sufia/models/cached_stats_generator.rb +1 -1
- data/lib/generators/sufia/models/clamav_generator.rb +19 -0
- data/lib/generators/sufia/models/fulltext_generator.rb +1 -1
- data/lib/generators/sufia/models/install_generator.rb +7 -1
- data/lib/generators/sufia/models/orcid_field_generator.rb +1 -1
- data/lib/generators/sufia/models/proxies_generator.rb +1 -1
- data/lib/generators/sufia/models/templates/config/arkivo.yml +6 -0
- data/lib/generators/sufia/models/templates/config/arkivo_constraint.rb +11 -0
- data/lib/generators/sufia/models/templates/config/redis_config.rb +1 -1
- data/lib/generators/sufia/models/templates/config/resque.rake +16 -0
- data/lib/generators/sufia/models/templates/config/sufia.rb +5 -8
- data/lib/generators/sufia/models/templates/config/zotero.yml +6 -0
- data/lib/generators/sufia/models/templates/migrations/add_arkivo_to_users.rb +8 -0
- data/lib/generators/sufia/models/update_content_blocks_generator.rb +1 -1
- data/lib/generators/sufia/models/upgrade400_generator.rb +2 -2
- data/lib/generators/sufia/models/usagestats_generator.rb +1 -1
- data/lib/generators/sufia/models/user_stats_generator.rb +1 -1
- data/lib/sufia/models/engine.rb +9 -9
- data/lib/sufia/models/file_content/versions.rb +0 -5
- data/lib/sufia/models/stats/user_stat_importer.rb +24 -4
- data/lib/sufia/models/utils.rb +17 -0
- data/lib/sufia/models/version.rb +1 -1
- data/lib/sufia/permissions/writable.rb +8 -7
- data/lib/tasks/migrate.rake +1 -1
- data/lib/tasks/sufia-models_tasks.rake +18 -2
- data/sufia-models.gemspec +2 -2
- metadata +30 -19
- data/app/services/sufia/id_service.rb +0 -45
- data/lib/generators/sufia/models/templates/config/mailboxer.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88115b1a7a645491dcff7e47680ae4f2f4699d5f
|
4
|
+
data.tar.gz: c6348bf5e986f9b0666b5f8c3494fc8c864e74ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f9323fcfa7cd7d73ce861dcb42c4fd2df22f7b09c3975d4fe18a654a66d39a49c07990399ef97106cfe4c9738420faafec1f0f7b3ef8c0281da8277204e3b9
|
7
|
+
data.tar.gz: bab9cc33d1e179f8b6e590429710d328c2571626a56dd4884e37ce0deb883ec2327cee36d502291f1a9c3f80d9342b1d6833eabb1a666140af81616edbbb67db
|
data/app/jobs/audit_job.rb
CHANGED
@@ -62,11 +62,11 @@ class BatchUpdateJob
|
|
62
62
|
|
63
63
|
def send_user_success_message user, batch
|
64
64
|
message = saved.count > 1 ? multiple_success(batch.id, saved) : single_success(batch.id, saved.first)
|
65
|
-
User.batchuser.send_message(user, message, success_subject,
|
65
|
+
User.batchuser.send_message(user, message, success_subject, false)
|
66
66
|
end
|
67
67
|
|
68
68
|
def send_user_failure_message user, batch
|
69
69
|
message = denied.count > 1 ? multiple_failure(batch.id, denied) : single_failure(batch.id, denied.first)
|
70
|
-
User.batchuser.send_message(user, message, failure_subject,
|
70
|
+
User.batchuser.send_message(user, message, failure_subject, false)
|
71
71
|
end
|
72
72
|
end
|
data/app/models/batch.rb
CHANGED
@@ -26,7 +26,7 @@ class Batch < ActiveFedora::Base
|
|
26
26
|
def self.safe_create(id)
|
27
27
|
begin
|
28
28
|
Batch.create(id: id)
|
29
|
-
rescue ActiveFedora::IllegalOperation
|
29
|
+
rescue ActiveFedora::IllegalOperation
|
30
30
|
# This is the exception thrown by LDP when we attempt to
|
31
31
|
# create a duplicate object. If we can find the object
|
32
32
|
# then we are good to go.
|
@@ -19,7 +19,7 @@ module Sufia
|
|
19
19
|
can :transfer, String do |id|
|
20
20
|
depositor_for_document(id) == current_user.user_key
|
21
21
|
end
|
22
|
-
can :create, ProxyDepositRequest if
|
22
|
+
can :create, ProxyDepositRequest if registered_user?
|
23
23
|
can :accept, ProxyDepositRequest, receiving_user_id: current_user.id, status: 'pending'
|
24
24
|
can :reject, ProxyDepositRequest, receiving_user_id: current_user.id, status: 'pending'
|
25
25
|
# a user who sent a proxy deposit request can cancel it if it's pending.
|
@@ -31,16 +31,16 @@ module Sufia
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def featured_work_abilities
|
34
|
-
can [:create, :destroy, :update], FeaturedWork if
|
34
|
+
can [:create, :destroy, :update], FeaturedWork if admin_user?
|
35
35
|
end
|
36
36
|
|
37
37
|
def generic_file_abilities
|
38
38
|
can :view_share_work, [GenericFile]
|
39
|
-
can :create, [GenericFile, Collection] if
|
39
|
+
can :create, [GenericFile, Collection] if registered_user?
|
40
40
|
end
|
41
41
|
|
42
42
|
def editor_abilities
|
43
|
-
if
|
43
|
+
if admin_user?
|
44
44
|
can :create, TinymceAsset
|
45
45
|
can [:create, :update], ContentBlock
|
46
46
|
end
|
@@ -53,9 +53,16 @@ module Sufia
|
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
def depositor_for_document(document_id)
|
57
|
+
::GenericFile.load_instance_from_solr(document_id).depositor
|
58
|
+
end
|
59
59
|
|
60
|
+
def registered_user?
|
61
|
+
user_groups.include? 'registered'
|
62
|
+
end
|
63
|
+
|
64
|
+
def admin_user?
|
65
|
+
user_groups.include? 'admin'
|
66
|
+
end
|
60
67
|
end
|
61
68
|
end
|
@@ -15,10 +15,43 @@ module Sufia
|
|
15
15
|
self.visibility = "open"
|
16
16
|
end
|
17
17
|
|
18
|
-
# Compute the sum of each file in the collection
|
19
|
-
#
|
18
|
+
# Compute the sum of each file in the collection using Solr to
|
19
|
+
# avoid having to hit Fedora
|
20
|
+
#
|
21
|
+
# @return [Fixnum] size of collection in bytes
|
22
|
+
# @raise [RuntimeError] unsaved record does not exist in solr
|
20
23
|
def bytes
|
21
|
-
|
24
|
+
rows = members.count
|
25
|
+
return 0 if rows == 0
|
26
|
+
|
27
|
+
raise "Collection must be saved to query for bytes" if new_record?
|
28
|
+
|
29
|
+
query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: file_model)
|
30
|
+
args = {
|
31
|
+
fq: "{!join from=hasCollectionMember_ssim to=id}id:#{id}",
|
32
|
+
fl: "id, #{file_size_field}",
|
33
|
+
rows: rows
|
34
|
+
}
|
35
|
+
|
36
|
+
files = ActiveFedora::SolrService.query(query, args)
|
37
|
+
files.reduce(0) { |sum, f| sum += f[file_size_field].to_i }
|
22
38
|
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
# Field to look up when locating the size of each file in Solr.
|
42
|
+
# Override for your own installation if using something different
|
43
|
+
def file_size_field
|
44
|
+
Solrizer.solr_name('file_size', stored_integer_descriptor)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Override if you are storing your file size in a different way
|
48
|
+
def stored_integer_descriptor
|
49
|
+
Sufia::GenericFileIndexingService::STORED_INTEGER
|
50
|
+
end
|
51
|
+
|
52
|
+
# Override if not using GenericFiles
|
53
|
+
def file_model
|
54
|
+
::GenericFile.to_class_uri
|
55
|
+
end
|
23
56
|
end
|
24
57
|
end
|
@@ -4,23 +4,52 @@ module Sufia
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
included do
|
6
6
|
contains "characterization", class_name: 'FitsDatastream'
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
7
|
+
property :mime_type, delegate_to: 'characterization', multiple: false do |index|
|
8
|
+
index.as :stored_searchable
|
9
|
+
end
|
10
|
+
property :format_label, delegate_to: 'characterization'
|
11
|
+
property :file_size, delegate_to: 'characterization'
|
12
|
+
property :last_modified, delegate_to: 'characterization'
|
13
|
+
property :filename, delegate_to: 'characterization'
|
14
|
+
property :original_checksum, delegate_to: 'characterization'
|
15
|
+
property :rights_basis, delegate_to: 'characterization'
|
16
|
+
property :copyright_basis, delegate_to: 'characterization'
|
17
|
+
property :copyright_note, delegate_to: 'characterization'
|
18
|
+
property :well_formed, delegate_to: 'characterization'
|
19
|
+
property :valid, delegate_to: 'characterization'
|
20
|
+
property :status_message, delegate_to: 'characterization'
|
21
|
+
property :file_title, delegate_to: 'characterization'
|
22
|
+
property :file_author, delegate_to: 'characterization'
|
23
|
+
property :page_count, delegate_to: 'characterization'
|
24
|
+
property :file_language, delegate_to: 'characterization'
|
25
|
+
property :word_count, delegate_to: 'characterization'
|
26
|
+
property :character_count, delegate_to: 'characterization'
|
27
|
+
property :paragraph_count, delegate_to: 'characterization'
|
28
|
+
property :line_count, delegate_to: 'characterization'
|
29
|
+
property :table_count, delegate_to: 'characterization'
|
30
|
+
property :graphics_count, delegate_to: 'characterization'
|
31
|
+
property :byte_order, delegate_to: 'characterization'
|
32
|
+
property :compression, delegate_to: 'characterization'
|
33
|
+
property :color_space, delegate_to: 'characterization'
|
34
|
+
property :profile_name, delegate_to: 'characterization'
|
35
|
+
property :profile_version, delegate_to: 'characterization'
|
36
|
+
property :orientation, delegate_to: 'characterization'
|
37
|
+
property :color_map, delegate_to: 'characterization'
|
38
|
+
property :image_producer, delegate_to: 'characterization'
|
39
|
+
property :capture_device, delegate_to: 'characterization'
|
40
|
+
property :scanning_software, delegate_to: 'characterization'
|
41
|
+
property :exif_version, delegate_to: 'characterization'
|
42
|
+
property :gps_timestamp, delegate_to: 'characterization'
|
43
|
+
property :latitude, delegate_to: 'characterization'
|
44
|
+
property :longitude, delegate_to: 'characterization'
|
45
|
+
property :character_set, delegate_to: 'characterization'
|
46
|
+
property :markup_basis, delegate_to: 'characterization'
|
47
|
+
property :markup_language, delegate_to: 'characterization'
|
48
|
+
property :bit_depth, delegate_to: 'characterization'
|
49
|
+
property :channels, delegate_to: 'characterization'
|
50
|
+
property :data_format, delegate_to: 'characterization'
|
51
|
+
property :offset, delegate_to: 'characterization'
|
52
|
+
property :frame_rate, delegate_to: 'characterization'
|
24
53
|
|
25
54
|
end
|
26
55
|
|
@@ -71,7 +100,7 @@ module Sufia
|
|
71
100
|
|
72
101
|
def characterization_terms
|
73
102
|
h = {}
|
74
|
-
|
103
|
+
FitsDatastream.terminology.terms.each_pair do |k, v|
|
75
104
|
next unless v.respond_to? :proxied_term
|
76
105
|
term = v.proxied_term
|
77
106
|
begin
|
@@ -11,6 +11,8 @@ module Sufia
|
|
11
11
|
index.as :symbol, :stored_searchable
|
12
12
|
end
|
13
13
|
|
14
|
+
property :arkivo_checksum, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#arkivoChecksum'), multiple: false
|
15
|
+
|
14
16
|
property :relative_path, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#relativePath'), multiple: false
|
15
17
|
|
16
18
|
property :import_url, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#importUrl'), multiple: false do |index|
|
@@ -91,6 +93,7 @@ module Sufia
|
|
91
93
|
rescue
|
92
94
|
puts "tables for vocabularies missing"
|
93
95
|
end
|
96
|
+
type ::RDF::URI.new('http://pcdm.org/models#Object')
|
94
97
|
end
|
95
98
|
|
96
99
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'oauth'
|
2
|
+
|
1
3
|
module Sufia::User
|
2
4
|
extend ActiveSupport::Concern
|
3
5
|
|
@@ -33,10 +35,37 @@ module Sufia::User
|
|
33
35
|
mount_uploader :avatar, AvatarUploader, mount_on: :avatar_file_name
|
34
36
|
validates_with AvatarValidator
|
35
37
|
|
38
|
+
# Add token to authenticate Arkivo API calls
|
39
|
+
after_initialize :set_arkivo_token, unless: :persisted? if Sufia.config.arkivo_api
|
40
|
+
|
36
41
|
has_many :trophies
|
37
42
|
attr_accessor :update_directory
|
38
43
|
end
|
39
44
|
|
45
|
+
def zotero_token
|
46
|
+
self[:zotero_token].blank? ? nil : Marshal::load(self[:zotero_token])
|
47
|
+
end
|
48
|
+
|
49
|
+
def zotero_token=(value)
|
50
|
+
if value.blank?
|
51
|
+
# Resetting the token
|
52
|
+
self[:zotero_token] = value
|
53
|
+
else
|
54
|
+
self[:zotero_token] = Marshal::dump(value)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_arkivo_token
|
59
|
+
self.arkivo_token ||= token_algorithm
|
60
|
+
end
|
61
|
+
|
62
|
+
def token_algorithm
|
63
|
+
loop do
|
64
|
+
token = SecureRandom.base64(24)
|
65
|
+
return token if User.find_by(arkivo_token: token).nil?
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
40
69
|
# Coerce the ORCID into URL format
|
41
70
|
def normalize_orcid
|
42
71
|
# Skip normalization if:
|
@@ -77,8 +106,13 @@ module Sufia::User
|
|
77
106
|
|
78
107
|
def trophy_files
|
79
108
|
trophies.map do |t|
|
80
|
-
|
81
|
-
|
109
|
+
begin
|
110
|
+
::GenericFile.load_instance_from_solr(t.generic_file_id)
|
111
|
+
rescue ActiveFedora::ObjectNotFoundError
|
112
|
+
logger.error("Invalid trophy for user #{user_key} (generic file id #{t.generic_file_id})")
|
113
|
+
nil
|
114
|
+
end
|
115
|
+
end.compact
|
82
116
|
end
|
83
117
|
|
84
118
|
# method needed for messaging
|
@@ -1,10 +1,6 @@
|
|
1
1
|
class FitsDatastream < ActiveFedora::OmDatastream
|
2
2
|
include OM::XML::Document
|
3
3
|
|
4
|
-
def prefix(_)
|
5
|
-
""
|
6
|
-
end
|
7
|
-
|
8
4
|
set_terminology do |t|
|
9
5
|
t.root(path: "fits",
|
10
6
|
xmlns: "http://hul.harvard.edu/ois/xml/ns/fits/fits_output",
|
@@ -12,7 +8,7 @@ class FitsDatastream < ActiveFedora::OmDatastream
|
|
12
8
|
t.identification {
|
13
9
|
t.identity {
|
14
10
|
t.format_label(path: {attribute: "format"})
|
15
|
-
t.mime_type(path: {attribute: "mimetype"}
|
11
|
+
t.mime_type(path: {attribute: "mimetype"})
|
16
12
|
}
|
17
13
|
}
|
18
14
|
t.fileinfo {
|
data/app/models/file_usage.rb
CHANGED
@@ -9,13 +9,30 @@ class FileUsage
|
|
9
9
|
|
10
10
|
self.id = id
|
11
11
|
self.path = Sufia::Engine.routes.url_helpers.generic_file_path(id)
|
12
|
-
|
13
|
-
self.created = ::GenericFile.find(id).create_date
|
14
|
-
self.created = earliest > created ? earliest : created unless earliest.blank?
|
12
|
+
self.created = date_for_analytics(file)
|
15
13
|
self.downloads = FileDownloadStat.to_flots FileDownloadStat.statistics(id, created, user_id)
|
16
14
|
self.pageviews = FileViewStat.to_flots FileViewStat.statistics(id, created, user_id)
|
17
15
|
end
|
18
16
|
|
17
|
+
# file.date_uploaded reflects the date the file was uploaded by the user
|
18
|
+
# and therefore (if available) the date that we want to use for the stats
|
19
|
+
# file.create_date reflects the date the file was added to Fedora. On data
|
20
|
+
# migrated from one repository to another the created_date can be later
|
21
|
+
# than the date the file was uploaded.
|
22
|
+
def date_for_analytics(file)
|
23
|
+
earliest = Sufia.config.analytic_start_date
|
24
|
+
date_uploaded = string_to_date file.date_uploaded
|
25
|
+
date_analytics = date_uploaded ? date_uploaded : file.create_date
|
26
|
+
return date_analytics if earliest.blank?
|
27
|
+
earliest > date_analytics ? earliest : date_analytics
|
28
|
+
end
|
29
|
+
|
30
|
+
def string_to_date(date_str)
|
31
|
+
return DateTime.parse(date_str)
|
32
|
+
rescue ArgumentError, TypeError
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
|
19
36
|
def total_downloads
|
20
37
|
self.downloads.reduce(0) { |total, result| total + result[1].to_i }
|
21
38
|
end
|
@@ -45,6 +45,17 @@ module Sufia
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def audit_stat
|
48
|
+
# Only access version if we can (file was loaded from fedora)
|
49
|
+
if generic_file.content.respond_to? :has_versions?
|
50
|
+
audit_stat_by_version
|
51
|
+
|
52
|
+
# file loaded from solr
|
53
|
+
else
|
54
|
+
audit_stat_by_id
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def audit_stat_by_version
|
48
59
|
audit_results = audit.collect { |result| result["pass"] }
|
49
60
|
|
50
61
|
# check how many non runs we had
|
@@ -59,6 +70,19 @@ module Sufia
|
|
59
70
|
end
|
60
71
|
end
|
61
72
|
|
73
|
+
# Check the file by only what is in the audit log.
|
74
|
+
# Do not try to access the versions if we do not have access to them.
|
75
|
+
# This occurs when a file is loaded from solr instead of fedora
|
76
|
+
def audit_stat_by_id
|
77
|
+
audit_results = ChecksumAuditLog.logs_for(generic_file.id, "content").collect { |result| result["pass"] }
|
78
|
+
|
79
|
+
if audit_results.length > 0
|
80
|
+
audit_results.reduce(true) { |sum, value| sum && value }
|
81
|
+
else
|
82
|
+
'Audits have not yet been run on this file.'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
62
86
|
def audit_file(file, uri, label = nil)
|
63
87
|
latest_audit = ChecksumAuditLog.logs_for(generic_file.id, file).first
|
64
88
|
return latest_audit unless needs_audit?(latest_audit)
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module Sufia
|
2
2
|
class GenericFileIndexingService < ActiveFedora::IndexingService
|
3
|
+
STORED_INTEGER = Solrizer::Descriptor.new(:integer, :stored)
|
4
|
+
|
3
5
|
def generate_solr_document
|
4
6
|
super.tap do |solr_doc|
|
5
7
|
solr_doc[Solrizer.solr_name('label')] = object.label
|
6
8
|
solr_doc[Solrizer.solr_name('file_format')] = object.file_format
|
7
9
|
solr_doc[Solrizer.solr_name('file_format', :facetable)] = object.file_format
|
8
10
|
solr_doc['all_text_timv'] = object.full_text.content
|
11
|
+
solr_doc[Solrizer.solr_name('file_size', STORED_INTEGER)] = object.content.size.to_i
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
data/app/services/sufia/noid.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_fedora/noid'
|
2
|
+
|
1
3
|
module Sufia
|
2
4
|
module Noid
|
3
5
|
extend ActiveSupport::Concern
|
@@ -5,18 +7,17 @@ module Sufia
|
|
5
7
|
## This overrides the default behavior, which is to ask Fedora for an id
|
6
8
|
# @see ActiveFedora::Persistence.assign_id
|
7
9
|
def assign_id
|
8
|
-
|
10
|
+
service.mint if Sufia.config.enable_noids
|
9
11
|
end
|
10
12
|
|
11
13
|
def to_param
|
12
14
|
id
|
13
15
|
end
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
def
|
18
|
-
|
17
|
+
private
|
18
|
+
|
19
|
+
def service
|
20
|
+
@service ||= ActiveFedora::Noid::Service.new
|
19
21
|
end
|
20
|
-
end
|
21
22
|
end
|
22
23
|
end
|
@@ -25,6 +25,6 @@ class Sufia::Models::AbstractMigrationGenerator < Rails::Generators::Base
|
|
25
25
|
def better_migration_template(file)
|
26
26
|
migration_template "migrations/#{file}", "db/migrate/#{file}"
|
27
27
|
rescue Rails::Generators::Error => e
|
28
|
-
say_status("
|
28
|
+
say_status("error", e.message, :red)
|
29
29
|
end
|
30
30
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'abstract_migration_generator'
|
2
|
+
|
3
|
+
class Sufia::Models::ArkivoApiGenerator < Sufia::Models::AbstractMigrationGenerator
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc """
|
7
|
+
This generator sets up Zotero/Arkivo API integration for your application:
|
8
|
+
"""
|
9
|
+
|
10
|
+
def banner
|
11
|
+
say_status("info", "ADDING ZOTERO/ARKIVO API INTEGRATION", :blue)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Turn on the feature set in Sufia's config
|
15
|
+
def inject_arkivo_config
|
16
|
+
inject_into_file 'config/initializers/sufia.rb', after: /^Sufia\.config do.*$/ do
|
17
|
+
"\n # Sufia can integrate with Zotero's Arkivo service for automatic deposit\n" +
|
18
|
+
" # of Zotero-managed research items.\n" +
|
19
|
+
" # Defaults to false. See README for more info\n" +
|
20
|
+
" config.arkivo_api = true\n"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Copy the routing constraint over
|
25
|
+
def copy_routing_constraint
|
26
|
+
copy_file 'config/arkivo_constraint.rb', 'config/initializers/arkivo_constraint.rb'
|
27
|
+
end
|
28
|
+
|
29
|
+
# Copy the database migration
|
30
|
+
def copy_migration
|
31
|
+
better_migration_template 'add_arkivo_to_users.rb'
|
32
|
+
end
|
33
|
+
|
34
|
+
# Copy the config files for Zotero and Arkivo
|
35
|
+
def copy_config_files
|
36
|
+
copy_file 'config/arkivo.yml', 'config/arkivo.yml'
|
37
|
+
copy_file 'config/zotero.yml', 'config/zotero.yml'
|
38
|
+
end
|
39
|
+
end
|
@@ -9,7 +9,7 @@ This generator adds the ability to cache usage stats to your application:
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
def banner
|
12
|
-
say_status("
|
12
|
+
say_status("info", "ADDING STATS CACHING-RELATED SUFIA MODELS", :blue)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Setup the database migrations
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
class Sufia::Models::ClamavGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc """
|
8
|
+
This generator makes the following changes to your application:
|
9
|
+
1. Generates clamav initializer
|
10
|
+
"""
|
11
|
+
|
12
|
+
def banner
|
13
|
+
say_status("info", "Generating clamav initializers", :blue)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_initializer_file
|
17
|
+
copy_file 'config/clamav.rb', 'config/initializers/clamav.rb'
|
18
|
+
end
|
19
|
+
end
|
@@ -11,7 +11,7 @@ This generator makes the following changes to your application:
|
|
11
11
|
"""
|
12
12
|
|
13
13
|
def banner
|
14
|
-
say_status("
|
14
|
+
say_status("info", "GENERATING SUFIA FULL-TEXT", :blue)
|
15
15
|
end
|
16
16
|
|
17
17
|
# Copy Sufia's solrconfig into the dir from which the jetty:config task pulls
|
@@ -17,7 +17,7 @@ This generator makes the following changes to your application:
|
|
17
17
|
10. Runs user stats generator
|
18
18
|
"""
|
19
19
|
def banner
|
20
|
-
say_status("
|
20
|
+
say_status("info", "GENERATING SUFIA MODELS", :blue)
|
21
21
|
end
|
22
22
|
|
23
23
|
# Setup the database migrations
|
@@ -65,6 +65,7 @@ This generator makes the following changes to your application:
|
|
65
65
|
copy_file 'config/redis_config.rb', 'config/initializers/redis_config.rb'
|
66
66
|
copy_file 'config/resque_admin.rb', 'config/initializers/resque_admin.rb'
|
67
67
|
copy_file 'config/resque_config.rb', 'config/initializers/resque_config.rb'
|
68
|
+
copy_file 'config/resque.rake', 'lib/tasks/resque.rake'
|
68
69
|
end
|
69
70
|
|
70
71
|
def create_collection
|
@@ -103,4 +104,9 @@ This generator makes the following changes to your application:
|
|
103
104
|
def user_stats
|
104
105
|
generate 'sufia:models:user_stats'
|
105
106
|
end
|
107
|
+
|
108
|
+
# Adds clamav initializtion
|
109
|
+
def clamav
|
110
|
+
generate 'sufia:models:clamav'
|
111
|
+
end
|
106
112
|
end
|
@@ -9,7 +9,7 @@ This generator adds a field to hold users' ORCIDs to your application:
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
def banner
|
12
|
-
say_status("
|
12
|
+
say_status("info", "ADDING ORCID FIELD TO USER MODEL", :blue)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Setup the database migration
|
@@ -9,7 +9,7 @@ This generator adds proxies and transfers to your application:
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
def banner
|
12
|
-
say_status("
|
12
|
+
say_status("info", "ADDING PROXY/TRANSFER-RELATED SUFIA MODELS", :blue)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Setup the database migrations
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Sufia
|
2
|
+
class ArkivoConstraint
|
3
|
+
def self.matches?(request)
|
4
|
+
# Add your own logic here to authorize trusted connections to
|
5
|
+
# the API e.g., if your installation of Arkivo runs on a host
|
6
|
+
# with the 10.0.0.3 IP address, you could use:
|
7
|
+
# request.remote_ip == '10.0.0.3'
|
8
|
+
false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -11,6 +11,7 @@ if defined?(PhusionPassenger)
|
|
11
11
|
$redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true) rescue nil
|
12
12
|
Resque.redis = $redis
|
13
13
|
Resque.redis.client.reconnect if Resque.redis
|
14
|
+
Resque.redis.namespace = "#{Sufia.config.redis_namespace}:#{Rails.env}"
|
14
15
|
end
|
15
16
|
end
|
16
17
|
else
|
@@ -18,7 +19,6 @@ else
|
|
18
19
|
$redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true) rescue nil
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
22
|
# Code borrowed from Obie's Redis patterns talk at RailsConf'12
|
23
23
|
Nest.class_eval do
|
24
24
|
def initialize(key, redis=$redis)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Load the Rails app all the time.
|
2
|
+
# See https://github.com/resque/resque/wiki/FAQ for more details
|
3
|
+
require 'resque/pool'
|
4
|
+
require 'resque/pool/tasks'
|
5
|
+
|
6
|
+
# This provides access to the Rails env within all Resque workers
|
7
|
+
task "resque:setup" => :environment
|
8
|
+
|
9
|
+
task 'resque:pool:setup' do
|
10
|
+
ActiveRecord::Base.connection.disconnect!
|
11
|
+
|
12
|
+
Resque::Pool.after_prefork do |j|
|
13
|
+
ActiveRecord::Base.establish_connection
|
14
|
+
Resque.redis.client.reconnect
|
15
|
+
end
|
16
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
|
-
# Returns an array containing the vhost 'CoSign service' value and URL
|
2
1
|
Sufia.config do |config|
|
3
|
-
|
4
|
-
config.fits_to_desc_mapping= {
|
2
|
+
config.fits_to_desc_mapping = {
|
5
3
|
file_title: :title,
|
6
4
|
file_author: :creator
|
7
5
|
}
|
@@ -118,15 +116,14 @@ Sufia.config do |config|
|
|
118
116
|
# Specify how many seconds back from the current time that we should show by default of the user's activity on the user's dashboard
|
119
117
|
# config.activity_to_show_default_seconds_since_now = 24*60*60
|
120
118
|
|
119
|
+
# Sufia can integrate with Zotero's Arkivo service for automatic deposit
|
120
|
+
# of Zotero-managed research items.
|
121
|
+
# config.arkivo_api = false
|
122
|
+
|
121
123
|
# Specify a date you wish to start collecting Google Analytic statistics for.
|
122
124
|
# Leaving it blank will set the start date to when ever the file was uploaded by
|
123
125
|
# NOTE: if you have always sent analytics to GA for downloads and page views leave this commented out
|
124
126
|
# config.analytic_start_date = DateTime.new(2014,9,10)
|
125
|
-
#
|
126
|
-
# Method of converting ids into URIs for storage in Fedora
|
127
|
-
# config.translate_uri_to_id = lambda { |uri| uri.to_s.split('/')[-1] }
|
128
|
-
# config.translate_id_to_uri = lambda { |id|
|
129
|
-
# "#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/#{Sufia::Noid.treeify(id)}" }
|
130
127
|
|
131
128
|
# If browse-everything has been configured, load the configs. Otherwise, set to nil.
|
132
129
|
begin
|
@@ -12,7 +12,7 @@ This generator for upgrading sufia-models from 3.7.2 to 4.0 makes the following
|
|
12
12
|
"""
|
13
13
|
|
14
14
|
def banner
|
15
|
-
say_status("
|
15
|
+
say_status("info", "UPGRADING SUFIA MODELS", :blue)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Setup the database migrations
|
@@ -44,7 +44,7 @@ This generator for upgrading sufia-models from 3.7.2 to 4.0 makes the following
|
|
44
44
|
" # Defaults to FALSE\n" +
|
45
45
|
" # Requires a Google Analytics id and OAuth2 keyfile. See README for more info\n" +
|
46
46
|
" #config.analytics = false\n"
|
47
|
-
|
47
|
+
end
|
48
48
|
end
|
49
49
|
|
50
50
|
# Sets up full-text indexing (Solr config + jars)
|
@@ -9,7 +9,7 @@ This generator adds usage stats methods to the user model in your application:
|
|
9
9
|
"""
|
10
10
|
|
11
11
|
def banner
|
12
|
-
say_status("
|
12
|
+
say_status("info", "ADDING USER STATS-RELATED ABILITIES TO SUFIA MODELS", :blue)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Setup the database migrations
|
data/lib/sufia/models/engine.rb
CHANGED
@@ -14,11 +14,11 @@ module Sufia
|
|
14
14
|
# Set some configuration defaults
|
15
15
|
config.persistent_hostpath = "http://localhost/files/"
|
16
16
|
config.enable_ffmpeg = false
|
17
|
-
config.noid_template = '.reeddeeddk'
|
18
17
|
config.ffmpeg_path = 'ffmpeg'
|
19
18
|
config.fits_message_length = 5
|
20
19
|
config.temp_file_base = nil
|
21
20
|
config.enable_noids = true
|
21
|
+
config.noid_template = '.reeddeeddk'
|
22
22
|
config.minter_statefile = '/tmp/minter-state'
|
23
23
|
config.redis_namespace = "sufia"
|
24
24
|
config.fits_path = "fits.sh"
|
@@ -29,14 +29,12 @@ module Sufia
|
|
29
29
|
config.queue = Sufia::Resque::Queue
|
30
30
|
config.max_notifications_for_dashboard = 5
|
31
31
|
config.activity_to_show_default_seconds_since_now = 24*60*60
|
32
|
+
config.arkivo_api = false
|
33
|
+
config.retry_unless_sleep = 0.0
|
32
34
|
|
33
|
-
# Defaulting analytic start date to
|
35
|
+
# Defaulting analytic start date to whenever the file was uploaded by leaving it blank
|
34
36
|
config.analytic_start_date = nil
|
35
37
|
|
36
|
-
config.translate_uri_to_id = lambda { |uri| uri.to_s.split('/')[-1] }
|
37
|
-
config.translate_id_to_uri = lambda { |id|
|
38
|
-
"#{ActiveFedora.fedora.host}#{ActiveFedora.fedora.base_path}/#{Sufia::Noid.treeify(id)}" }
|
39
|
-
|
40
38
|
config.autoload_paths += %W(
|
41
39
|
#{config.root}/app/models/datastreams
|
42
40
|
)
|
@@ -53,11 +51,11 @@ module Sufia
|
|
53
51
|
initializer 'requires' do
|
54
52
|
require 'activerecord-import'
|
55
53
|
require 'hydra/derivatives'
|
54
|
+
require 'active_fedora/noid'
|
56
55
|
require 'sufia/models/file_content'
|
57
56
|
require 'sufia/models/file_content/versions'
|
58
57
|
require 'sufia/models/user_local_directory_behavior'
|
59
58
|
require 'sufia/noid'
|
60
|
-
require 'sufia/id_service'
|
61
59
|
require 'sufia/analytics'
|
62
60
|
require 'sufia/pageview'
|
63
61
|
require 'sufia/download'
|
@@ -70,8 +68,10 @@ module Sufia
|
|
70
68
|
Hydra::Derivatives.fits_path = c.fits_path
|
71
69
|
Hydra::Derivatives.enable_ffmpeg = c.enable_ffmpeg
|
72
70
|
|
73
|
-
ActiveFedora::Base.translate_uri_to_id =
|
74
|
-
ActiveFedora::Base.translate_id_to_uri =
|
71
|
+
ActiveFedora::Base.translate_uri_to_id = ActiveFedora::Noid.config.translate_uri_to_id
|
72
|
+
ActiveFedora::Base.translate_id_to_uri = ActiveFedora::Noid.config.translate_id_to_uri
|
73
|
+
ActiveFedora::Noid.config.template = c.noid_template
|
74
|
+
ActiveFedora::Noid.config.statefile = c.minter_statefile
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -7,6 +7,7 @@ module Sufia
|
|
7
7
|
@verbose = options[:verbose]
|
8
8
|
@logging = options[:logging]
|
9
9
|
@delay_secs = options[:delay_secs].to_f
|
10
|
+
@number_of_retries = options[:number_of_retries].to_i
|
10
11
|
end
|
11
12
|
|
12
13
|
def import
|
@@ -14,14 +15,17 @@ module Sufia
|
|
14
15
|
sorted_users.each do |user|
|
15
16
|
start_date = date_since_last_cache(user)
|
16
17
|
|
18
|
+
# this user has already been processed today continue without delay
|
19
|
+
next if start_date.to_date >= Date.today
|
20
|
+
|
17
21
|
stats = {}
|
18
22
|
file_ids_for_user(user).each do |file_id|
|
19
|
-
view_stats = FileViewStat.statistics(file_id, start_date, user.id)
|
20
|
-
stats = tally_results(view_stats, :views, stats)
|
23
|
+
view_stats = rescue_and_retry("Retried FileViewStat on #{user} for file #{file_id} too many times.") { FileViewStat.statistics(file_id, start_date, user.id) }
|
24
|
+
stats = tally_results(view_stats, :views, stats) unless view_stats.blank?
|
21
25
|
delay
|
22
26
|
|
23
|
-
dl_stats = FileDownloadStat.statistics(file_id, start_date, user.id)
|
24
|
-
stats = tally_results(dl_stats, :downloads, stats)
|
27
|
+
dl_stats = rescue_and_retry("Retried FileDownloadStat on #{user} for file #{file_id} too many times.") { FileDownloadStat.statistics(file_id, start_date, user.id) }
|
28
|
+
stats = tally_results(dl_stats, :downloads, stats) unless dl_stats.blank?
|
25
29
|
delay
|
26
30
|
end
|
27
31
|
|
@@ -47,6 +51,22 @@ private
|
|
47
51
|
sleep @delay_secs
|
48
52
|
end
|
49
53
|
|
54
|
+
def rescue_and_retry(fail_message)
|
55
|
+
retry_count = 0
|
56
|
+
begin
|
57
|
+
return yield
|
58
|
+
rescue StandardError => e
|
59
|
+
retry_count += 1
|
60
|
+
if retry_count < @number_of_retries
|
61
|
+
delay
|
62
|
+
retry
|
63
|
+
else
|
64
|
+
log_message fail_message
|
65
|
+
log_message "Last exception #{e}"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
50
70
|
def date_since_last_cache(user)
|
51
71
|
last_cached_stat = UserStat.where(user_id: user.id).order(date: :asc).last
|
52
72
|
|
data/lib/sufia/models/utils.rb
CHANGED
@@ -1,12 +1,28 @@
|
|
1
|
+
# This module includes utility methods
|
1
2
|
module Sufia
|
2
3
|
module Utils
|
3
4
|
extend ActiveSupport::Concern
|
4
5
|
|
6
|
+
# retry the block if the conditional call is true unless we hit the maximum tries
|
7
|
+
#
|
8
|
+
# @param number_of_tries [enumerator] maximum number of times to retry the block (eg. 7.times)
|
9
|
+
# @param condition [#call] conditional to call and see if we SHOULD retry
|
10
|
+
# @yeild block [] code you want to run and retry
|
11
|
+
#
|
12
|
+
# @return result of the block call
|
5
13
|
def retry_unless(number_of_tries, condition, &block)
|
6
14
|
self.class.retry_unless(number_of_tries, condition, &block)
|
7
15
|
end
|
8
16
|
|
9
17
|
module ClassMethods
|
18
|
+
|
19
|
+
# retry the block if the conditional call is true unless we hit the maximum tries
|
20
|
+
#
|
21
|
+
# @param number_of_tries [enumerator] maximum number of times to retry the block
|
22
|
+
# @param condition [#call] conditional to call and see if we SHOULD retry
|
23
|
+
# @yeild block [] code you want to run and retry
|
24
|
+
#
|
25
|
+
# @return result of the block call
|
10
26
|
def retry_unless(number_of_tries, condition, &block)
|
11
27
|
raise ArgumentError, "First argument must be an enumerator" unless number_of_tries.is_a? Enumerator
|
12
28
|
raise ArgumentError, "Second argument must be a lambda" unless condition.respond_to? :call
|
@@ -14,6 +30,7 @@ module Sufia
|
|
14
30
|
number_of_tries.each do
|
15
31
|
result = block.call
|
16
32
|
return result unless condition.call
|
33
|
+
sleep(Sufia.config.retry_unless_sleep) if Sufia.config.retry_unless_sleep > 0
|
17
34
|
end
|
18
35
|
raise RuntimeError, "retry_unless could not complete successfully. Try upping the # of tries?"
|
19
36
|
end
|
data/lib/sufia/models/version.rb
CHANGED
@@ -13,7 +13,7 @@ module Sufia
|
|
13
13
|
|
14
14
|
def paranoid_permissions
|
15
15
|
valid = true
|
16
|
-
|
16
|
+
paranoid_edit_permissions.each do |validation|
|
17
17
|
if validation[:condition].call(self)
|
18
18
|
errors[validation[:key]] ||= []
|
19
19
|
errors[validation[:key]] << validation[:message]
|
@@ -23,12 +23,13 @@ module Sufia
|
|
23
23
|
return valid
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
def paranoid_edit_permissions
|
27
|
+
[
|
28
|
+
{key: :edit_users, message: 'Depositor must have edit access', condition: lambda { |obj| !obj.edit_users.include?(obj.depositor) }},
|
29
|
+
{key: :edit_groups, message: 'Public cannot have edit access', condition: lambda { |obj| obj.edit_groups.include?('public') }},
|
30
|
+
{key: :edit_groups, message: 'Registered cannot have edit access', condition: lambda { |obj| obj.edit_groups.include?('registered') }}
|
31
|
+
]
|
32
|
+
end
|
32
33
|
|
33
34
|
def clear_permissions!
|
34
35
|
self.permissions = []
|
data/lib/tasks/migrate.rake
CHANGED
@@ -8,6 +8,20 @@ namespace :solr do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
namespace :sufia do
|
11
|
+
namespace :user do
|
12
|
+
desc 'Populate user tokens'
|
13
|
+
task tokens: :environment do
|
14
|
+
unless Sufia.config.arkivo_api
|
15
|
+
puts "Zotero integration is not enabled"
|
16
|
+
next
|
17
|
+
end
|
18
|
+
User.where(arkivo_token: nil).each do |user|
|
19
|
+
user.set_arkivo_token
|
20
|
+
user.save
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
11
25
|
namespace :jetty do
|
12
26
|
|
13
27
|
FULLTEXT_JARS = %w(
|
@@ -66,8 +80,10 @@ end
|
|
66
80
|
|
67
81
|
def download_from_maven url, dst
|
68
82
|
full_url = '/remotecontent?filepath=' + url
|
69
|
-
file = File.open(dst, "
|
70
|
-
Net::HTTP.
|
83
|
+
file = File.open(dst, "wb")
|
84
|
+
endpoint = Net::HTTP.new('search.maven.org', 443)
|
85
|
+
endpoint.use_ssl = true
|
86
|
+
endpoint.start do |http|
|
71
87
|
puts "Fetching #{full_url}"
|
72
88
|
begin
|
73
89
|
http.request_get(full_url) do |resp|
|
data/sufia-models.gemspec
CHANGED
@@ -30,13 +30,13 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency 'activeresource', "~> 4.0" # No longer a dependency of rails 4.0
|
31
31
|
|
32
32
|
spec.add_dependency "hydra-head", "~> 9.0"
|
33
|
-
spec.add_dependency "active-fedora", "~> 9.
|
33
|
+
spec.add_dependency "active-fedora", "~> 9.1", ">= 9.1.1"
|
34
34
|
spec.add_dependency "hydra-collections", [">= 5.0.2", "< 6.0"]
|
35
35
|
spec.add_dependency 'hydra-derivatives', '~> 1.0'
|
36
|
+
spec.add_dependency 'active_fedora-noid', '~> 0.1'
|
36
37
|
spec.add_dependency 'nest', '~> 1.1'
|
37
38
|
spec.add_dependency 'resque', '~> 1.23'
|
38
39
|
spec.add_dependency 'resque-pool', '~> 0.3'
|
39
|
-
spec.add_dependency 'noid', '~> 0.6'
|
40
40
|
spec.add_dependency 'mailboxer', '~> 0.12'
|
41
41
|
spec.add_dependency 'acts_as_follower', '>= 0.1.1', '< 0.3'
|
42
42
|
spec.add_dependency 'carrierwave', '~> 0.9'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sufia-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,20 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '9.
|
89
|
+
version: '9.1'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 9.1.1
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
97
|
- - "~>"
|
95
98
|
- !ruby/object:Gem::Version
|
96
|
-
version: '9.
|
99
|
+
version: '9.1'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 9.1.1
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: hydra-collections
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,61 +135,61 @@ dependencies:
|
|
129
135
|
- !ruby/object:Gem::Version
|
130
136
|
version: '1.0'
|
131
137
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
138
|
+
name: active_fedora-noid
|
133
139
|
requirement: !ruby/object:Gem::Requirement
|
134
140
|
requirements:
|
135
141
|
- - "~>"
|
136
142
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
143
|
+
version: '0.1'
|
138
144
|
type: :runtime
|
139
145
|
prerelease: false
|
140
146
|
version_requirements: !ruby/object:Gem::Requirement
|
141
147
|
requirements:
|
142
148
|
- - "~>"
|
143
149
|
- !ruby/object:Gem::Version
|
144
|
-
version: '
|
150
|
+
version: '0.1'
|
145
151
|
- !ruby/object:Gem::Dependency
|
146
|
-
name:
|
152
|
+
name: nest
|
147
153
|
requirement: !ruby/object:Gem::Requirement
|
148
154
|
requirements:
|
149
155
|
- - "~>"
|
150
156
|
- !ruby/object:Gem::Version
|
151
|
-
version: '1.
|
157
|
+
version: '1.1'
|
152
158
|
type: :runtime
|
153
159
|
prerelease: false
|
154
160
|
version_requirements: !ruby/object:Gem::Requirement
|
155
161
|
requirements:
|
156
162
|
- - "~>"
|
157
163
|
- !ruby/object:Gem::Version
|
158
|
-
version: '1.
|
164
|
+
version: '1.1'
|
159
165
|
- !ruby/object:Gem::Dependency
|
160
|
-
name: resque
|
166
|
+
name: resque
|
161
167
|
requirement: !ruby/object:Gem::Requirement
|
162
168
|
requirements:
|
163
169
|
- - "~>"
|
164
170
|
- !ruby/object:Gem::Version
|
165
|
-
version: '
|
171
|
+
version: '1.23'
|
166
172
|
type: :runtime
|
167
173
|
prerelease: false
|
168
174
|
version_requirements: !ruby/object:Gem::Requirement
|
169
175
|
requirements:
|
170
176
|
- - "~>"
|
171
177
|
- !ruby/object:Gem::Version
|
172
|
-
version: '
|
178
|
+
version: '1.23'
|
173
179
|
- !ruby/object:Gem::Dependency
|
174
|
-
name:
|
180
|
+
name: resque-pool
|
175
181
|
requirement: !ruby/object:Gem::Requirement
|
176
182
|
requirements:
|
177
183
|
- - "~>"
|
178
184
|
- !ruby/object:Gem::Version
|
179
|
-
version: '0.
|
185
|
+
version: '0.3'
|
180
186
|
type: :runtime
|
181
187
|
prerelease: false
|
182
188
|
version_requirements: !ruby/object:Gem::Requirement
|
183
189
|
requirements:
|
184
190
|
- - "~>"
|
185
191
|
- !ruby/object:Gem::Version
|
186
|
-
version: '0.
|
192
|
+
version: '0.3'
|
187
193
|
- !ruby/object:Gem::Dependency
|
188
194
|
name: mailboxer
|
189
195
|
requirement: !ruby/object:Gem::Requirement
|
@@ -377,30 +383,35 @@ files:
|
|
377
383
|
- app/services/sufia/analytics.rb
|
378
384
|
- app/services/sufia/generic_file_audit_service.rb
|
379
385
|
- app/services/sufia/generic_file_indexing_service.rb
|
380
|
-
- app/services/sufia/id_service.rb
|
381
386
|
- app/services/sufia/noid.rb
|
382
387
|
- app/services/sufia/repository_audit_service.rb
|
383
388
|
- config/locales/sufia.en.yml
|
384
389
|
- lib/generators/sufia/models/abstract_migration_generator.rb
|
390
|
+
- lib/generators/sufia/models/arkivo_api_generator.rb
|
385
391
|
- lib/generators/sufia/models/cached_stats_generator.rb
|
392
|
+
- lib/generators/sufia/models/clamav_generator.rb
|
386
393
|
- lib/generators/sufia/models/fulltext_generator.rb
|
387
394
|
- lib/generators/sufia/models/install_generator.rb
|
388
395
|
- lib/generators/sufia/models/orcid_field_generator.rb
|
389
396
|
- lib/generators/sufia/models/proxies_generator.rb
|
390
397
|
- lib/generators/sufia/models/templates/app/models/collection.rb
|
391
398
|
- lib/generators/sufia/models/templates/config/analytics.yml
|
399
|
+
- lib/generators/sufia/models/templates/config/arkivo.yml
|
400
|
+
- lib/generators/sufia/models/templates/config/arkivo_constraint.rb
|
392
401
|
- lib/generators/sufia/models/templates/config/clamav.rb
|
393
|
-
- lib/generators/sufia/models/templates/config/mailboxer.rb
|
394
402
|
- lib/generators/sufia/models/templates/config/mime_types.rb
|
395
403
|
- lib/generators/sufia/models/templates/config/redis.yml
|
396
404
|
- lib/generators/sufia/models/templates/config/redis_config.rb
|
397
405
|
- lib/generators/sufia/models/templates/config/resque-pool.yml
|
406
|
+
- lib/generators/sufia/models/templates/config/resque.rake
|
398
407
|
- lib/generators/sufia/models/templates/config/resque_admin.rb
|
399
408
|
- lib/generators/sufia/models/templates/config/resque_config.rb
|
400
409
|
- lib/generators/sufia/models/templates/config/setup_mail.rb
|
401
410
|
- lib/generators/sufia/models/templates/config/solrconfig.xml
|
402
411
|
- lib/generators/sufia/models/templates/config/sufia.rb
|
412
|
+
- lib/generators/sufia/models/templates/config/zotero.yml
|
403
413
|
- lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb
|
414
|
+
- lib/generators/sufia/models/templates/migrations/add_arkivo_to_users.rb
|
404
415
|
- lib/generators/sufia/models/templates/migrations/add_avatars_to_users.rb
|
405
416
|
- lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb
|
406
417
|
- lib/generators/sufia/models/templates/migrations/add_groups_to_users.rb
|
@@ -470,7 +481,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
470
481
|
version: '0'
|
471
482
|
requirements: []
|
472
483
|
rubyforge_project:
|
473
|
-
rubygems_version: 2.4.
|
484
|
+
rubygems_version: 2.4.5
|
474
485
|
signing_key:
|
475
486
|
specification_version: 4
|
476
487
|
summary: Models and services for sufia
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'noid'
|
2
|
-
|
3
|
-
module Sufia
|
4
|
-
module IdService
|
5
|
-
|
6
|
-
def self.noid_template
|
7
|
-
Sufia.config.noid_template
|
8
|
-
end
|
9
|
-
|
10
|
-
@minter = ::Noid::Minter.new(template: noid_template)
|
11
|
-
@semaphore = Mutex.new
|
12
|
-
def self.valid?(identifier)
|
13
|
-
# remove the fedora namespace since it's not part of the noid
|
14
|
-
noid = identifier#.split(":").last
|
15
|
-
@minter.valid? noid
|
16
|
-
end
|
17
|
-
def self.mint
|
18
|
-
@semaphore.synchronize do
|
19
|
-
while true
|
20
|
-
id = self.next_id
|
21
|
-
return id unless ActiveFedora::Base.exists?(id)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
protected
|
27
|
-
|
28
|
-
def self.next_id
|
29
|
-
id = ''
|
30
|
-
File.open(Sufia.config.minter_statefile, File::RDWR|File::CREAT, 0644) do |f|
|
31
|
-
f.flock(File::LOCK_EX)
|
32
|
-
yaml = YAML::load(f.read)
|
33
|
-
yaml = {template: noid_template} unless yaml
|
34
|
-
minter = ::Noid::Minter.new(yaml)
|
35
|
-
id = minter.mint
|
36
|
-
f.rewind
|
37
|
-
yaml = YAML::dump(minter.dump)
|
38
|
-
f.write yaml
|
39
|
-
f.flush
|
40
|
-
f.truncate(f.pos)
|
41
|
-
end
|
42
|
-
id
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
Mailboxer.setup do |config|
|
2
|
-
|
3
|
-
#Configures if you applications uses or no the email sending for Notifications and Messages
|
4
|
-
config.uses_emails = true
|
5
|
-
|
6
|
-
#Configures the default from for the email sent for Messages and Notifications of Mailboxer
|
7
|
-
config.default_from = "no-reply@mailboxer.com"
|
8
|
-
|
9
|
-
#Configures the methods needed by mailboxer
|
10
|
-
config.email_method = :mailboxer_email
|
11
|
-
config.name_method = :name
|
12
|
-
|
13
|
-
#Configures if you use or not a search engine and wich one are you using
|
14
|
-
#Supported enignes: [:solr,:sphinx]
|
15
|
-
config.search_enabled = false
|
16
|
-
config.search_engine = :solr
|
17
|
-
end
|