Class: SingleUseLinkController

Inherits:
DownloadsController show all
Defined in:
app/controllers/single_use_link_controller.rb

Instance Method Summary collapse

Instance Method Details

#downloadObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/single_use_link_controller.rb', line 33

def download
  #look up the item
  link = lookup_hash

  #grab the item id
  id = link.itemId 
  
  #check to make sure the path matches
  not_found if link.path != sufia.download_path(id)
  
  # send the data content
  asset = ActiveFedora::Base.find(id, :cast=>true)
  send_content(asset)
end

#generate_downloadObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/single_use_link_controller.rb', line 9

def generate_download
  @generic_file = GenericFile.find(params[:id])
  authorize! :read, @generic_file   
  @su =  SingleUseLink.create_download(params[:id])
  @link =  sufia.download_single_use_link_path(@su.downloadKey)
  respond_to do |format|
    format.html
    format.js  {render :js => @link}
  end
  
end

#generate_showObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/single_use_link_controller.rb', line 21

def generate_show
  @generic_file = GenericFile.find(params[:id])
  authorize! :read, @generic_file   
  @su = SingleUseLink.create_show(params[:id])
  @link = sufia.show_single_use_link_path(@su.downloadKey)
  respond_to do |format|
    format.html
    format.js  {render :js => @link}
  end
  
end

#showObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/single_use_link_controller.rb', line 48

def show
  link = lookup_hash

  #grab the item id
  id = link.itemId 
  
  #check to make sure the path matches
  not_found if link.path != sufia.generic_file_path(id)
  
  #show the file
  @generic_file = GenericFile.find(id)
  @terms = @generic_file.terms_for_display
  
  # create a dowload link that is single use for the user since we do not just want to show metadata we want to access it too
  @su =  SingleUseLink.create_download(id)
  @download_link =  sufia.download_single_use_link_path(@su.downloadKey)
end