sufia-models 3.4.0 → 3.5.0
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/app/models/datastreams/fits_datastream.rb +10 -1
- data/lib/generators/sufia/models/install_generator.rb +1 -1
- data/lib/sufia/models/generic_file.rb +3 -0
- data/lib/sufia/models/generic_file/actions.rb +8 -11
- data/lib/sufia/models/generic_file/characterization.rb +19 -4
- data/lib/sufia/models/generic_file/virus_check.rb +33 -0
- data/lib/sufia/models/generic_file/web_form.rb +2 -3
- data/lib/sufia/models/jobs/import_url_job.rb +29 -31
- data/lib/sufia/models/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7000540d10c6082fbe78b05a2043eb11f555635
|
4
|
+
data.tar.gz: 60e2c7dc3e31acd37648c671f5df9835f151b913
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61cb90f5d5c5cbf94aca85a2e23a69f20b03b33105808febb2492c4cc55779c49177abbbcfcbdf65b276617281ccf86eadcb2b55674e2c94130cf4364225c2ed
|
7
|
+
data.tar.gz: d0226b74b4c91b7ee635afdf6f37baacd31e8025b53e079a1c123cfa97f1fbd2dfc7851c585f82053e498ab12857600041047d5fce3bbe7541ae69424e762caf
|
@@ -70,7 +70,11 @@ class FitsDatastream < ActiveFedora::OmDatastream
|
|
70
70
|
t.offset(:path=>"offset")
|
71
71
|
}
|
72
72
|
t.video {
|
73
|
-
|
73
|
+
t.width(:path=>"imageWidth")
|
74
|
+
t.height(:path=>"imageHeight")
|
75
|
+
t.duration(:path=>"duration")
|
76
|
+
t.sample_rate(:path=>"sampleRate")
|
77
|
+
t.frame_rate(:path=>"frameRate")
|
74
78
|
}
|
75
79
|
}
|
76
80
|
t.format_label(:proxy=>[:identification, :identity, :format_label])
|
@@ -98,7 +102,9 @@ class FitsDatastream < ActiveFedora::OmDatastream
|
|
98
102
|
t.byte_order(:proxy=>[:metadata, :image, :byte_order])
|
99
103
|
t.compression(:proxy=>[:metadata, :image, :compression])
|
100
104
|
t.width(:proxy=>[:metadata, :image, :width])
|
105
|
+
t.video_width( :proxy=>[:metadata, :video, :width])
|
101
106
|
t.height(:proxy=>[:metadata, :image, :height])
|
107
|
+
t.video_height(:proxy=>[:metadata, :video, :height])
|
102
108
|
t.color_space(:proxy=>[:metadata, :image, :color_space])
|
103
109
|
t.profile_name(:proxy=>[:metadata, :image, :profile_name])
|
104
110
|
t.profile_version(:proxy=>[:metadata, :image, :profile_version])
|
@@ -115,11 +121,14 @@ class FitsDatastream < ActiveFedora::OmDatastream
|
|
115
121
|
t.markup_basis(:proxy=>[:metadata, :text, :markup_basis])
|
116
122
|
t.markup_language(:proxy=>[:metadata, :text, :markup_language])
|
117
123
|
t.duration(:proxy=>[:metadata, :audio, :duration])
|
124
|
+
t.video_duration(:proxy=>[:metadata, :video, :duration])
|
118
125
|
t.bit_depth(:proxy=>[:metadata, :audio, :bit_depth])
|
119
126
|
t.sample_rate(:proxy=>[:metadata, :audio, :sample_rate])
|
127
|
+
t.video_sample_rate(:proxy=>[:metadata, :video, :sample_rate])
|
120
128
|
t.channels(:proxy=>[:metadata, :audio, :channels])
|
121
129
|
t.data_format(:proxy=>[:metadata, :audio, :data_format])
|
122
130
|
t.offset(:proxy=>[:metadata, :audio, :offset])
|
131
|
+
t.frame_rate(:proxy=>[:metadata, :video, :frame_rate])
|
123
132
|
end
|
124
133
|
|
125
134
|
def self.xml_template
|
@@ -55,7 +55,7 @@ This generator makes the following changes to your application:
|
|
55
55
|
def inject_sufia_user_behavior
|
56
56
|
file_path = "app/models/#{model_name.underscore}.rb"
|
57
57
|
if File.exists?(file_path)
|
58
|
-
|
58
|
+
inject_into_file file_path, after: /include Hydra\:\:User.*$/ do
|
59
59
|
"# Connects this user object to Sufia behaviors. " +
|
60
60
|
"\n include Sufia::User\n"
|
61
61
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'sufia/virus_found_error'
|
1
2
|
module Sufia
|
2
3
|
module GenericFile
|
3
4
|
extend ActiveSupport::Concern
|
@@ -9,6 +10,7 @@ module Sufia
|
|
9
10
|
autoload :Trophies, 'sufia/models/generic_file/trophies'
|
10
11
|
autoload :Metadata, 'sufia/models/generic_file/metadata'
|
11
12
|
autoload :Versions, 'sufia/models/generic_file/versions'
|
13
|
+
autoload :VirusCheck, 'sufia/models/generic_file/virus_check'
|
12
14
|
include Sufia::ModelMethods
|
13
15
|
include Sufia::Noid
|
14
16
|
include Sufia::GenericFile::MimeTypes
|
@@ -22,6 +24,7 @@ module Sufia
|
|
22
24
|
include Sufia::GenericFile::Trophies
|
23
25
|
include Sufia::GenericFile::Metadata
|
24
26
|
include Sufia::GenericFile::Versions
|
27
|
+
include Sufia::GenericFile::VirusCheck
|
25
28
|
|
26
29
|
included do
|
27
30
|
belongs_to :batch, :property => :is_part_of
|
@@ -2,7 +2,6 @@ module Sufia::GenericFile
|
|
2
2
|
# Actions are decoupled from controller logic so that they may be called from a controller or a background job.
|
3
3
|
module Actions
|
4
4
|
def self.create_metadata(generic_file, user, batch_id)
|
5
|
-
|
6
5
|
generic_file.apply_depositor_metadata(user)
|
7
6
|
generic_file.date_uploaded = Date.today
|
8
7
|
generic_file.date_modified = Date.today
|
@@ -16,7 +15,7 @@ module Sufia::GenericFile
|
|
16
15
|
yield(generic_file) if block_given?
|
17
16
|
generic_file.save!
|
18
17
|
end
|
19
|
-
|
18
|
+
|
20
19
|
def self.create_content(generic_file, file, file_name, dsid, user)
|
21
20
|
generic_file.add_file(file, dsid, file_name)
|
22
21
|
|
@@ -40,15 +39,13 @@ module Sufia::GenericFile
|
|
40
39
|
end
|
41
40
|
|
42
41
|
def self.virus_check(file)
|
43
|
-
|
44
|
-
|
45
|
-
logger.warn "Virus checking
|
46
|
-
|
47
|
-
else
|
48
|
-
logger.warn "Virus checking disabled for #{file.inspect}"
|
49
|
-
0
|
42
|
+
path = file.is_a?(String) ? file : file.path
|
43
|
+
unless defined?(ClamAV)
|
44
|
+
logger.warn "Virus checking disabled, #{path} not checked"
|
45
|
+
return
|
50
46
|
end
|
51
|
-
|
52
|
-
|
47
|
+
scan_result = ClamAV.instance.scanfile(path)
|
48
|
+
raise Sufia::VirusFoundError.new("A virus was found in #{path}: #{scan_result}") unless scan_result == 0
|
49
|
+
end
|
53
50
|
end
|
54
51
|
end
|
@@ -13,21 +13,36 @@ module Sufia
|
|
13
13
|
:file_language, :word_count, :character_count,
|
14
14
|
:paragraph_count, :line_count, :table_count,
|
15
15
|
:graphics_count, :byte_order, :compression,
|
16
|
-
:
|
16
|
+
:color_space, :profile_name,
|
17
17
|
:profile_version, :orientation, :color_map,
|
18
18
|
:image_producer, :capture_device,
|
19
19
|
:scanning_software, :exif_version,
|
20
20
|
:gps_timestamp, :latitude, :longitude,
|
21
21
|
:character_set, :markup_basis,
|
22
|
-
:markup_language, :
|
23
|
-
:
|
22
|
+
:markup_language, :bit_depth,
|
23
|
+
:channels, :data_format, :offset, :frame_rate, datastream: :characterization, multiple: true
|
24
24
|
|
25
25
|
end
|
26
26
|
|
27
|
+
def width
|
28
|
+
characterization.width.blank? ? characterization.video_width : characterization.width
|
29
|
+
end
|
30
|
+
|
31
|
+
def height
|
32
|
+
characterization.height.blank? ? characterization.video_height : characterization.height
|
33
|
+
end
|
34
|
+
|
35
|
+
def duration
|
36
|
+
characterization.duration.blank? ? characterization.video_duration : characterization.duration
|
37
|
+
end
|
38
|
+
|
39
|
+
def sample_rate
|
40
|
+
characterization.sample_rate.blank? ? characterization.video_sample_rate : characterization.sample_rate
|
41
|
+
end
|
42
|
+
|
27
43
|
def characterize_if_changed
|
28
44
|
content_changed = self.content.changed?
|
29
45
|
yield
|
30
|
-
#logger.debug "DOING CHARACTERIZE ON #{self.pid}"
|
31
46
|
Sufia.queue.push(CharacterizeJob.new(self.pid)) if content_changed
|
32
47
|
end
|
33
48
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Sufia
|
2
|
+
module GenericFile
|
3
|
+
module VirusCheck
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
validate :detect_viruses
|
8
|
+
end
|
9
|
+
|
10
|
+
# Default behavior is to raise a validation error and halt the save if a virus is found
|
11
|
+
def detect_viruses
|
12
|
+
return unless content.changed?
|
13
|
+
path = if content.content.respond_to?(:path)
|
14
|
+
content.content.path
|
15
|
+
else
|
16
|
+
Tempfile.open('') do |t|
|
17
|
+
t.binmode
|
18
|
+
t.write(content.content)
|
19
|
+
t.close
|
20
|
+
t.path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
Sufia::GenericFile::Actions.virus_check(path)
|
24
|
+
true
|
25
|
+
rescue Sufia::VirusFoundError => virus
|
26
|
+
logger.warn(virus.message)
|
27
|
+
errors.add(:content, virus.message)
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -22,14 +22,13 @@ module Sufia
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def terms_for_editing
|
25
|
-
terms_for_display -
|
26
|
-
[:part_of, :date_modified, :date_uploaded, :format] #, :resource_type]
|
25
|
+
terms_for_display - [:date_modified, :date_uploaded, :format]
|
27
26
|
end
|
28
27
|
|
29
28
|
def terms_for_display
|
30
29
|
# 'type' is the RDF.type assertion, which is not present by default, but may be
|
31
30
|
# provided in some RDF schemas
|
32
|
-
self.descMetadata.class.fields
|
31
|
+
self.descMetadata.class.fields - [:part_of]
|
33
32
|
end
|
34
33
|
|
35
34
|
def to_jq_upload
|
@@ -9,40 +9,38 @@ class ImportUrlJob < ActiveFedoraPidBasedJob
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def run
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
12
|
+
user = User.find_by_user_key(generic_file.depositor)
|
13
|
+
|
14
|
+
Tempfile.open(self.pid) do |f|
|
15
|
+
f.binmode
|
16
|
+
|
17
|
+
# download file from url
|
18
|
+
uri = URI(generic_file.import_url)
|
19
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
20
|
+
http.use_ssl = uri.scheme == "https" # enable SSL/TLS
|
21
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
22
|
+
|
23
|
+
http.start do
|
24
|
+
http.request_get(uri.request_uri) do |resp|
|
25
|
+
resp.read_body do |segment|
|
26
|
+
f.write(segment)
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
|
31
|
+
f.rewind
|
32
|
+
# attach downloaded file to generic file stubbed out
|
33
|
+
Sufia::GenericFile::Actions.create_content(generic_file, f, File.basename(uri.path), 'content', user)
|
34
|
+
Sufia.queue.push(ContentDepositEventJob.new(generic_file.pid, generic_file.depositor))
|
35
|
+
# add message to user for downloaded file
|
36
|
+
message = "The file (#{File.basename(uri.path)}) was successfully imported."
|
37
|
+
job_user.send_message(user, message, 'File Import')
|
35
38
|
end
|
39
|
+
rescue => error
|
40
|
+
job_user.send_message(user, error.message, 'File Import Error')
|
41
|
+
end
|
36
42
|
|
37
|
-
|
38
|
-
|
39
|
-
Sufia::GenericFile::Actions.create_content(generic_file, f, File.basename(uri.path), 'content', user)
|
40
|
-
# add message to user for downloaded file
|
41
|
-
message = "The file (#{File.basename(uri.path)}) was successfully imported."
|
42
|
-
job_user.send_message(user, message, 'File Import')
|
43
|
-
|
44
|
-
ensure
|
45
|
-
f.close
|
46
|
-
f.unlink
|
43
|
+
def job_user
|
44
|
+
User.batchuser
|
47
45
|
end
|
48
46
|
end
|
data/lib/sufia/models/version.rb
CHANGED
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: 3.
|
4
|
+
version: 3.5.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: 2013-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -333,6 +333,7 @@ files:
|
|
333
333
|
- lib/sufia/models/generic_file/thumbnail.rb
|
334
334
|
- lib/sufia/models/generic_file/trophies.rb
|
335
335
|
- lib/sufia/models/generic_file/versions.rb
|
336
|
+
- lib/sufia/models/generic_file/virus_check.rb
|
336
337
|
- lib/sufia/models/generic_file/web_form.rb
|
337
338
|
- lib/sufia/models/id_service.rb
|
338
339
|
- lib/sufia/models/jobs/active_fedora_pid_based_job.rb
|
@@ -374,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
374
375
|
version: '0'
|
375
376
|
requirements: []
|
376
377
|
rubyforge_project:
|
377
|
-
rubygems_version: 2.0.
|
378
|
+
rubygems_version: 2.0.14
|
378
379
|
signing_key:
|
379
380
|
specification_version: 4
|
380
381
|
summary: Models and services for sufia
|