hydra 10.0.0 → 10.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/doc/Dive-into-Hydra.md +60 -57
  3. data/doc/For-Developers.md +0 -1
  4. data/doc/Hackfest-ideas.md +18 -0
  5. data/doc/Home.md +3 -1
  6. data/doc/Hydra-Recipes.md +5 -1
  7. data/doc/LDP-Containers-for-the-perplexed.md +119 -0
  8. data/doc/Lesson---Adding-attached-files.md +83 -0
  9. data/doc/Lesson---Build-a-Codex-model-with-XML.md +272 -0
  10. data/doc/Lesson---Build-a-book-model-with-RDF.md +250 -0
  11. data/doc/Lesson---Define-Relationships-Between-Objects.md +125 -0
  12. data/doc/{Lesson:-Generate-Rails-Scaffolding-for-Creating-and-Editing-Books.md → Lesson---Generate-Rails-Scaffolding-for-Creating-and-Editing-Books.md} +57 -50
  13. data/doc/Lesson---Start-FCRepo-and-Solr.md +76 -0
  14. data/doc/{Lesson:-add-the-Hydra-dependencies.md → Lesson---add-the-Hydra-dependencies.md} +3 -3
  15. data/doc/{Lesson:-generate-a-rails-application.md → Lesson---generate-a-rails-application.md} +78 -91
  16. data/doc/Lesson---make-blacklight-return-search-results.md +71 -0
  17. data/doc/Lesson---start-the-application-&-search-for-results.md +55 -0
  18. data/doc/Recipe:-Add-full-text-indexing-to-your-app.md +27 -0
  19. data/doc/Using-rdf:resource-within-your-models.md +43 -0
  20. data/hydra.gemspec +1 -1
  21. data/lib/hydra/version.rb +1 -1
  22. data/script/grant_revoke_gem_authority.rb +1 -1
  23. metadata +18 -17
  24. data/doc/Lesson:-Define-Relationships-Between-Objects.md +0 -131
  25. data/doc/Lesson:-Reading-Hydra-rightsMetadata-XML.md +0 -87
  26. data/doc/Lesson:-Use-Hydra-Access-Controls-to-Control-Access-to-Blacklight-show-Pages.md +0 -37
  27. data/doc/Lesson:-Using-Hydra-Access-Controls-and-CanCan-to-conditionally-render-part-of-a-page.md +0 -29
  28. data/doc/Lesson:-adding-content-datastreams.md +0 -57
  29. data/doc/Lesson:-build-a-book-model.md +0 -265
  30. data/doc/Lesson:-install-hydra-jetty.md +0 -148
  31. data/doc/Lesson:-make-blacklight-return-search-results.md +0 -69
  32. data/doc/Lesson:-set-up-your-Rails-Application-to-use-rspec.md +0 -41
  33. data/doc/Lesson:-start-the-application-&-search-for-results.md +0 -29
@@ -1,265 +0,0 @@
1
- # Goals
2
- * Define a simple OM (Opinionated Metadata) Terminology for Book Metadata that we will track as XML Datastreams
3
- * Start the Rails console and run code interactively in the console
4
- * Create Datastream objects that use your OM Terminology
5
- * Define an ActiveFedora Model for Book objects
6
- * Declare a Datastream called descMetadata on your Book model and make it use your Book Metadata Terminology
7
- * Delegate methods from Book objects to their descMetadata Datastream
8
- * Create Book objects that use your Book Model
9
- * See how an object has been indexed into Solr
10
- * See how & where objects and metadata are stored in Fedora
11
- * Use OM to Manage how your Metadata is indexed in Solr
12
- * Re-index objects into Solr (update Solr based on any changes to an object, its Model, or the OM Terminologies it uses)
13
-
14
- # Explanation
15
- In Fedora an object can have many 'datastreams' which are either content for the object or metadata about the object. We are going to create a 'book' object. This object will have a metadata datastream which will contain some XML that describes the properties of the book. We'll call this datastream 'descMetadata'. You are free to call it whatever you like, but 'descMetadata' is a loose convention that stands for 'descriptive metadata'.
16
-
17
- Once you've created an object and saved it in Fedora, you also want to be able to search for it in Solr. ActiveFedora and OM make it easy to get your metadata into Solr and manage if/when/how your metadata is indexed.
18
-
19
- # Steps
20
-
21
- ### Step 1: Create an OM Terminology for Book Metadata
22
-
23
- First we'll create a Ruby class that represents this descriptive metadata. Make a new directory for our datastreams by typing in
24
- ```bash
25
- $> mkdir app/models/datastreams
26
- ```
27
-
28
- Now we'll create a file called `app/models/datastreams/book_metadata.rb`
29
-
30
- Paste the following code into that file:
31
-
32
- ```ruby
33
- class BookMetadata < ActiveFedora::OmDatastream
34
-
35
- set_terminology do |t|
36
- t.root(path: "fields")
37
- t.title
38
- t.author
39
- end
40
-
41
- def self.xml_template
42
- Nokogiri::XML.parse("<fields/>")
43
- end
44
-
45
- def prefix
46
- # set a datastream prefix if you need to namespace terms that might occur in multiple data streams
47
- ""
48
- end
49
-
50
- end
51
- ```
52
-
53
- This class extends from OmDatastream. OM is a gem that allows us to describe the format of an xml file and access properties. We are using OM by calling the `set_terminology` method. The xml_template method tells OM how to create a new xml document for this class.
54
-
55
- **Tip:** If you want to learn about OM Terminologies and how they work, visit the [Tame your XML with OM](https://github.com/projecthydra/om/wiki/Tame-your-XML-with-OM) Tutorial.
56
-
57
- ### Step 2: Start the Rails console
58
-
59
- Let's take a look at how this class works. We'll start the rails console by typing
60
-
61
- ```bash
62
- $> rails console
63
- ```
64
-
65
- You should see something like `Loading development environment (Rails 3.2.11)`. Now you're in a "[REPL](http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)", or *interactive ruby console* that has all of your Rails application's code and configuration loaded.
66
-
67
- ### Step 3: In the console, create Datastream objects that use your OM Terminology
68
-
69
- Let's create a new BookMetadata instance. I've shown the expected output after each command:
70
-
71
- ```text
72
- d = BookMetadata.new
73
- => #<BookMetadata @pid="" @dsid="" @controlGroup="X" changed="false" @mimeType="text/xml" >
74
- d.title = "ZOIA! Memoirs of Zoia Horn, Battler for the People's Right to Know."
75
- => "ZOIA! Memoirs of Zoia Horn, Battler for the People's Right to Know."
76
- d.author = "Horn, Zoia"
77
- => "Horn, Zoia"
78
- d.to_xml
79
- => "<fields>\n <title>ZOIA! Memoirs of Zoia Horn, Battler for the People's Right to Know.</title>\n <author>Horn, Zoia</author>\n</fields>"
80
- ```
81
-
82
- Once you're done, exit the console by typing ```exit```
83
-
84
-
85
- ### Step 4: Define a Book Model
86
-
87
- Now let's, create a model that uses this datastream. Create a new file at `app/models/book.rb`. We'll paste in this code:
88
-
89
- ```ruby
90
- class Book < ActiveFedora::Base
91
- has_metadata 'descMetadata', type: BookMetadata
92
-
93
- has_attributes :title, datastream: 'descMetadata', multiple: false
94
- has_attributes :author, datastream: 'descMetadata', multiple: false
95
-
96
- end
97
- ```
98
-
99
- We've defined our Book model to use the BookMetadata for its datastream called 'descMetadata'. We're telling the model to use the descMetadata as the delegate for the properties 'title' and 'author'. We are also telling Active Fedora to treat these attributes as single values rather than as multi-valued arrays.
100
-
101
- ### Step 5: In the console, create Datastream objects that use your OM Terminology
102
-
103
- Now we'll open the `rails console` again and see how to work with our book.
104
-
105
- ```text
106
- b = Book.create(title: 'Anna Karenina', author: 'Tolstoy, Leo')
107
- => #<Book pid:"changeme:1", title:["Anna Karenina"], author:["Tolstoy, Leo"]>
108
- ```
109
-
110
- We've created a new Book object in the repository. You can see that it has a pid (Fedora Commons persistence identifier) of 'changeme:1'. Because you set title and author to delegate to the descMetadata datastream, they are stored in that datastream's XML and can be accessed either through the delegated methods on the Book, or by going specifically to the datastream.
111
-
112
-
113
- ```text
114
- b.descMetadata
115
- => #<BookMetadata @pid="changeme:1" @dsid="descMetadata" @controlGroup="M" changed="false" @mimeType="text/xml" >
116
- b.title
117
- => "Anna Karenina"
118
- b.author
119
- => "Tolstoy, Leo"
120
- b.descMetadata.title
121
- => ["Anna Karenina"]
122
- b.descMetadata.author
123
- => ["Tolstoy, Leo"]
124
- ```
125
-
126
-
127
- ### Step 6: See what your Book objects look like in Fedora and Solr
128
-
129
- If we go to [[http://localhost:8983/fedora/objects/changeme:1]] we should see what it looks like in fedora. Note especially that the xml datastream has been ingested [[http://localhost:8983/fedora/objects/changeme:1/datastreams/descMetadata/content]]. The content of that datastream should look like this in your browser:
130
-
131
- ```xml
132
- <fields>
133
- <title>Anna Karenina</title>
134
- <author>Tolstoy, Leo</author>
135
- </fields>
136
- ```
137
-
138
- Let's also see that this book has been ingested into the Solr search index. [[http://localhost:8983/solr/select?q=changeme:1]]. It should look like the sample below. Note that, at this point, the title and author have not been stored in solr. You only get fields like `system_create_dtsi`, `system_modified_dtsi`, `id`, `object_profile_ssm`, and `has_model_ssim`. In the next step we will modify our BookMetadata datastream to add the book metadata to the solr document.
139
-
140
- ```xml
141
- <?xml version="1.0"?>
142
- <response>
143
- <lst name="responseHeader">
144
- <int name="status">0</int>
145
- <int name="QTime">3</int>
146
- <lst name="params">
147
- <str name="q">changeme:4</str>
148
- </lst>
149
- </lst>
150
- <result name="response" numFound="1" start="0" maxScore="0.05991731">
151
- <doc>
152
- <date name="system_create_dtsi">2013-05-06T16:22:39Z</date>
153
- <date name="system_modified_dtsi">2013-05-06T16:22:39Z</date>
154
- <arr name="active_fedora_model_ssim">
155
- <str>Book</str>
156
- </arr>
157
- <str name="id">changeme:4</str>
158
- <arr name="object_profile_ssm">
159
- <str>{"datastreams":{"RELS-EXT":{"dsLabel":"Fedora Object-to-Object Relationship Metadata","dsVersionID":"RELS-EXT.0","dsCreateDate":"2013-05-06T16:22:40Z","dsState":"A","dsMIME":"application/rdf+xml","dsFormatURI":null,"dsControlGroup":"X","dsSize":277,"dsVersionable":true,"dsInfoType":null,"dsLocation":"changeme:4+RELS-EXT+RELS-EXT.0","dsLocationType":null,"dsChecksumType":"DISABLED","dsChecksum":"none"},"descMetadata":{"dsLabel":null,"dsVersionID":"descMetadata.0","dsCreateDate":"2013-05-06T16:22:41Z","dsState":"A","dsMIME":"text/xml","dsFormatURI":null,"dsControlGroup":"M","dsSize":81,"dsVersionable":true,"dsInfoType":null,"dsLocation":"changeme:4+descMetadata+descMetadata.0","dsLocationType":"INTERNAL_ID","dsChecksumType":"DISABLED","dsChecksum":"none"},"rightsMetadata":{}},"objLabel":null,"objOwnerId":"fedoraAdmin","objModels":["info:fedora/fedora-system:FedoraObject-3.0"],"objCreateDate":"2013-05-06T16:22:39Z","objLastModDate":"2013-05-06T16:22:39Z","objDissIndexViewURL":"http://localhost:8983/fedora/objects/changeme%3A4/methods/fedora-system%3A3/viewMethodIndex","objItemIndexViewURL":"http://localhost:8983/fedora/objects/changeme%3A4/methods/fedora-system%3A3/viewItemIndex","objState":"A"}</str>
160
- </arr>
161
- <arr name="has_model_ssim">
162
- <str>info:fedora/afmodel:Book</str>
163
- </arr>
164
- <date name="timestamp">2013-05-06T16:22:58.397Z</date>
165
- <float name="score">0.05991731</float>
166
- </doc>
167
- </result>
168
- <lst name="facet_counts">
169
- <lst name="facet_queries"/>
170
- <lst name="facet_fields">
171
- <lst name="active_fedora_model_ssi"/>
172
- <lst name="object_type_si"/>
173
- </lst>
174
- <lst name="facet_dates"/>
175
- <lst name="facet_ranges"/>
176
- </lst>
177
- </response>
178
- ```
179
- ### Step 7: See how your Book metadata are indexed into Solr
180
-
181
-
182
- The to_solr method is what generates the solr document for your objects and their datastreams. To see the full solr document for the book we created, call
183
-
184
- ```text
185
- b.to_solr
186
- ```
187
-
188
- To see just the part of the solr document that comes from the descMetadata datastream (which has our book title and author), call
189
-
190
- ```text
191
- b.descMetadata.to_solr
192
- => {}
193
- ```
194
-
195
- As you can see, the descMetadata datastream is returning an empty Hash, meaning that it isn't indexing the author and title values.
196
-
197
- ### Step 8: Change how your Book metadata are indexed into Solr
198
-
199
- To make the BookMetadata Terminology index the author and title fields, you need to reopen `app/models/datastreams/book_metadata.rb` and change the terminology section to look like this:
200
-
201
- ```ruby
202
- set_terminology do |t|
203
- t.root(path: "fields")
204
- t.title(index_as: :stored_searchable)
205
- t.author(index_as: :stored_searchable)
206
- end
207
- ```
208
-
209
- **Note:** Because we have made changes to our Ruby code that we want to use, we need to restart the Rails console so that it will reload all of the code, including our latest changes.
210
-
211
- Now, **restart the rails console** and we can load the object we previously created:
212
-
213
- ```text
214
- b = Book.find('changeme:1')
215
- => #<Book pid:"changeme:1", title:"Anna Karenina", author:"Tolstoy, Leo">
216
- ```
217
-
218
- Check and see that to_solr includes the title and author fields.
219
-
220
- ```text
221
- b.descMetadata.to_solr
222
- => {"title_tesim"=>["Anna Karenina"], "author_tesim"=>["Tolstoy, Leo"]}
223
- ```
224
- Now when you call `.to_solr` on a BookMetadata datastream it returns a solr document with fields named `title_tesim` and `author_tesim` that contain your title and author values. Those are the field names that we will add to Blacklight's queries in [[Lesson: Make Blacklight Return Search Results]].
225
-
226
-
227
- ### Step 9: Re-index an object in Solr
228
-
229
- Now we'll call the ```update_index``` method, which republishes the Solr document using the changes we've made.
230
-
231
- ```text
232
- b.update_index
233
- => {"responseHeader"=>{"status"=>0, "QTime"=>25}}
234
- ```
235
-
236
- If you refresh the document result from solr ([[http://localhost:8983/solr/select?q=changeme:1]]) you should see that these fields have been added to the solr_document:
237
-
238
- ```xml
239
- <arr name="title_tesim">
240
- <str>Anna Karenina</str>
241
- </arr>
242
- <arr name="author_tesim">
243
- <str>Tolstoy, Leo</str>
244
- </arr>
245
- ```
246
-
247
- **Aside:** The strange suffixes on the field names are provided by [solrizer](http://github.com/projecthydra/solrizer). You can read about them in the [solrizer documentaton](https://github.com/projecthydra/hydra-head/wiki/Solr-Schema). In short, the **_tesim** suffix tells Solr to treat the values as _**t**ext_ in the _**e**nglish_ language that should be _**s**tored_, _**i**ndexed_ and allowed to be _**m**ultivalued_. This _tesim suffix is a useful catch-all that gets your searches working predictably with minimal fuss. As you encounter cases where you need to index your content in more nuanced ways, there are ways to change these suffixes in order to achieve different results in Solr.
248
-
249
- #### Why doesn't the Book show up in Blacklight?
250
-
251
- Now your object is indexed properly, but it **won't show up in Blacklight's search results** until you've turned off access controls and added the appropriate fields to Blacklight's queries. We cover those in the next 2 lessons.
252
-
253
- ### Step 10: Commit your changes
254
-
255
- Now that we've got our model working, it's a great time to commit to git:
256
-
257
- ```text
258
- git add .
259
- git commit -m "Created a book model and a datastream"
260
- ```
261
-
262
- # Next Step
263
- Go on to [[Lesson: Make Blacklight Return Search Results]] or return to the [[Dive into Hydra]] page.
264
-
265
- If you want to learn about OM Terminologies and how they work, visit the [Tame your XML with OM](https://github.com/projecthydra/om/wiki/Tame-your-XML-with-OM) Tutorial.
@@ -1,148 +0,0 @@
1
- # Goals
2
- * Install a copy of hydra-jetty, which includes pre-configured copies of Fedora and Solr
3
- * Learn to start and stop hydra-jetty (which contains Fedora and Solr)
4
-
5
- # Explanation
6
- In order to use blacklight and hydra-head, you need an installation of Solr. In addition, hydra-head requires a copy of Fedora. Fedora and Solr are both Java web applications that need to run in a servlet container like Tomcat or Jetty.
7
-
8
- For developer environments, we have created a package called hydra-jetty which provides both services pre-installed within a Jetty Java application server. Whenever you need Fedora and Solr running in your development environment, just start or stop that copy of hydra-jetty.
9
-
10
- >
11
- **TIP** *DO NOT* use hydra-jetty for production installations. The hydra-jetty passwords are well-known and the installation has not been secured for non-local use.
12
- >
13
-
14
- # Steps
15
-
16
- ### Step 1: Install the hydra-jetty package
17
-
18
- Use the hydra:jetty generator to install the hydra-jetty package by running:
19
-
20
- >
21
- **TIP** hydra-jetty is a very large download. If you are completing this lesson as part of a workshop, the facilitator may have a copy of hydra-jetty that you can load from a flash-drive rather than downloading over the internet. The workshop facilitator will provide alternate instructions for this step.
22
- >
23
-
24
- ```text
25
- rails g hydra:jetty
26
- ```
27
-
28
- Note: this requires that your system have curl installed. If it does not, you may see an unhelpful error:
29
-
30
- ```text
31
- Unable to download jetty from https://github.com/projecthydra/hydra-jetty/archive/v7.0.0.zip
32
- ```
33
-
34
- This generator is provided by the jettywrapper gem.
35
-
36
-
37
- This can be very slow (over 100Mb of download). When it's done you'll see the directory named `jetty` has been created. If you run `git status` you will see
38
-
39
- ```text
40
- # On branch master
41
- # Untracked files:
42
- # (use "git add <file>..." to include in what will be committed)
43
- #
44
- # jetty/
45
- ```
46
-
47
- **Windows Tip**: Currently this rake task doesn't work on Windows (see [jettywrapper issue #14](https://github.com/projecthydra/jettywrapper/issues/14) for status). Workaround: Download https://github.com/projecthydra/hydra-jetty/archive/v7.0.0.zip, unpack it, and move the unpacked 'jetty' directory to the root of your application.
48
-
49
- ### Step 2: Make git ignore the jetty directory
50
-
51
- We want git to ignore the jetty directory for the same reasons that we don't check our development databases into git -- because it's big and bulky and you don't actually need other developers to have exact copies of your jetty as long as they have all the other code.
52
-
53
- We do that by editing `.gitignore` and adding the something like this:
54
-
55
- ```text
56
- # Ignore jetty directory (from hydra-jetty)
57
- /jetty
58
-
59
- ```
60
-
61
- Now commit this change
62
-
63
- ```text
64
- git add .gitignore
65
- git commit -m "Adds /jetty to .gitignore"
66
- ```
67
-
68
- ### Step 3: Start Jetty
69
- At the project root, type
70
-
71
- ```text
72
- rake jetty:start
73
- ```
74
-
75
- You should see output like this:
76
-
77
- >
78
- ```text
79
- Starting jetty with these values:
80
- jetty_home: /Users/justin/hydra-demo/jetty
81
- jetty_command: java -Djetty.port=8983 -Dsolr.solr.home=/Users/justin/hydra-demo/jetty/solr -Xmx256m -XX:MaxPermSize=128m -jar start.jar
82
- Logging jettywrapper stdout to /Users/justin/hydra-demo/jetty/jettywrapper.log
83
- Wrote pid file to /Users/justin/hydra-demo/tmp/pids/_Users_justin_hydra-demo_jetty.pid with value 8315
84
- Waited 5 seconds for jetty to start, but it is not yet listening on port 8983. Continuing anyway.
85
- Started jetty (5575.9ms)
86
- ```
87
- >
88
-
89
- hydra-jetty has a fair amount of stuff in it, so it may take up to a minute to start. You can check to see if it's started by going to [[http://localhost:8983/solr]]
90
-
91
- If Fedora, Solr, or jetty itself are not starting, you'll want to look at the jettywrapper log to diagnose.
92
-
93
- **Windows Tip:** This rake task is not currently working on Windows (see [jettywrapper issue #13](https://github.com/projecthydra/jettywrapper/issues/13) for status). In the meantime, start jetty manually
94
-
95
- ```text
96
- cd jetty
97
- java -Djetty.port=8983 -Dsolr.solr.home=/Users/justin/hydra-demo/jetty/solr -Xmx256m -XX:MaxPermSize=128m -jar start.jar
98
- ```
99
-
100
- ### Step 4: Look at the jettywrapper log
101
-
102
- The jetty:start rake task runs jetty as a background job, so jetty's logs won't appear in your terminal. Instead they're written to the file `jetty/jettywrapper.log`. If you look at the output from running the jetty:start task, you'll see that one line gives you the full path to the file, for example:
103
-
104
- ```text
105
- Logging jettywrapper stdout to /Users/justin/hydra-demo/jetty/jettywrapper.log
106
- ```
107
-
108
- You can open this log file with any text editor or log reader.
109
-
110
- ```text
111
- vi jetty/jettywrapper.log
112
- ```
113
-
114
- ### Step 5: Monitor the jettywrapper log
115
-
116
- >
117
- **Tip:** if jetty is taking a long time to start, you can watch its output using the tail command with the path to your jettywrapper.log. For example:
118
-
119
- ```text
120
- tail -f jetty/jettywrapper.log
121
- ```
122
- >
123
-
124
- As Jetty, Fedora, and Solr start you will see more info being written to the log file. After a few moments you will be able to open jetty at [[http://localhost:8983]] or [[http://0.0.0.0:8983]] (**note:** The root page will give a 404 error, but should have three links to the applications running in Jetty: /solr, /fedora and /fedora-test)
125
-
126
- ### Step 6: Stop Jetty
127
- You might have guessed this one. In order to stop jetty, at the project root, type
128
-
129
- ```text
130
- rake jetty:stop
131
- ```
132
-
133
- ### Step 7: Start Jetty again
134
- Before proceeding to the next lesson, make sure jetty is running. If you're not sure whether it's running, go to http://localhost:8983. If jetty is running a page will load. If jetty is not running no page will load.
135
-
136
- If it's not running, just use the jetty:start rake task again.
137
-
138
- ```text
139
- rake jetty:start
140
- ```
141
-
142
-
143
- >
144
- **Tip:** Sometimes people are confused about whether they need to restart jetty when they restart their Rails application. In most cases it is fine to leave jetty running when you start, stop, and restart the Rails application. The only exception is when you make changes to Solr's configuration or Fedora's configuration -- these would be changes to files inside of your copy of hydra-jetty (ie. jetty/solr/config), not changes to files in your Rails application's Ruby code. In those cases, where you have made changes to Solr or Fedora's configuration, you need to restart Jetty in order for those changes to take effect. The most common change that requires restarting jetty is when you modify the solrconfig.xml or schema.xml in your solr config directory.
145
- >
146
-
147
- # Next Step
148
- Go on to [[Lesson: Start the Application & Search for Results]] or return to the [[Dive into Hydra]] page.
@@ -1,69 +0,0 @@
1
- # Goals
2
- * *(for now)* Turn off access controls for Blacklight-based searches and "show" views
3
- * Tell Blacklight which fields to use in searches
4
- * Run a search in Blacklight and see results rendered
5
-
6
- # Explanation
7
-
8
- In [[Lesson: Build a Book Model]] you made a Book object, saved it, and saw that the Book's metadata was indexed in Solr. Now we will make that Book appear in your Blacklight searches.
9
-
10
- One of the main features that Hydra adds to Blacklight is the ability to control who has access to which information in search results. That topic gets a little bit complicated. For the purpose of this Tutorial we want to stay focused on showing you how to set up an app, define models and create objects based on those models, so in order to keep things simple we will make this Hydra Head behave like an open access repository where everyone can see everything. Once you've completed this tutorial, you can check out [Access Controls with Hydra](https://github.com/projecthydra/hydra-head/wiki/Access-Controls-with-Hydra) to learn how to assert access controls on objects and enforce those access controls in a Hydra Head.
11
-
12
- Once you've turned off access controls in step #1, we show you how to tell blacklight which fields you want to use for default searches in the remaining steps.
13
-
14
- # Steps
15
-
16
- ### Step 1: Comment out the lines that enforce access controls in Blacklight's CatalogController
17
-
18
- If you open ```app/controllers/catalog_controller.rb``` and look at the code near lines 8-12 you should see this:
19
- ```ruby
20
- # These before_filters apply the hydra access controls
21
- before_filter :enforce_show_permissions, :only=>:show
22
- # This applies appropriate access controls to all solr queries
23
- CatalogController.solr_search_params_logic += [:add_access_controls_to_solr_params]
24
- ```
25
-
26
- This code tells blacklight to enforce access controls on the search and result view pages. For the time being we will turn this off by commenting out two lines so that it looks like this:
27
-
28
- ```ruby
29
- # These before_filters apply the hydra access controls
30
- #before_filter :enforce_show_permissions, :only=>:show
31
- # This applies appropriate access controls to all solr queries
32
- #CatalogController.solr_search_params_logic += [:add_access_controls_to_solr_params]
33
- ```
34
- Then, save the file.
35
-
36
- ### Step 2: Run a search in the CatalogController
37
-
38
- Visit or reload the page at [[http://localhost:3000/]]. You should see the Blacklight search interface with a search box. If you search for 'Anna' you don't see any results even though we created a Book called "Anna Karenina" and indexed it in Solr in the last lesson.
39
-
40
- ### Step 3: Tell Blacklight which fields to use in Queries
41
-
42
- The reason why we're not getting any hits is because we haven't told Blacklight which fields to search in. Let's fix that by setting the default 'qf' solr parameter. Open `app/controllers/catalog_controller.rb` and set the `default_solr_params` section (around line 18) to this:
43
-
44
- ```ruby
45
- config.default_solr_params = {
46
- :qf => 'title_tesim author_tesim',
47
- :qt => 'search',
48
- :rows => 10
49
- }
50
- ```
51
-
52
- ### Step 4: Re-run your search
53
-
54
- Save the file, and refresh your web browser. You should now see a result for "Anna Karenina" when you search for "Anna"
55
-
56
- **Tip:** When you make changes like this, you *don't* need to restart the Rails server. This is because in development mode (which is the default environment for the Rails server), the Rails server reloads any files in app/models, app/controllers, app/views, etc. for every request it receives from a browser. This makes the server slower, but it makes life much smoother when you're actively developing and making changes.
57
-
58
- ### Step 5: Commit your changes
59
-
60
- Now that we've updated our search functionality, it's a great time to commit to git:
61
-
62
- ```text
63
- git add .
64
- git commit -m "Disabled access controls and set default search fields"
65
- ```
66
-
67
- # Next Step
68
- Go on to **BONUS** [[Lesson: Define Relationships Between Objects]] or
69
- explore other [Dive into Hydra](Dive into Hydra#Bonus) tutorial bonus lessons.