sufia 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile +1 -1
  4. data/History.md +77 -0
  5. data/README.md +26 -11
  6. data/SUFIA_VERSION +1 -1
  7. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +4 -3
  8. data/app/helpers/sufia_helper.rb +7 -5
  9. data/app/jobs/ingest_local_file_job.rb +34 -0
  10. data/app/views/catalog/_facet_selected.html.erb +1 -1
  11. data/app/views/generic_files/_local_file_import.html.erb +3 -0
  12. data/app/views/generic_files/new.html.erb +10 -0
  13. data/app/views/generic_files/upload/_alerts.html.erb +2 -2
  14. data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +27 -0
  15. data/app/views/generic_files/upload/_script_templates.html.erb +1 -1
  16. data/lib/generators/sufia/sufia_generator.rb +1 -0
  17. data/lib/generators/sufia/templates/config/resque_config.rb +3 -20
  18. data/lib/sufia/files_controller/local_ingest_behavior.rb +54 -0
  19. data/lib/sufia/files_controller/upload_complete_behavior.rb +7 -0
  20. data/lib/sufia/files_controller_behavior.rb +31 -11
  21. data/lib/sufia/version.rb +1 -1
  22. data/spec/active_fedora/unsaved_digital_object_spec.rb +1 -1
  23. data/spec/controllers/authorities_controller_spec.rb +1 -1
  24. data/spec/controllers/batch_controller_spec.rb +4 -4
  25. data/spec/controllers/batch_edits_controller_spec.rb +1 -1
  26. data/spec/controllers/catalog_controller_spec.rb +1 -1
  27. data/spec/controllers/dashboard_controller_spec.rb +2 -2
  28. data/spec/controllers/downloads_controller_spec.rb +2 -3
  29. data/spec/controllers/generic_files_controller_spec.rb +113 -31
  30. data/spec/controllers/mailbox_controller_spec.rb +1 -1
  31. data/spec/controllers/single_use_link_controller_spec.rb +4 -5
  32. data/spec/controllers/users_controller_spec.rb +3 -3
  33. data/spec/features/browse_dashboard_files.rb +1 -1
  34. data/spec/features/browse_files.rb +1 -1
  35. data/spec/features/contact_form.rb +1 -1
  36. data/spec/features/display_dashboard.rb +1 -1
  37. data/spec/features/ingest_upload_files.rb +1 -1
  38. data/spec/features/users_spec.rb +1 -1
  39. data/spec/helpers/generic_file_helper_spec.rb +1 -1
  40. data/spec/helpers/render_constraints_helper_behavior_spec.rb +42 -0
  41. data/spec/helpers/sufia_helper_spec.rb +40 -1
  42. data/spec/jobs/import_url_job_spec.rb +45 -0
  43. data/spec/jobs/ingest_local_file_job_spec.rb +35 -0
  44. data/spec/lib/sufia/id_service_spec.rb +1 -1
  45. data/spec/lib/sufia/upload_complete_behavior_spec.rb +26 -0
  46. data/spec/models/audit_job_spec.rb +2 -2
  47. data/spec/models/batch_spec.rb +1 -1
  48. data/spec/models/batch_update_job_spec.rb +2 -4
  49. data/spec/models/characterize_job_spec.rb +17 -14
  50. data/spec/models/checksum_audit_log_spec.rb +2 -2
  51. data/spec/models/event_jobs_spec.rb +2 -2
  52. data/spec/models/file_content_datastream_spec.rb +5 -5
  53. data/spec/models/fits_datastream_spec.rb +2 -2
  54. data/spec/models/generic_file/actions_spec.rb +25 -0
  55. data/spec/models/generic_file/web_form_spec.rb +1 -1
  56. data/spec/models/generic_file_spec.rb +16 -33
  57. data/spec/models/local_authority_spec.rb +1 -1
  58. data/spec/models/properties_datastream_spec.rb +1 -1
  59. data/spec/models/single_use_link_spec.rb +1 -1
  60. data/spec/models/solr_document_spec.rb +1 -1
  61. data/spec/models/transcode_audio_job_spec.rb +22 -18
  62. data/spec/models/transcode_video_job_spec.rb +4 -3
  63. data/spec/models/trophy_spec.rb +1 -1
  64. data/spec/models/unzip_job_spec.rb +2 -2
  65. data/spec/models/user_spec.rb +1 -1
  66. data/spec/rake/sufia_fixtures_spec.rb +1 -1
  67. data/spec/routing/route_spec.rb +1 -1
  68. data/spec/spec_helper.rb +2 -2
  69. data/spec/views/batch_edits/check_all_spec.rb +1 -1
  70. data/sufia-models/app/models/datastreams/file_content_datastream.rb +1 -15
  71. data/sufia-models/app/models/geo_names_resource.rb +0 -2
  72. data/sufia-models/lib/sufia/models.rb +1 -1
  73. data/sufia-models/lib/sufia/models/engine.rb +12 -1
  74. data/sufia-models/lib/sufia/models/file_content.rb +0 -3
  75. data/sufia-models/lib/sufia/models/generic_file.rb +6 -10
  76. data/sufia-models/lib/sufia/models/generic_file/actions.rb +1 -1
  77. data/sufia-models/lib/sufia/models/generic_file/characterization.rb +1 -1
  78. data/sufia-models/lib/sufia/models/generic_file/derivatives.rb +31 -0
  79. data/sufia-models/lib/sufia/models/generic_file/mime_types.rb +27 -0
  80. data/sufia-models/lib/sufia/models/generic_file/thumbnail.rb +6 -60
  81. data/sufia-models/lib/sufia/models/jobs/active_fedora_pid_based_job.rb +19 -0
  82. data/sufia-models/lib/sufia/models/jobs/audit_job.rb +12 -8
  83. data/sufia-models/lib/sufia/models/jobs/characterize_job.rb +3 -10
  84. data/sufia-models/lib/sufia/models/jobs/import_url_job.rb +2 -9
  85. data/sufia-models/lib/sufia/models/jobs/resolrize_job.rb +8 -1
  86. data/sufia-models/lib/sufia/models/jobs/transcode_audio_job.rb +4 -28
  87. data/sufia-models/lib/sufia/models/jobs/transcode_video_job.rb +4 -28
  88. data/sufia-models/lib/sufia/models/jobs/unzip_job.rb +5 -19
  89. data/sufia-models/lib/sufia/models/model_methods.rb +2 -16
  90. data/sufia-models/lib/sufia/models/user_local_directory_behavior.rb +29 -0
  91. data/sufia-models/lib/sufia/models/version.rb +1 -1
  92. data/sufia-models/sufia-models.gemspec +1 -1
  93. data/sufia.gemspec +2 -1
  94. data/tasks/sufia-dev.rake +1 -1
  95. metadata +26 -10
  96. data/app/assets/stylesheets/jquery-ui-1.8.1.custom.css +0 -486
  97. data/app/assets/stylesheets/jquery-ui-1.8.23.custom.css +0 -340
  98. data/sufia-models/lib/sufia/models/file_content/extract_metadata.rb +0 -60
  99. data/sufia-models/lib/sufia/models/jobs/ffmpeg_transcode_job.rb +0 -61
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a23f866c05484770f7f3caaec082f6cb36b7258
4
- data.tar.gz: 47c0e1f3d27a544258f7d4d520d23152aad13773
3
+ metadata.gz: 94bdabbd0da949b6909f8a09f6c6db08910fa0d8
4
+ data.tar.gz: 363c5ec11e4dc93850a79dbf7cdd8a9a9a231870
5
5
  SHA512:
6
- metadata.gz: d48523de8c674ffa5dd496b3595943ab4db13b9b42b26eb730b25bdb4db467a34863cb920d03b6d3c09c5a8e77ee4c3fed091ffa2316d3435bf3ab52c872c322
7
- data.tar.gz: 2ab7bef74ddb9365f6f10695b2ade76c0149504dfebd349455ffc52cbbd58a8749410c581285c040b0abc4f790495597daf6797e27af46f2ad940e38f43c76e8
6
+ metadata.gz: 38714b26c3d16dfcb2ff8da8e03515ecff0bbd9171fb75c568f828aa327e64bbb7b2d0ffea855fbf9286ed64a77098f5e4c114682a6c2b470353ca4b35893006
7
+ data.tar.gz: 2c48c93673ec0fc8d540f801a945cf0ac10f0cbc487406ad3ddb91afad2e2a8e2d4e9567627135060cc32fadcb1618d3e06c0f583a15f61c1616322d5f2f9631
data/.gitignore CHANGED
@@ -48,6 +48,8 @@ spec/dummy/log/*.log
48
48
  spec/dummy/tmp/
49
49
 
50
50
 
51
+ spec/mock_upload_directory
52
+
51
53
  ## PROJECT::GENERAL
52
54
  coverage
53
55
  rdoc
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Please see sufia.gemspec for dependency information.
4
4
  gemspec
data/History.md CHANGED
@@ -1,5 +1,82 @@
1
1
  # History of Sufia releases
2
2
 
3
+ ## 3.1.0
4
+ * Make fits instructions more verbose [Carolyn Cole]
5
+
6
+ * Adding one location to define/ override where the upload redirects to after a
7
+ sucessfull upload [Carolyn Cole]
8
+
9
+ * Added license to the gemspec [Justin Coyne]
10
+
11
+ * fixed typo in require statement [Matt Zumwalt]
12
+
13
+ * requires active_resource more cleanly [Matt Zumwalt]
14
+
15
+ * updating facet views so that the blacklight helper_method will get called
16
+ [Carolyn Cole]
17
+
18
+ * Adds a spec for the ImportUrlJob [Michael J. Giarlo]
19
+
20
+ * Fixed expecations for travis tests for #169 [Justin Coyne]
21
+
22
+ * ModelMethods#apply_depositor_metadata should accept a user or a string like the
23
+ method it overrides in HydraHead. See:
24
+ https://github.com/projecthydra/hydra-head/blob/9a5b2728be2046125d09376a6d78ad06d26548c3/hydra-core/lib/hydra/model_methods.rb#L12
25
+ [Justin Coyne]
26
+
27
+ * Remove expand_path jazz from remaining specs [Michael J. Giarlo]
28
+
29
+ * Codifying a pid based job [Jeremy Friesen]
30
+
31
+ * Removing characterization save unless new_object? [Jeremy Friesen]
32
+
33
+ * Adding $LOAD_PATH variable to dev rake task [Jeremy Friesen]
34
+
35
+ * Bump dependency on hydra-derivatives [Justin Coyne]
36
+
37
+ * Use add_file() rather than add_file_datastream() to ensure object label is set
38
+ [Michael J. Giarlo]
39
+
40
+ * Audio and video transcoding with hydra-derivatives [Justin Coyne]
41
+
42
+ * Use hydra-derivatives for generating thumbnails [Justin Coyne]
43
+
44
+ * ingest_local_file should ingest the file, not the filename [Justin Coyne]
45
+
46
+ * Including deposit agreement on local import page [Matt Zumwalt]
47
+
48
+ * UI for local ingest only appears in local ingest tab on upload page [Matt
49
+ Zumwalt]
50
+
51
+ * Putting test coverage for virus check into the right place [Matt Zumwalt]
52
+
53
+ * local file ingest runs virus check [Matt Zumwalt]
54
+
55
+ * testing outputs without relying on consistent array ordering [Matt Zumwalt]
56
+
57
+ * UI text changes for local ingest [Matt Zumwalt]
58
+
59
+ * removing unused fixtures [Matt Zumwalt]
60
+
61
+ * cleanup of tests and method names around local ingest [Matt Zumwalt]
62
+
63
+ * Display local ingest tab in Upload page when local import enabled [Matt
64
+ Zumwalt]
65
+
66
+ * Local ingest renders graceful error message if User does not define a directory
67
+ path [Matt Zumwalt]
68
+
69
+ * fixing scope of describe blocks in this test [Matt Zumwalt]
70
+
71
+ * LocalFileIngestBehavior for FilesController [Matt Zumwalt]
72
+
73
+ * The generator should create config/initializers/resque_config.rb [Justin Coyne]
74
+
75
+ * Reindex everything scopes to sufia's namespace [Jeremy Friesen]
76
+
77
+ * Remove css that doesn't appear to be used [Justin Coyne]
78
+
79
+
3
80
  ## 3.0.0
4
81
  * Update README.md paths for Sufia assets application.css and application.js [Jim
5
82
  Coble]
data/README.md CHANGED
@@ -25,14 +25,13 @@ Sufia has the following features:
25
25
  * Background jobs
26
26
  * Single-use links
27
27
 
28
- Sufia needs the following software to work:
29
- * Solr
30
- * Fedora Commons
31
- * A SQL RDBMS (MySQL, SQLite)
32
- * Redis
33
- * Ruby
34
-
35
-
28
+ ## Sufia needs the following software to work:
29
+ 1. Solr
30
+ 1. Fedora Commons
31
+ 1. A SQL RDBMS (MySQL, SQLite)
32
+ 1. [Redis](http://redis.io/) key-value store
33
+ 1. Ruby
34
+ ## !! Ensure that you have all of the above components installed before you continue. !!
36
35
 
37
36
  ## Creating an application
38
37
  ### Generate base Rails install
@@ -92,13 +91,29 @@ Add this line:
92
91
  ```
93
92
 
94
93
  ### Install Fits.sh
95
- http://code.google.com/p/fits/downloads/list
96
- Download a copy of fits & unpack it somewhere on your PATH.
94
+ 1. Go to http://code.google.com/p/fits/downloads/list and download a copy of fits & unpack it somewhere on your Machine.
95
+ 1. Give your system access to fits
96
+ 1. By adding the path to fits.sh to your excutable PATH. (ex. in your .bashrc)
97
+ * OR
98
+ 1. By adding/changing config/initializers/sufia.rb to point to your fits location: `config.fits_path = "/<your full path>/fits.sh"`
99
+ 1. You may additionally need to chmod the fits.sh (chmod a+x fits.sh)
100
+ 1. You may need to restart your shell to pick up the changes to you path
101
+ 1. You should be able to run "fits.sh" from the command line and see a help message
97
102
 
98
103
  ### Start background workers
104
+ **Note:** Resque relies on the [redis](http://redis.io/) key-value store. You must install [redis](http://redis.io/) on your system and *have redis running* in order for this command to work.
105
+ To start redis, you usually want to call the `redis-server` command.
106
+
107
+ ```
108
+ QUEUE=* rake environment resque:work
99
109
  ```
100
- COUNT=4 QUEUE=* rake environment resque:work
110
+
111
+ For production you may want to set up a config/resque-pool.yml and run resque pool in daemon mode
112
+
101
113
  ```
114
+ resque-pool --daemon --environment development start
115
+ ```
116
+
102
117
  See https://github.com/defunkt/resque for more options
103
118
 
104
119
  ### If you want to enable transcoding of video, instal ffmpeg version 1.0+
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.1.0
@@ -56,16 +56,17 @@ module Blacklight::RenderConstraintsHelperBehavior
56
56
  end
57
57
 
58
58
  def render_filter_element(facet, values, localized_params)
59
+ facet_configuration_for_field(facet)
59
60
  values.map do |val|
60
- if params[:controller] == 'dashboard'
61
+ if params[:controller] == 'dashboard'
61
62
  render_constraint_element( facet_field_labels[facet],
62
- val,
63
+ facet_display_value(facet, val),
63
64
  :remove => dashboard_index_path(remove_facet_params(facet, val, localized_params)),
64
65
  :classes => ["filter", "filter-" + facet.parameterize]
65
66
  ) + "\n"
66
67
  else
67
68
  render_constraint_element( facet_field_labels[facet],
68
- val,
69
+ facet_display_value(facet, val),
69
70
  :remove => catalog_index_path(remove_facet_params(facet, val, localized_params)),
70
71
  :classes => ["filter", "filter-" + facet.parameterize]
71
72
  ) + "\n"
@@ -92,17 +92,19 @@ module SufiaHelper
92
92
 
93
93
  # Override to remove the label class (easier integration with bootstrap)
94
94
  # and handles arrays
95
- def render_facet_value(facet_solr_field, item, options ={})
95
+ def render_facet_value(facet_solr_field, item, options ={})
96
+ logger.warn "display value #{ facet_display_value(facet_solr_field, item)}"
96
97
  if item.is_a? Array
97
98
  render_array_facet_value(facet_solr_field, item, options)
98
99
  end
99
100
  if params[:controller] == "dashboard"
100
- path = sufia.url_for(add_facet_params_and_redirect(facet_solr_field, item.value).merge(:only_path=>true))
101
- (link_to_unless(options[:suppress_link], item.value, path, :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
102
- else
101
+ path = sufia.url_for(add_facet_params_and_redirect(facet_solr_field,item.value ).merge(:only_path=>true))
102
+ path = sufia.url_for(add_facet_params_and_redirect(facet_solr_field,item.value ).merge(:only_path=>true))
103
+ (link_to_unless(options[:suppress_link], facet_display_value(facet_solr_field, item), path, :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
104
+ else
103
105
  # This is for controllers that use this helper method that are defined outside Sufia
104
106
  path = url_for(add_facet_params_and_redirect(facet_solr_field, item.value).merge(:only_path=>true))
105
- (link_to_unless(options[:suppress_link], item.value, path, :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
107
+ (link_to_unless(options[:suppress_link], facet_display_value(facet_solr_field, item), path, :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
106
108
  end
107
109
  end
108
110
 
@@ -0,0 +1,34 @@
1
+ class IngestLocalFileJob
2
+ def queue_name
3
+ :ingest
4
+ end
5
+
6
+ attr_accessor :directory, :filename, :user_key, :generic_file_id
7
+
8
+ def initialize(generic_file_id, directory, filename, user_key)
9
+ self.generic_file_id = generic_file_id
10
+ self.directory = directory
11
+ self.filename = filename
12
+ self.user_key = user_key
13
+ end
14
+
15
+ def run
16
+ filedata = File.new( File.join(directory, filename) )
17
+ generic_file = GenericFile.find(generic_file_id)
18
+ user = User.find_by_user_key(user_key)
19
+ raise "Unable to find user for #{user_key}" unless user
20
+
21
+ # virus check
22
+ virus_stat = Sufia::GenericFile::Actions.virus_check(filedata)
23
+ raise "Virus checking did not pass for #{File.basename(filedata.path)} status = #{virus_stat}" unless virus_stat == 0
24
+
25
+ generic_file.label = File.basename(filename)
26
+ generic_file.add_file(File.open(File.join(directory, filename)), 'content', generic_file.label)
27
+ generic_file.record_version_committer(user)
28
+ generic_file.save!
29
+
30
+ #Sufia.queue.push(UnzipJob.new(generic_file.pid)) if generic_file.content.mimeType == 'application/zip'
31
+ Sufia.queue.push(ContentDepositEventJob.new(generic_file.pid, user_key))
32
+ FileUtils.rm([File.join(directory, filename)])
33
+ end
34
+ end
@@ -5,7 +5,7 @@
5
5
  <% link_options = remove_facet_params(k, selected_facet, params).merge!Hash["controller" => "catalog", :action=> "index"] %>
6
6
  <div class="alert alert-warning">
7
7
  <%= link_to 'X', url_for(link_options), {:class=>'close', :'data-dismiss' => "alert" } %>
8
- <i class="icon-ok icon-large"></i> <strong><%= selected_facet %></strong>
8
+ <i class="icon-ok icon-large"></i> <strong><%= facet_display_value(k, selected_facet) %></strong>
9
9
  </div>
10
10
  <% end %>
11
11
  <% end %>
@@ -0,0 +1,3 @@
1
+ <%= render partial: 'generic_files/upload/agreement' %>
2
+ <%= render partial: 'generic_files/upload/alerts' %>
3
+ <%= render partial: 'generic_files/upload/local_file_import_chooser' %>
@@ -21,6 +21,9 @@ limitations under the License.
21
21
  <% if Sufia.config.dropbox_api_key %>
22
22
  <li><a href="#dropbox" data-toggle="tab"><i class="icon-inbox"></i> Dropbox</a></li>
23
23
  <% end %>
24
+ <% if Sufia.config.enable_local_ingest %>
25
+ <li><a href="#ingest" data-toggle="tab"><i class="icon-hdd"></i> Network/Server Location</a></li>
26
+ <% end %>
24
27
  </ul>
25
28
 
26
29
  <div class="tab-content">
@@ -33,4 +36,11 @@ limitations under the License.
33
36
  <%= render partial: 'dropbox_import' %>
34
37
  </div>
35
38
  <% end %>
39
+
40
+ <% if Sufia.config.enable_local_ingest %>
41
+ <div class="tab-pane" id="ingest">
42
+ <%= render partial: 'generic_files/local_file_import' %>
43
+ </div>
44
+ <% end %>
45
+
36
46
  </div>
@@ -2,7 +2,7 @@
2
2
  <div class="alert alert-info hide" id="success">
3
3
  You have successfully uploaded some of your files. Either continue to upload or edit use the links below to abandon the rest of your added files.
4
4
  <p>
5
- <%= link_to 'Add Descriptions', sufia.batch_edit_path(@batch_noid), :class=>'btn' %>
5
+ <%= link_to 'Add Descriptions', GenericFilesController.upload_complete_path(@batch_noid), :class=>'btn' %>
6
6
  </p>
7
7
  </div>
8
8
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  <div class="alert hide" id="partial_fail">
14
14
  One or more files did not upload successfully. To continue using the files uploaded use one of the links below.<br />
15
- <%= link_to 'Add Descriptions', sufia.batch_edit_path(@batch_noid), :class=>'btn' %>
15
+ <%= link_to 'Add Descriptions', GenericFilesController.upload_complete_path(@batch_noid), :class=>'btn' %>
16
16
  </div>
17
17
 
18
18
  <div class="alert hide" id="errmsg"> </div>
@@ -0,0 +1,27 @@
1
+ <% if current_user.directory.present? %>
2
+ <div class="well">
3
+ <%= render partial: 'generic_files/upload/tos_checkbox' %>
4
+ <%= form_for @generic_file, :url => sufia.generic_files_path, :html => { :class => 'form-horizontal well'} do |f| %>
5
+ <table class="table table-striped">
6
+ <caption>Select files to deposit from your user directory on the server.</caption>
7
+ <thead>
8
+ <tr><th>File</th></tr>
9
+ </thead>
10
+ <tbody>
11
+ <%current_user.files.each do |f| %>
12
+ <tr>
13
+ <td>
14
+ <label><%= check_box_tag 'local_file[]', f[:name] %> <%= f[:directory] ? '<i class="icon-folder-close"></i>'.html_safe : '<i class="icon-file"></i>'.html_safe %> <%= f[:name] %></label>
15
+ </td>
16
+ </tr>
17
+ <%end%>
18
+ </tbody>
19
+ </table>
20
+ <%= hidden_field_tag(:batch_id, @batch_noid) %>
21
+ <button type="submit" class="activate-submit btn btn-primary start" id="main_upload_start">
22
+ <i class="icon-upload icon-white"></i>
23
+ <span>Deposit Selected Files</span>
24
+ </button>
25
+ <% end %>
26
+ </div>
27
+ <% end %>
@@ -1,6 +1,6 @@
1
1
  <div class="alert alert-info hide" id="redirect-loc" type="text/x-jquery-tmpl">
2
2
  <%-# Script redirects here once the uploads are complete %>
3
- <%=sufia.batch_edit_path(@batch_noid)%>
3
+ <%=GenericFilesController.upload_complete_path(@batch_noid)%>
4
4
  </div>
5
5
 
6
6
  <!-- The template to display files available for upload -->
@@ -73,6 +73,7 @@ add_groups_to_users.rb create_local_authorities.rb create_trophies.rb}.each do
73
73
  copy_file "config/redis.yml", "config/redis.yml"
74
74
  copy_file "config/redis_config.rb", "config/initializers/redis_config.rb"
75
75
  copy_file "config/resque_admin.rb", "config/initializers/resque_admin.rb"
76
+ copy_file "config/resque_config.rb", "config/initializers/resque_config.rb"
76
77
  end
77
78
 
78
79
  def catalog_controller
@@ -1,22 +1,5 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- rails_root = ENV['RAILS_ROOT'] || "#{File.dirname(__FILE__)}/../.."
16
- rails_env = ENV['RAILS_ENV'] || 'development'
17
-
18
- config = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)['resque'].with_indifferent_access
1
+ config = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
19
2
  Resque.redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true)
20
3
 
21
- Resque.inline = rails_env == 'test'
22
- Resque.redis.namespace = "#{Sufia::Engine.config.id_namespace}:#{rails_env}"
4
+ Resque.inline = Rails.env.test?
5
+ Resque.redis.namespace = "#{Sufia::Engine.config.id_namespace}:#{Rails.env}"
@@ -0,0 +1,54 @@
1
+ module Sufia
2
+ module FilesController::LocalIngestBehavior
3
+
4
+ private
5
+
6
+ def perform_local_ingest
7
+ if Sufia.config.enable_local_ingest && current_user.respond_to?(:directory)
8
+ if ingest_local_file
9
+ redirect_to GenericFilesController.upload_complete_path( params[:batch_id])
10
+ else
11
+ flash[:alert] = "Error importing files from user directory."
12
+ render :new
13
+ end
14
+ else
15
+ flash[:alert] = "Your account is not configured for importing files from a user-directory on the server."
16
+ render :new
17
+ end
18
+ end
19
+
20
+ def ingest_local_file
21
+ # Ingest files already on disk
22
+ has_directories = false
23
+ files = []
24
+ params[:local_file].each do |filename|
25
+ if File.directory?(File.join(current_user.directory, filename))
26
+ has_directories = true
27
+ Dir[File.join(current_user.directory, filename, '**', '*')].each do |single|
28
+ next if File.directory? single
29
+ logger.info("Ingesting file: #{single}")
30
+ files << single.sub(current_user.directory + '/', '')
31
+ logger.info("after removing the user directory #{current_user.directory} we have: #{files.last}")
32
+ end
33
+ else
34
+ files << filename
35
+ end
36
+ end
37
+ files.each do |filename|
38
+ ingest_one(filename, has_directories)
39
+ end
40
+ true
41
+ end
42
+
43
+ def ingest_one(filename, unarranged)
44
+ # do not remove ::
45
+ @generic_file = ::GenericFile.new
46
+ basename = File.basename(filename)
47
+ @generic_file.label = basename
48
+ @generic_file.relative_path = filename if filename != basename
49
+ create_metadata(@generic_file)
50
+ Sufia.queue.push(IngestLocalFileJob.new(@generic_file.id, current_user.directory, filename, current_user.user_key))
51
+ end
52
+
53
+ end # /FilesController::LocalIngestBehavior
54
+ end # /Sufia
@@ -0,0 +1,7 @@
1
+ module Sufia
2
+ module FilesController::UploadCompleteBehavior
3
+ def upload_complete_path(batch_id)
4
+ Sufia::Engine.routes.url_helpers.batch_edit_path(batch_id)
5
+ end
6
+ end # /FilesController::UploadCompleteBehavior
7
+ end # /Sufia
@@ -14,13 +14,21 @@
14
14
  # limitations under the License.
15
15
 
16
16
  module Sufia
17
+ module FilesController
18
+ autoload :LocalIngestBehavior, 'sufia/files_controller/local_ingest_behavior'
19
+ autoload :UploadCompleteBehavior, 'sufia/files_controller/upload_complete_behavior'
20
+ end
17
21
  module FilesControllerBehavior
18
22
  extend ActiveSupport::Concern
23
+ extend Sufia::FilesController::UploadCompleteBehavior
19
24
 
20
25
  included do
21
26
  include Hydra::Controller::ControllerBehavior
22
27
  include Blacklight::Configurable # comply with BL 3.7
23
- include Sufia::Noid # for normalize_identifier method
28
+ include Sufia::Noid # for normalize_identifier method
29
+ include Sufia::FilesController::LocalIngestBehavior
30
+ extend Sufia::FilesController::UploadCompleteBehavior
31
+
24
32
  layout "sufia-one-column"
25
33
 
26
34
  # This is needed as of BL 3.7
@@ -44,6 +52,7 @@ module Sufia
44
52
  prepend_before_filter :normalize_identifier, :except => [:index, :create, :new]
45
53
  load_resource :only=>[:audit]
46
54
  load_and_authorize_resource :except=>[:index, :audit]
55
+
47
56
  end
48
57
 
49
58
  # routed to /files/new
@@ -68,14 +77,20 @@ module Sufia
68
77
 
69
78
  # routed to /files (POST)
70
79
  def create
71
- case params['file_coming_from']
72
- when 'dropbox'
73
- create_from_url(params)
80
+ if params[:local_file].present?
81
+ perform_local_ingest
74
82
  else
75
- create_from_local(params)
83
+ case params['file_coming_from']
84
+ when 'dropbox'
85
+ create_from_url(params)
86
+ else
87
+ create_from_upload(params)
88
+ end
76
89
  end
77
90
  end
78
91
 
92
+
93
+
79
94
  def create_from_url(params)
80
95
  params[:dropbox_urls].each do |db_file|
81
96
  next if db_file.blank?
@@ -83,13 +98,13 @@ module Sufia
83
98
  @generic_file = ::GenericFile.new
84
99
  @generic_file.import_url = db_file
85
100
  @generic_file.label = File.basename(db_file)
86
- Sufia::GenericFile::Actions.create_metadata(@generic_file, current_user, params[:batch_id])
101
+ create_metadata(@generic_file)
87
102
  Sufia.queue.push(ImportUrlJob.new(@generic_file.pid))
88
103
  end
89
- redirect_to sufia.batch_edit_path(params[:batch_id])
104
+ redirect_to self.class.upload_complete_path( params[:batch_id])
90
105
  end
91
106
 
92
- def create_from_local(params)
107
+ def create_from_upload(params)
93
108
  begin
94
109
  # check error condition No files
95
110
  return json_error("Error! No file to save") if !params.has_key?(:files)
@@ -138,7 +153,7 @@ module Sufia
138
153
 
139
154
  if params.has_key?(:revision) and params[:revision] != @generic_file.content.latest_version.versionID
140
155
  revision = @generic_file.content.get_version(params[:revision])
141
- @generic_file.add_file_datastream(revision.content, :dsid => 'content', :mimeType => revision.mimeType)
156
+ @generic_file.add_file(revision.content, datastream_id, revision.label)
142
157
  version_event = true
143
158
  Sufia.queue.push(ContentRestoredVersionEventJob.new(@generic_file.pid, current_user.user_key, params[:revision]))
144
159
  end
@@ -181,7 +196,7 @@ module Sufia
181
196
  if virus_check(file) == 0
182
197
  @generic_file = ::GenericFile.new
183
198
  update_metadata_from_upload_screen
184
- Sufia::GenericFile::Actions.create_metadata(@generic_file, current_user, params[:batch_id])
199
+ create_metadata(@generic_file)
185
200
  Sufia::GenericFile::Actions.create_content(@generic_file, file, file.original_filename, datastream_id, current_user)
186
201
  respond_to do |format|
187
202
  format.html {
@@ -235,7 +250,12 @@ module Sufia
235
250
  stat = Sufia::GenericFile::Actions.virus_check(file)
236
251
  flash[:error] = "Virus checking did not pass for #{File.basename(file.path)} status = #{stat}" unless stat == 0
237
252
  stat
238
- end
253
+ end
254
+
255
+
256
+ def create_metadata(file)
257
+ Sufia::GenericFile::Actions.create_metadata(file, current_user, params[:batch_id])
258
+ end
239
259
 
240
260
  end
241
261
  end