Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Hooked Avalon up to Rubyhorn and felix retraction

  • Loading branch information...
commit 2d9c3e794abee2c322d7c7e22b1e2b5fd8486872 1 parent e817906
authored March 14, 2013
2  Gemfile.lock
@@ -50,7 +50,7 @@ GIT
50 50
 
51 51
 GIT
52 52
   remote: https://github.com/avalonmediasystem/rubyhorn.git
53  
-  revision: 53c4befd15c92ed4f20aa4844baf66b38d9f2ced
  53
+  revision: d82dc9ffccb75917241cbe88b25c6d04152be2ea
54 54
   specs:
55 55
     rubyhorn (0.0.4)
56 56
       activesupport
13  app/models/derivative.rb
@@ -17,9 +17,10 @@ class Derivative < ActiveFedora::Base
17 17
     d.field :hls_url, :string
18 18
     d.field :duration, :string
19 19
     d.field :track_id, :string
  20
+    d.field :hls_track_id, :string
20 21
   end
21 22
 
22  
-  delegate_to 'descMetadata', [:location_url, :hls_url, :duration, :track_id], unique: true
  23
+  delegate_to 'descMetadata', [:location_url, :hls_url, :duration, :track_id, :hls_track_id], unique: true
23 24
 
24 25
   has_metadata name: 'encoding', type: EncodingProfileDocument
25 26
 
@@ -31,6 +32,7 @@ def self.url_handler
31 32
   # Getting the track ID from the fragment is not great but it does reduce the number
32 33
   # of calls to Matterhorn 
33 34
   def self.create_from_master_file(masterfile, markup)
  35
+    
34 36
     # Looks for an existing derivative of the same quality
35 37
     # and adds the track URL to it
36 38
     quality = markup.tags.quality.first.split('-')[1] unless markup.tags.quality.empty?
@@ -43,7 +45,6 @@ def self.create_from_master_file(masterfile, markup)
43 45
     # If same quality derivative doesn't exist, create one
44 46
     if derivative.blank?
45 47
       derivative = Derivative.create 
46  
-      derivative.track_id = markup.track_id
47 48
       
48 49
       derivative.duration = markup.duration.first
49 50
       derivative.encoding.mime_type = markup.mimetype.first
@@ -60,8 +61,10 @@ def self.create_from_master_file(masterfile, markup)
60 61
     end
61 62
 
62 63
     if markup.tags.tag.include? "hls"   
  64
+      derivative.hls_track_id = markup.track_id
63 65
       derivative.hls_url = markup.url.first
64 66
     else
  67
+      derivative.track_id = markup.track_id
65 68
       derivative.location_url = markup.url.first
66 69
     end
67 70
 
@@ -120,4 +123,10 @@ def format
120 123
         "other"
121 124
       end
122 125
   end
  126
+
  127
+  def delete
  128
+    Rubyhorn.client.delete_track(masterfile.workflow_id, track_id) if track_id.present? 
  129
+    Rubyhorn.client.delete_hls_track(masterfile.workflow_id, hls_track_id) if hls_track_id.present? 
  130
+    super
  131
+  end
123 132
 end 
38  app/models/master_file.rb
@@ -57,12 +57,6 @@ def save_parent
57 57
   end
58 58
 
59 59
   def destroy
60  
-    parent = mediaobject
61  
-    parent.parts -= [self]
62  
-    parent.save(validate: false)
63  
-    unless new_object? || finished_processing?
64  
-      Rubyhorn.client.stop(workflow_id) if workflow_id
65  
-    end
66 60
     delete
67 61
   end
68 62
 
@@ -92,10 +86,36 @@ def mediaobject=(mo)
92 86
   end
93 87
 
94 88
   def delete 
  89
+    # Stops all processing and deletes the workflow
  90
+    unless new_object? || finished_processing?
  91
+      Rubyhorn.client.stop(workflow_id) if workflow_id
  92
+    end
  93
+
  94
+    parent = mediaobject
  95
+    parent.save(validate: false)
  96
+
95 97
     mo = self.mediaobject
96  
-    self.mediaobject = nil 
97  
-    super
98  
-    mo.save
  98
+    self.mediaobject = nil
  99
+    mo.parts -= [self]
  100
+
  101
+    derivatives_deleted = true
  102
+    self.derivatives.each do |d|
  103
+      if !d.delete
  104
+        derivatives_deleted = false
  105
+      end
  106
+    end
  107
+    if !derivatives_deleted 
  108
+      #flash[:error] << "Some derivatives could not be deleted."
  109
+    end 
  110
+
  111
+    if Rubyhorn.client.stop(workflow_id)
  112
+      super
  113
+    else 
  114
+      # If can't delete workflow from Matterhorn.
  115
+      # Detaches the MasterFile anyway, but don't delete it so we have a record of what failed
  116
+      #flash[:error] << "MasterFile's workflow could not be deleted from Matterhorn."
  117
+    end
  118
+    mo.save(validate: false)
99 119
   end
100 120
 
101 121
   def process
2  felix
... ...
@@ -1 +1 @@
1  
-Subproject commit 5b5e8c0100a153b35166012118bdd33b10c38e26
  1
+Subproject commit 05c09f3e7be42956e51b39355a23aed88ec0abee

0 notes on commit 2d9c3e7

Please sign in to comment.
Something went wrong with that request. Please try again.