hydra-head 3.0.0.rc2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +31 -2
- data/RELEASE_NOTES.textile +8 -0
- data/app/helpers/application_helper.rb +0 -16
- data/app/helpers/blacklight_helper.rb +1 -1
- data/lib/generators/hydra/head_generator.rb +3 -1
- data/lib/generators/hydra/templates/config/initializers/blacklight_config.rb +9 -2
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra/access_controls_enforcement.rb +47 -5
- data/lib/railties/hydra-fixtures.rake +1 -1
- data/lib/railties/hydra_jetty.rake +13 -6
- data/solr_conf/conf/schema.xml +2 -0
- data/solr_conf/conf/solrconfig.xml +117 -55
- data/test_support/features/absent_model_search_result.feature +2 -8
- data/test_support/features/html_validity.feature +2 -2
- data/test_support/features/mods_asset_search_result.feature +2 -2
- data/test_support/spec/controllers/catalog_controller_spec.rb +6 -3
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +77 -0
- metadata +9 -12
data/README.textile
CHANGED
@@ -74,7 +74,7 @@ First, add them to the "Gemfile":http://gembundler.com/gemfile.html of your appl
|
|
74
74
|
gem 'rails', '~>3.0.10'
|
75
75
|
|
76
76
|
gem 'blacklight', '~> 3.0.0'
|
77
|
-
gem 'hydra-head', '3.0.0.
|
77
|
+
gem 'hydra-head', '3.0.0.rc2'
|
78
78
|
|
79
79
|
# We will assume that you're using sqlite3 for testing/demo,
|
80
80
|
# but in a production setup you probably want to use a real sql database like mysql or postgres
|
@@ -95,6 +95,7 @@ First, add them to the "Gemfile":http://gembundler.com/gemfile.html of your appl
|
|
95
95
|
gem 'database_cleaner'
|
96
96
|
gem 'capybara'
|
97
97
|
gem 'bcrypt-ruby'
|
98
|
+
gem "jettywrapper"
|
98
99
|
end
|
99
100
|
</pre>
|
100
101
|
|
@@ -110,7 +111,7 @@ Even if all of the dependencies are satisfied, this will take a _very_ long time
|
|
110
111
|
|
111
112
|
<pre>
|
112
113
|
gem install blacklight
|
113
|
-
gem install hydra-head -v 3.0.0.
|
114
|
+
gem install hydra-head -v 3.0.0.rc2
|
114
115
|
</pre>
|
115
116
|
|
116
117
|
Then re-run bundle install and it will run slightly faster.
|
@@ -190,6 +191,34 @@ git submodule init
|
|
190
191
|
git submodule update
|
191
192
|
</pre>
|
192
193
|
|
194
|
+
*Important*: To apply the your application's solrconfig.xml and schema.xml to the copy of solr in hydra-jetty, run this:
|
195
|
+
|
196
|
+
<pre>
|
197
|
+
rake hydra:jetty:config
|
198
|
+
</pre>
|
199
|
+
|
200
|
+
Now you're ready to start jetty. We've written a useful gem that gives you rake tasks for starting and stopping jetty. Make sure you have jettywrapper in your Gemfile
|
201
|
+
|
202
|
+
<pre>
|
203
|
+
gem "jettywrapper"
|
204
|
+
</pre>
|
205
|
+
|
206
|
+
Then run <pre> bundle install <pre>
|
207
|
+
|
208
|
+
Now that you have jettywrapper installed, to start jetty use
|
209
|
+
|
210
|
+
<pre>
|
211
|
+
rake jetty:start
|
212
|
+
</pre>
|
213
|
+
|
214
|
+
To stop jetty
|
215
|
+
|
216
|
+
<pre>
|
217
|
+
rake jetty:stop
|
218
|
+
</pre>
|
219
|
+
|
220
|
+
For more information about using jettywrapper, see http://hudson.projecthydra.org/job/jettywrapper/Documentation/
|
221
|
+
|
193
222
|
h3. RSpec and Cucumber for Testing
|
194
223
|
|
195
224
|
We STRONGLY recommend that you write tests for every local change you make. This will allow you to ensure that upgrading the core code doesn't break any local changes you have made.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
h2. 3.0.0
|
2
|
+
|
3
|
+
If you have been testing out the Release Candidates, you need to add this line to your CatalogController:
|
4
|
+
|
5
|
+
<pre>
|
6
|
+
# This filters out objects that you want to exclude from search results. By default, it filters out FileAssets
|
7
|
+
CatalogController.solr_search_params_logic << :exclude_unwanted_models
|
8
|
+
</pre>
|
@@ -29,22 +29,6 @@ module ApplicationHelper
|
|
29
29
|
def linked_label(field, field_string)
|
30
30
|
link_to(field, add_facet_params(field_string, field).merge!({"controller" => "catalog", :action=> "index"}))
|
31
31
|
end
|
32
|
-
def link_to_document(doc, opts={:label=>Blacklight.config[:index][:show_link].to_sym, :counter => nil,:title => nil})
|
33
|
-
label = case opts[:label]
|
34
|
-
when Symbol
|
35
|
-
doc.get(opts[:label])
|
36
|
-
when String
|
37
|
-
opts[:label]
|
38
|
-
else
|
39
|
-
raise 'Invalid label argument'
|
40
|
-
end
|
41
|
-
|
42
|
-
if label.blank?
|
43
|
-
label = doc[:id]
|
44
|
-
end
|
45
|
-
|
46
|
-
link_to_with_data(label, catalog_path(doc[:id]), {:method => :put, :data => {:counter => opts[:counter]},:title=>opts[:title]})
|
47
|
-
end
|
48
32
|
|
49
33
|
# currently only used by the render_document_partial helper method (below)
|
50
34
|
def document_partial_name(document)
|
@@ -34,7 +34,7 @@ module BlacklightHelper
|
|
34
34
|
def link_to_document(doc, opts={:label=>Blacklight.config[:index][:show_link].to_sym, :counter => nil,:title => nil})
|
35
35
|
label = case opts[:label]
|
36
36
|
when Symbol
|
37
|
-
doc.fetch(opts[:label], "
|
37
|
+
doc.fetch(opts[:label], "")
|
38
38
|
when String
|
39
39
|
opts[:label]
|
40
40
|
else
|
@@ -118,7 +118,9 @@ EOF
|
|
118
118
|
"\n before_filter :enforce_access_controls" +
|
119
119
|
"\n before_filter :enforce_viewing_context_for_show_requests, :only=>:show" +
|
120
120
|
"\n # This applies appropriate access controls to all solr queries" +
|
121
|
-
"\n CatalogController.solr_search_params_logic << :add_access_controls_to_solr_params"
|
121
|
+
"\n CatalogController.solr_search_params_logic << :add_access_controls_to_solr_params" +
|
122
|
+
"\n # This filters out objects that you want to exclude from search results, like FileAssets" +
|
123
|
+
"\n CatalogController.solr_search_params_logic << :exclude_unwanted_models"
|
122
124
|
end
|
123
125
|
else
|
124
126
|
puts " \e[31mFailure\e[0m Could not find #{model_name.underscore}.rb. To add Hydra behaviors to your Blacklight::Catalog Controllers, you must include the Hydra::Controller module in the Controller class definition. See the Hydra::Controller section in the Hydra API Docs for more info."
|
@@ -42,9 +42,16 @@ Blacklight.configure(:shared) do |config|
|
|
42
42
|
# TODO: Reorganize facet data structures supplied in config to make simpler
|
43
43
|
# for human reading/writing, kind of like search_fields. Eg,
|
44
44
|
# config[:facet] << {:field_name => "format", :label => "Format", :limit => 10}
|
45
|
+
#
|
46
|
+
# Hydra uses active_fedora_model_s by default for displaying Format because that field is automatically
|
47
|
+
# populated by active-fedora from your RELS-EXT. You can change this to anything you want to use though.
|
48
|
+
# for example, the sample Hydra::ModsAsset Datastream Class adds object_type_facet = "Article" in its to_solr method.\
|
49
|
+
# You could use that as the format field instead of active_fedora_model_s to have a more nicer value displayed.
|
50
|
+
#
|
51
|
+
#
|
45
52
|
config[:facet] = {
|
46
53
|
:field_names => (facet_fields = [
|
47
|
-
"
|
54
|
+
"active_fedora_model_s",
|
48
55
|
"pub_date",
|
49
56
|
"subject_topic_facet",
|
50
57
|
"language_facet",
|
@@ -53,7 +60,7 @@ Blacklight.configure(:shared) do |config|
|
|
53
60
|
"subject_era_facet"
|
54
61
|
]),
|
55
62
|
:labels => {
|
56
|
-
"
|
63
|
+
"active_fedora_model_s" => "Format",
|
57
64
|
"pub_date" => "Publication Year",
|
58
65
|
"subject_topic_facet" => "Topic",
|
59
66
|
"language_facet" => "Language",
|
data/lib/hydra-head/version.rb
CHANGED
@@ -172,13 +172,46 @@ module Hydra::AccessControlsEnforcement
|
|
172
172
|
# @param solr_parameters the current solr parameters
|
173
173
|
# @param user_parameters the current user-subitted parameters
|
174
174
|
def apply_gated_discovery(solr_parameters, user_parameters)
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
175
|
+
solr_parameters[:fq] ||= []
|
176
|
+
# Grant access to public content
|
177
|
+
permission_types = ["edit","discover","read"]
|
178
|
+
user_access_filters = []
|
179
|
+
|
180
|
+
permission_types.each do |type|
|
181
|
+
user_access_filters << "#{type}_access_group_t:public"
|
182
|
+
end
|
183
|
+
|
184
|
+
# Grant access based on user id & role
|
185
|
+
unless current_user.nil?
|
186
|
+
# for roles
|
187
|
+
RoleMapper.roles(current_user.login).each_with_index do |role, i|
|
188
|
+
permission_types.each do |type|
|
189
|
+
user_access_filters << "#{type}_access_group_t:#{role}"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
# for individual person access
|
193
|
+
permission_types.each do |type|
|
194
|
+
user_access_filters << "#{type}_access_person_t:#{current_user.login}"
|
195
|
+
end
|
196
|
+
if current_user.is_being_superuser?(session)
|
197
|
+
permission_types.each do |type|
|
198
|
+
user_access_filters << "#{type}_access_person_t:[* TO *]"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Enforcing Embargo at Query time has been disabled.
|
203
|
+
# If you want to do this, set up your own solr_search_params before_filter that injects the appropriate :fq constraints for a field that expresses your objects' embargo status.
|
204
|
+
#
|
205
|
+
# include docs in results if the embargo date is NOT in the future OR if the current user is depositor
|
206
|
+
# embargo_query = "(NOT embargo_release_date_dt:[NOW TO *]) OR depositor_t:#{current_user.login}"
|
207
|
+
# embargo_query = "(NOT embargo_release_date_dt:[NOW TO *]) OR (embargo_release_date_dt:[NOW TO *] AND depositor_t:#{current_user.login}) AND NOT (NOT depositor_t:#{current_user.login} AND embargo_release_date_dt:[NOW TO *])"
|
208
|
+
# solr_parameters[:fq] << embargo_query
|
209
|
+
end
|
210
|
+
solr_parameters[:fq] << user_access_filters.join(" OR ")
|
211
|
+
logger.debug("Solr parameters: #{ solr_parameters.inspect }")
|
180
212
|
end
|
181
213
|
|
214
|
+
|
182
215
|
# proxy for {enforce_index_permissions}
|
183
216
|
def enforce_search_permissions
|
184
217
|
enforce_index_permissions
|
@@ -188,10 +221,19 @@ module Hydra::AccessControlsEnforcement
|
|
188
221
|
def enforce_read_permissions
|
189
222
|
enforce_show_permissions
|
190
223
|
end
|
224
|
+
|
225
|
+
# This filters out objects that you want to exclude from search results. By default it only excludes FileAssets
|
226
|
+
# @param solr_parameters the current solr parameters
|
227
|
+
# @param user_parameters the current user-subitted parameters
|
228
|
+
def exclude_unwanted_models(solr_parameters, user_parameters)
|
229
|
+
solr_parameters[:fq] ||= []
|
230
|
+
solr_parameters[:fq] << "-has_model_s:\"info:fedora/afmodel:FileAsset\""
|
231
|
+
end
|
191
232
|
|
192
233
|
# Build the lucene query that performs gated discovery based on Hydra rightsMetadata information in Solr
|
193
234
|
# @param [String] user_query the user's original query request that will be wrapped in access controls
|
194
235
|
def build_lucene_query(user_query)
|
236
|
+
logger.warn("DEPRECATED: build_lucene_query has been deprecated. Recommended convention is to use blacklight's dismax search requestHandler (not lucene) and filter queries with :fq solr parameters. See Hydra::AccessControlsEnforcement#apply_gated_discovery and Hydra::AccessControlsEnforcement#exclude_unwanted_models")
|
195
237
|
q = ""
|
196
238
|
# start query of with user supplied query term
|
197
239
|
q << "_query_:\"{!dismax qf=$qf_dismax pf=$pf_dismax}#{user_query}\" AND " if user_query
|
@@ -25,7 +25,7 @@ namespace :hydra do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
desc "Delete the object identified by pid. Example: rake hydra:delete pid=demo:12"
|
28
|
-
task :delete => :
|
28
|
+
task :delete => :environment do
|
29
29
|
# If a destination url has been provided, attampt to export from the fedora repository there.
|
30
30
|
if ENV["destination"]
|
31
31
|
Fedora::Repository.register(ENV["destination"])
|
@@ -13,6 +13,14 @@ JETTY_PARAMS = {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
#:jetty_port => ENV['HYDRA_JETTY_PORT'],
|
16
|
+
|
17
|
+
namespace :jetty do
|
18
|
+
desc "Apply all configs to Testing Server (relies on hydra:jetty:config tasks unless you override it)"
|
19
|
+
task :config do
|
20
|
+
Rake::Task["hydra:jetty:config"].invoke
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
16
24
|
namespace :hydra do
|
17
25
|
namespace :jetty do
|
18
26
|
desc "Starts the bundled Hydra Testing Server"
|
@@ -39,13 +47,12 @@ namespace :hydra do
|
|
39
47
|
Rake::Task["hydra:jetty:config_solr"].invoke
|
40
48
|
end
|
41
49
|
|
42
|
-
desc "Copies the
|
50
|
+
desc "Copies the contents of solr_conf into the Solr development-core and test-core of Testing Server"
|
43
51
|
task :config_solr do
|
44
|
-
FileList['solr_conf
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
52
|
+
FileList['solr_conf/*'].each do |f|
|
53
|
+
cp_r("#{f}", 'jetty/solr/development-core/', :verbose => true)
|
54
|
+
cp_r("#{f}", 'jetty/solr/test-core/', :verbose => true)
|
55
|
+
end
|
49
56
|
end
|
50
57
|
|
51
58
|
desc "Copies a custom fedora config for the bundled Hydra Testing Server"
|
data/solr_conf/conf/schema.xml
CHANGED
@@ -118,5 +118,7 @@ This copy of the solr schema is only used in the context of testing hydra-head.
|
|
118
118
|
<defaultSearchField>text</defaultSearchField>
|
119
119
|
<solrQueryParser defaultOperator="AND" />
|
120
120
|
<copyField source="*_facet" dest="text" />
|
121
|
+
<copyField source="*_t" dest="text" />
|
122
|
+
<copyField source="*_s" dest="text" />
|
121
123
|
|
122
124
|
</schema>
|
@@ -82,51 +82,121 @@
|
|
82
82
|
</lst>
|
83
83
|
</requestHandler>
|
84
84
|
|
85
|
-
<!--
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
<!-- Searching ("All Fields") -->
|
86
|
+
<requestHandler name="search" class="solr.SearchHandler" default="true">
|
87
|
+
<lst name="defaults">
|
88
|
+
<str name="defType">dismax</str>
|
89
|
+
<str name="echoParams">explicit</str>
|
90
|
+
<str name="q.alt">*:*</str>
|
91
|
+
<str name="mm">2<-1 5<-2 6<90%</str>
|
92
|
+
<!-- this qf and pf are used by default, if not otherwise specified by
|
93
|
+
client. The default blacklight_config will use these for the
|
94
|
+
"keywords" search. See the author_qf/author_pf, title_qf, etc
|
95
|
+
below, which the default blacklight_config will specify for
|
96
|
+
those searches. You may also be interested in:
|
97
|
+
http://wiki.apache.org/solr/LocalParams
|
98
|
+
-->
|
99
|
+
<str name="qf">
|
100
|
+
id
|
101
|
+
title_t^25000
|
102
|
+
text
|
103
|
+
active_fedora_model_s
|
104
|
+
object_type_facet
|
105
|
+
</str>
|
106
|
+
<str name="pf">
|
107
|
+
id
|
108
|
+
title_t^250000
|
109
|
+
text^10
|
110
|
+
active_fedora_model_s
|
111
|
+
object_type_facet
|
112
|
+
</str>
|
113
|
+
<str name="author_qf">
|
114
|
+
author_unstem_search^200
|
115
|
+
author_addl_unstem_search^50
|
116
|
+
author_t^20
|
117
|
+
author_addl_t
|
118
|
+
</str>
|
119
|
+
<str name="author_pf">
|
120
|
+
author_unstem_search^2000
|
121
|
+
author_addl_unstem_search^500
|
122
|
+
author_t^200
|
123
|
+
author_addl_t^10
|
124
|
+
</str>
|
125
|
+
<str name="title_qf">
|
126
|
+
title_unstem_search^50000
|
127
|
+
subtitle_unstem_search^25000
|
128
|
+
title_addl_unstem_search^10000
|
129
|
+
title_t^5000
|
130
|
+
subtitle_t^2500
|
131
|
+
title_addl_t^100
|
132
|
+
title_added_entry_unstem_search^50
|
133
|
+
title_added_entry_t^10
|
134
|
+
title_series_unstem_search^5
|
135
|
+
title_series_t
|
136
|
+
</str>
|
137
|
+
<str name="title_pf">
|
138
|
+
title_unstem_search^500000
|
139
|
+
subtitle_unstem_search^250000
|
140
|
+
title_addl_unstem_search^100000
|
141
|
+
title_t^50000
|
142
|
+
subtitle_t^25000
|
143
|
+
title_addl_t^1000
|
144
|
+
title_added_entry_unstem_search^500
|
145
|
+
title_added_entry_t^100
|
146
|
+
title_series_t^50
|
147
|
+
title_series_unstem_search^10
|
148
|
+
</str>
|
149
|
+
<str name="subject_qf">
|
150
|
+
subject_topic_unstem_search^200
|
151
|
+
subject_unstem_search^125
|
152
|
+
subject_topic_facet^100
|
153
|
+
subject_t^50
|
154
|
+
subject_addl_unstem_search^10
|
155
|
+
subject_addl_t
|
156
|
+
</str>
|
157
|
+
<str name="subject_pf">
|
158
|
+
subject_topic_unstem_search^2000
|
159
|
+
subject_unstem_search^1250
|
160
|
+
subject_t^1000
|
161
|
+
subject_topic_facet^500
|
162
|
+
subject_addl_unstem_search^100
|
163
|
+
subject_addl_t^10
|
164
|
+
</str>
|
90
165
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
object_type_facet, department_facet, peer_reviewed_facet
|
126
|
-
</str>
|
127
|
-
</lst>
|
128
|
-
</requestHandler>
|
129
|
-
|
166
|
+
|
167
|
+
<int name="ps">3</int>
|
168
|
+
<float name="tie">0.01</float>
|
169
|
+
|
170
|
+
<!-- NOT using marc_display because it is large and will slow things down for search results -->
|
171
|
+
<str name="fl">
|
172
|
+
*,score
|
173
|
+
</str>
|
174
|
+
|
175
|
+
<str name="facet">true</str>
|
176
|
+
<str name="facet.mincount">1</str>
|
177
|
+
<str name="facet.limit">10</str>
|
178
|
+
<str name="facet.field">format</str>
|
179
|
+
<str name="facet.field">lc_1letter_facet</str>
|
180
|
+
<str name="facet.field">lc_alpha_facet</str>
|
181
|
+
<str name="facet.field">lc_b4cutter_facet</str>
|
182
|
+
<str name="facet.field">language_facet</str>
|
183
|
+
<str name="facet.field">pub_date</str>
|
184
|
+
<str name="facet.field">subject_era_facet</str>
|
185
|
+
<str name="facet.field">subject_geo_facet</str>
|
186
|
+
<str name="facet.field">subject_topic_facet</str>
|
187
|
+
|
188
|
+
<str name="spellcheck">true</str>
|
189
|
+
<str name="spellcheck.dictionary">default</str>
|
190
|
+
<str name="spellcheck.onlyMorePopular">true</str>
|
191
|
+
<str name="spellcheck.extendedResults">true</str>
|
192
|
+
<str name="spellcheck.collate">false</str>
|
193
|
+
<str name="spellcheck.count">5</str>
|
194
|
+
</lst>
|
195
|
+
<arr name="last-components">
|
196
|
+
<str>spellcheck</str>
|
197
|
+
</arr>
|
198
|
+
</requestHandler>
|
199
|
+
|
130
200
|
<requestHandler name="public_search" class="solr.SearchHandler" >
|
131
201
|
<lst name="defaults">
|
132
202
|
<!-- Making defType lucene to exclude file assets -->
|
@@ -137,6 +207,8 @@
|
|
137
207
|
<!-- dismax params -->
|
138
208
|
<str name="mm"> 2<-1 5<-2 6<90% </str>
|
139
209
|
<str name="q.alt">*:*</str>
|
210
|
+
<str name="qf">id^0.8 id_t^0.8 format text^0.3 journal_issn_t</str>
|
211
|
+
<str name="pf">id^0.9 id_t^0.9 text^0.5 journal_issn_t</str>
|
140
212
|
<str name="qf_dismax">id^0.8 id_t^0.8 format text^0.3</str>
|
141
213
|
<str name="pf_dismax">id^0.9 id_t^0.9 text^0.5</str>
|
142
214
|
<int name="ps">100</int>
|
@@ -146,17 +218,7 @@
|
|
146
218
|
<str name="facet.mincount">1</str>
|
147
219
|
<str name="echoParams">explicit</str>
|
148
220
|
<str name="fl">
|
149
|
-
|
150
|
-
person_0_role_t,person_1_role_t,person_2_role_t,person_3_role_t,person_4_role_t,person_5_role_t,person_6_role_t,person_7_role_t,person_8_role_t,person_9_role_t,
|
151
|
-
person_0_first_name_t,person_1_first_name_t,person_2_first_name_t,person_3_first_name_t,person_4_first_name_t,person_5_first_name_t,person_6_first_name_t,person_7_first_name_t,person_8_first_name_t,person_9_first_name_t,
|
152
|
-
person_0_last_name_t,person_1_last_name_t,person_2_last_name_t,person_3_last_name_t,person_4_last_name_t,person_5_last_name_t,person_6_last_name_t,person_7_last_name_t,person_8_last_name_t,person_9_last_name_t,depositor_t,
|
153
|
-
|
154
|
-
journal_title_info_t, journal_title_info_main_title_t, journal_issue_publication_date_t, journal_issue_pages_start_t, journal_issue_pages_end_t, journal_issue_volume_t, journal_issue_start_page_t, journal_issue_end_page_t, abstract_t,
|
155
|
-
person_0_institution_t,person_1_institution_t,person_2_institution_t,person_3_institution_t,person_4_institution_t,person_5_institution_t,person_institution_role_t,
|
156
|
-
person_7_institution_t,person_8_institution_t,person_9_institution_t,
|
157
|
-
mods_gps_t, mods_region_t, mods_site_t, mods_ecosystem_t,
|
158
|
-
mods_timespan_start_t, mods_timespan_end_t, description_t, mods_title_info_t,mods_0_title_info_0_main_title_t, embargo_release_date_dt, note_t,
|
159
|
-
object_type_facet, department_facet, peer_reviewed_facet
|
221
|
+
*,score
|
160
222
|
</str>
|
161
223
|
</lst>
|
162
224
|
</requestHandler>
|
@@ -1,14 +1,8 @@
|
|
1
1
|
Feature: Objects Without Models - Search Results
|
2
2
|
I want to see appropriate information in search results for objects without an (active)fedora model
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
And I am on the home page
|
7
|
-
And I fill in "q" with "test"
|
8
|
-
When I press "submit"
|
9
|
-
Then I should see a link to "the show document page for hydra:test_no_model"
|
10
|
-
|
11
|
-
# you can't see this object unless you are an editor
|
4
|
+
# Objects without a model, are not ever displayed because they don't have rightsMetadata
|
5
|
+
|
12
6
|
Scenario: html5 valid - unauthenticated
|
13
7
|
When I am on the home page
|
14
8
|
And I fill in "q" with "test"
|
@@ -14,14 +14,14 @@ Feature: HTML validity
|
|
14
14
|
|
15
15
|
Scenario: Search Results (unauthenticated)
|
16
16
|
Given I am on the home page
|
17
|
-
When I follow "
|
17
|
+
When I follow "ModsAsset"
|
18
18
|
Then I should see "TITLE OF HOST JOURNAL"
|
19
19
|
And the page should be HTML5 valid
|
20
20
|
|
21
21
|
Scenario: Search Results (authenticated)
|
22
22
|
Given I am logged in as "archivist1@example.com"
|
23
23
|
When I am on the home page
|
24
|
-
And I follow "
|
24
|
+
And I follow "ModsAsset"
|
25
25
|
Then I should see "TITLE OF HOST JOURNAL"
|
26
26
|
And the page should be HTML5 valid
|
27
27
|
|
@@ -13,12 +13,12 @@ Feature: ModsAsset Search Result
|
|
13
13
|
|
14
14
|
Scenario: html5 valid - unauthenticated
|
15
15
|
Given I am on the home page
|
16
|
-
When I follow "
|
16
|
+
When I follow "ModsAsset"
|
17
17
|
Then the page should be HTML5 valid
|
18
18
|
|
19
19
|
Scenario: html5 valid - authenticated
|
20
20
|
Given I am logged in as "archivist1@example.com"
|
21
21
|
When I am on the home page
|
22
|
-
And I follow "
|
22
|
+
And I follow "ModsAsset"
|
23
23
|
Then the page should be HTML5 valid
|
24
24
|
|
@@ -60,8 +60,10 @@ describe CatalogController do
|
|
60
60
|
|
61
61
|
describe "access controls" do
|
62
62
|
before(:all) do
|
63
|
-
@public_only_results = Blacklight.solr.find Hash[:
|
64
|
-
@
|
63
|
+
@public_only_results = Blacklight.solr.find Hash[:fq=>"access_t:public"]
|
64
|
+
# @public_only_results = Blacklight.solr.find Hash[:phrases=>{:access_t=>"public"}]
|
65
|
+
# @private_only_results = Blacklight.solr.find Hash[:phrases=>{:access_t=>"private"}]
|
66
|
+
@private_only_results = Blacklight.solr.find Hash[:fq=>"access_t:private"]
|
65
67
|
end
|
66
68
|
|
67
69
|
it "should only return public documents if role does not have permissions" do
|
@@ -72,7 +74,8 @@ describe CatalogController do
|
|
72
74
|
it "should return all documents if role does have permissions" do
|
73
75
|
User.any_instance.stubs(:login).returns("BigWig")
|
74
76
|
mock_user = User.new
|
75
|
-
session[:superuser_mode] = true
|
77
|
+
# session[:superuser_mode] = true
|
78
|
+
mock_user.stubs(:is_being_superuser?).returns(true)
|
76
79
|
controller.stubs(:current_user).returns(mock_user)
|
77
80
|
get :index
|
78
81
|
assigns(:document_list).count.should > @public_only_results.docs.count
|
@@ -2,6 +2,83 @@
|
|
2
2
|
require File.expand_path( File.join( File.dirname(__FILE__),'..','spec_helper') )
|
3
3
|
|
4
4
|
describe Hydra::AccessControlsEnforcement do
|
5
|
+
|
6
|
+
describe "apply_gated_discovery" do
|
7
|
+
before(:each) do
|
8
|
+
@stub_user = User.new :email=>'archivist1@example.com'
|
9
|
+
@stub_user.stubs(:is_being_superuser?).returns false
|
10
|
+
@stub_user.stubs(:login).returns "fred"
|
11
|
+
RoleMapper.stubs(:roles).with(@stub_user.login).returns(["archivist","researcher"])
|
12
|
+
helper.stubs(:current_user).returns(@stub_user)
|
13
|
+
@solr_parameters = {}
|
14
|
+
@user_parameters = {}
|
15
|
+
end
|
16
|
+
it "should set query fields for the user id checking against the discover, access, read fields" do
|
17
|
+
helper.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
18
|
+
["discover","edit","read"].each do |type|
|
19
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_person_t\:#{@stub_user.login}/)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
it "should set query fields for all roles the user is a member of checking against the discover, access, read fields" do
|
23
|
+
helper.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
24
|
+
["discover","edit","read"].each do |type|
|
25
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_t\:archivist/)
|
26
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_group_t\:researcher/)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
# it "should filter out any content whose embargo date is in the future" do
|
30
|
+
# helper.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
31
|
+
# @solr_parameters[:fq].should include("-embargo_release_date_dt:[NOW TO *]")
|
32
|
+
# end
|
33
|
+
it "should allow content owners access to their embargoed content" do
|
34
|
+
pending
|
35
|
+
helper.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
36
|
+
@solr_parameters[:fq].should include("(NOT embargo_release_date_dt:[NOW TO *]) OR depositor_t:#{@stub_user.login}")
|
37
|
+
|
38
|
+
# @solr_parameters[:fq].should include("embargo_release_date_dt:[NOW TO *] AND depositor_t:#{current_user.login}) AND NOT (NOT depositor_t:#{current_user.login} AND embargo_release_date_dt:[NOW TO *]")
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "for superusers" do
|
42
|
+
it "should return superuser access level" do
|
43
|
+
stub_user = User.new
|
44
|
+
stub_user.stubs(:login).returns "suzie"
|
45
|
+
stub_user.stubs(:is_being_superuser?).returns true
|
46
|
+
RoleMapper.stubs(:roles).with(stub_user.login).returns(["archivist","researcher"])
|
47
|
+
helper.stubs(:current_user).returns(stub_user)
|
48
|
+
helper.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
49
|
+
["discover","edit","read"].each do |type|
|
50
|
+
@solr_parameters[:fq].first.should match(/#{type}_access_person_t\:\[\* TO \*\]/)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
it "should not return superuser access to non-superusers" do
|
54
|
+
stub_user = User.new
|
55
|
+
stub_user.stubs(:login).returns "suzie"
|
56
|
+
stub_user.stubs(:is_being_superuser?).returns false
|
57
|
+
RoleMapper.stubs(:roles).with(stub_user.login).returns(["archivist","researcher"])
|
58
|
+
helper.stubs(:current_user).returns(stub_user)
|
59
|
+
helper.send(:apply_gated_discovery, @solr_parameters, @user_parameters)
|
60
|
+
["discover","edit","read"].each do |type|
|
61
|
+
@solr_parameters[:fq].should_not include("#{type}_access_person_t\:\[\* TO \*\]")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "exclude_unwanted_models" do
|
69
|
+
before(:each) do
|
70
|
+
stub_user = User.new :email=>'archivist1@example.com'
|
71
|
+
stub_user.stubs(:is_being_superuser?).returns false
|
72
|
+
helper.stubs(:current_user).returns(stub_user)
|
73
|
+
@solr_parameters = {}
|
74
|
+
@user_parameters = {}
|
75
|
+
end
|
76
|
+
it "should set solr query parameters to filter out FileAssets" do
|
77
|
+
helper.send(:exclude_unwanted_models, @solr_parameters, @user_parameters)
|
78
|
+
@solr_parameters[:fq].should include("-has_model_s:\"info:fedora/afmodel:FileAsset\"")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
5
82
|
describe "build_lucene_query" do
|
6
83
|
|
7
84
|
it "should return fields for all roles the user is a member of checking against the discover, access, read fields" do
|
metadata
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-head
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
|
11
|
-
- 2
|
12
|
-
version: 3.0.0.rc2
|
10
|
+
version: 3.0.0
|
13
11
|
platform: ruby
|
14
12
|
authors:
|
15
13
|
- Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield, Justin Coyne & many more. See https://github.com/projecthydra/hydra-head/contributors
|
@@ -17,7 +15,7 @@ autorequire:
|
|
17
15
|
bindir: bin
|
18
16
|
cert_chain: []
|
19
17
|
|
20
|
-
date: 2011-
|
18
|
+
date: 2011-11-08 00:00:00 -08:00
|
21
19
|
default_executable:
|
22
20
|
dependencies:
|
23
21
|
- !ruby/object:Gem::Dependency
|
@@ -757,6 +755,7 @@ files:
|
|
757
755
|
- README_RAKE_TASKS.textile
|
758
756
|
- README_SUBTREE.textile
|
759
757
|
- README_TERSE.textile
|
758
|
+
- RELEASE_NOTES.textile
|
760
759
|
- Rakefile
|
761
760
|
- TESTING.textile
|
762
761
|
- TESTING_PLUGIN.textile
|
@@ -1282,14 +1281,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1282
1281
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1283
1282
|
none: false
|
1284
1283
|
requirements:
|
1285
|
-
- - "
|
1284
|
+
- - ">="
|
1286
1285
|
- !ruby/object:Gem::Version
|
1287
|
-
hash:
|
1286
|
+
hash: 3
|
1288
1287
|
segments:
|
1289
|
-
-
|
1290
|
-
|
1291
|
-
- 1
|
1292
|
-
version: 1.3.1
|
1288
|
+
- 0
|
1289
|
+
version: "0"
|
1293
1290
|
requirements: []
|
1294
1291
|
|
1295
1292
|
rubyforge_project:
|