Permalink
Browse files

Hooked Avalon up to Rubyhorn and felix retraction

  • Loading branch information...
1 parent e817906 commit 2d9c3e794abee2c322d7c7e22b1e2b5fd8486872 Phuong Dinh committed Mar 14, 2013
Showing with 42 additions and 13 deletions.
  1. +1 −1 Gemfile.lock
  2. +11 −2 app/models/derivative.rb
  3. +29 −9 app/models/master_file.rb
  4. +1 −1 felix
View
@@ -50,7 +50,7 @@ GIT
GIT
remote: https://github.com/avalonmediasystem/rubyhorn.git
- revision: 53c4befd15c92ed4f20aa4844baf66b38d9f2ced
+ revision: d82dc9ffccb75917241cbe88b25c6d04152be2ea
specs:
rubyhorn (0.0.4)
activesupport
View
@@ -17,9 +17,10 @@ class Derivative < ActiveFedora::Base
d.field :hls_url, :string
d.field :duration, :string
d.field :track_id, :string
+ d.field :hls_track_id, :string
end
- delegate_to 'descMetadata', [:location_url, :hls_url, :duration, :track_id], unique: true
+ delegate_to 'descMetadata', [:location_url, :hls_url, :duration, :track_id, :hls_track_id], unique: true
has_metadata name: 'encoding', type: EncodingProfileDocument
@@ -31,6 +32,7 @@ def self.url_handler
# Getting the track ID from the fragment is not great but it does reduce the number
# of calls to Matterhorn
def self.create_from_master_file(masterfile, markup)
+
# Looks for an existing derivative of the same quality
# and adds the track URL to it
quality = markup.tags.quality.first.split('-')[1] unless markup.tags.quality.empty?
@@ -43,7 +45,6 @@ def self.create_from_master_file(masterfile, markup)
# If same quality derivative doesn't exist, create one
if derivative.blank?
derivative = Derivative.create
- derivative.track_id = markup.track_id
derivative.duration = markup.duration.first
derivative.encoding.mime_type = markup.mimetype.first
@@ -60,8 +61,10 @@ def self.create_from_master_file(masterfile, markup)
end
if markup.tags.tag.include? "hls"
+ derivative.hls_track_id = markup.track_id
derivative.hls_url = markup.url.first
else
+ derivative.track_id = markup.track_id
derivative.location_url = markup.url.first
end
@@ -120,4 +123,10 @@ def format
"other"
end
end
+
+ def delete
+ Rubyhorn.client.delete_track(masterfile.workflow_id, track_id) if track_id.present?
+ Rubyhorn.client.delete_hls_track(masterfile.workflow_id, hls_track_id) if hls_track_id.present?
+ super
+ end
end
View
@@ -57,12 +57,6 @@ def save_parent
end
def destroy
- parent = mediaobject
- parent.parts -= [self]
- parent.save(validate: false)
- unless new_object? || finished_processing?
- Rubyhorn.client.stop(workflow_id) if workflow_id
- end
delete
end
@@ -92,10 +86,36 @@ def mediaobject=(mo)
end
def delete
+ # Stops all processing and deletes the workflow
+ unless new_object? || finished_processing?
+ Rubyhorn.client.stop(workflow_id) if workflow_id
+ end
+
+ parent = mediaobject
+ parent.save(validate: false)
+
mo = self.mediaobject
- self.mediaobject = nil
- super
- mo.save
+ self.mediaobject = nil
+ mo.parts -= [self]
+
+ derivatives_deleted = true
+ self.derivatives.each do |d|
+ if !d.delete
+ derivatives_deleted = false
+ end
+ end
+ if !derivatives_deleted
+ #flash[:error] << "Some derivatives could not be deleted."
+ end
+
+ if Rubyhorn.client.stop(workflow_id)
+ super
+ else
+ # If can't delete workflow from Matterhorn.
+ # Detaches the MasterFile anyway, but don't delete it so we have a record of what failed
+ #flash[:error] << "MasterFile's workflow could not be deleted from Matterhorn."
+ end
+ mo.save(validate: false)
end
def process

0 comments on commit 2d9c3e7

Please sign in to comment.