active-fedora 9.12.0 → 9.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/active-fedora.gemspec +1 -0
  4. data/lib/active_fedora.rb +1 -0
  5. data/lib/active_fedora/associations.rb +38 -3
  6. data/lib/active_fedora/associations/basic_contains_association.rb +12 -51
  7. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  8. data/lib/active_fedora/associations/builder/basic_contains.rb +7 -0
  9. data/lib/active_fedora/associations/builder/{contains.rb → has_subresource.rb} +2 -2
  10. data/lib/active_fedora/associations/contains_association.rb +19 -1
  11. data/lib/active_fedora/associations/directly_contains_association.rb +1 -15
  12. data/lib/active_fedora/associations/has_subresource_association.rb +61 -0
  13. data/lib/active_fedora/attached_files.rb +6 -9
  14. data/lib/active_fedora/autosave_association.rb +1 -1
  15. data/lib/active_fedora/base.rb +0 -1
  16. data/lib/active_fedora/common.rb +1 -0
  17. data/lib/active_fedora/fedora.rb +14 -19
  18. data/lib/active_fedora/file.rb +1 -1
  19. data/lib/active_fedora/file/attributes.rb +4 -0
  20. data/lib/active_fedora/file_persistence.rb +9 -1
  21. data/lib/active_fedora/initializing_connection.rb +64 -0
  22. data/lib/active_fedora/ldp_cache.rb +1 -2
  23. data/lib/active_fedora/ldp_resource_service.rb +7 -1
  24. data/lib/active_fedora/persistence.rb +12 -1
  25. data/lib/active_fedora/reflection.rb +22 -6
  26. data/lib/active_fedora/simple_datastream.rb +2 -0
  27. data/lib/active_fedora/version.rb +1 -1
  28. data/lib/generators/active_fedora/config/fedora/fedora_generator.rb +1 -0
  29. data/lib/generators/active_fedora/config/fedora/templates/.fcrepo_wrapper +1 -0
  30. data/lib/generators/active_fedora/config/fedora/templates/fcrepo_wrapper_test.yml +4 -0
  31. data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -0
  32. data/lib/generators/active_fedora/config/solr/templates/.solr_wrapper +3 -0
  33. data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +8 -0
  34. data/spec/integration/attached_files_spec.rb +77 -18
  35. data/spec/integration/attributes_spec.rb +3 -4
  36. data/spec/integration/autosave_association_spec.rb +0 -1
  37. data/spec/integration/base_spec.rb +19 -66
  38. data/spec/integration/basic_contains_association_spec.rb +108 -0
  39. data/spec/integration/complex_rdf_datastream_spec.rb +1 -1
  40. data/spec/integration/field_to_solr_name_spec.rb +12 -11
  41. data/spec/integration/file_fixity_spec.rb +1 -1
  42. data/spec/integration/file_spec.rb +4 -1
  43. data/spec/integration/generators/fedora_generator_spec.rb +26 -0
  44. data/spec/integration/generators/solr_generator_spec.rb +26 -0
  45. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +6 -16
  46. data/spec/integration/has_many_associations_spec.rb +6 -16
  47. data/spec/integration/{contains_association_spec.rb → has_subresource_spec.rb} +1 -1
  48. data/spec/integration/json_serialization_spec.rb +11 -5
  49. data/spec/integration/model_spec.rb +7 -13
  50. data/spec/integration/ntriples_datastream_spec.rb +2 -2
  51. data/spec/integration/om_datastream_spec.rb +1 -1
  52. data/spec/integration/persistence_spec.rb +0 -3
  53. data/spec/integration/query_result_builder_spec.rb +1 -1
  54. data/spec/integration/relation_delegation_spec.rb +3 -8
  55. data/spec/integration/scoped_query_spec.rb +5 -7
  56. data/spec/integration/solr_hit_spec.rb +10 -4
  57. data/spec/integration/solr_instance_loader_spec.rb +11 -4
  58. data/spec/integration/versionable_spec.rb +3 -3
  59. data/spec/spec_helper.rb +5 -1
  60. data/spec/unit/active_fedora_spec.rb +1 -1
  61. data/spec/unit/attached_files_spec.rb +32 -21
  62. data/spec/unit/attributes_spec.rb +21 -23
  63. data/spec/unit/base_active_model_spec.rb +13 -10
  64. data/spec/unit/base_spec.rb +2 -24
  65. data/spec/unit/callback_spec.rb +0 -8
  66. data/spec/unit/core_spec.rb +3 -5
  67. data/spec/unit/inheritance_spec.rb +15 -9
  68. data/spec/unit/ntriples_datastream_spec.rb +1 -1
  69. data/spec/unit/om_datastream_spec.rb +1 -1
  70. data/spec/unit/persistence_spec.rb +21 -0
  71. data/spec/unit/query_spec.rb +8 -0
  72. data/spec/unit/rdf_datastream_spec.rb +1 -1
  73. data/spec/unit/rdf_resource_datastream_spec.rb +1 -1
  74. data/spec/unit/simple_datastream_spec.rb +8 -2
  75. data/spec/unit/solr_config_options_spec.rb +1 -1
  76. data/spec/unit/validations_spec.rb +2 -8
  77. metadata +27 -6
  78. data/spec/integration/bug_spec.rb +0 -40
  79. data/spec/integration/full_featured_model_spec.rb +0 -160
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02fb3ee9bf393052113ffdd4082e741bc155266c
4
- data.tar.gz: 674c9e4a7a00220c1bb2011414dfdaf841b76100
3
+ metadata.gz: de64ddd51b632d51f1f4dc511ff09f362ef0f780
4
+ data.tar.gz: d92cd808d81b5f883bfe354ec500ddb0b876cf45
5
5
  SHA512:
6
- metadata.gz: 8e8c4e554a899aa3109de27b30dfb1a64b0c3954cf2ad4c2e7c255413ed27bf8242ed8bd951f8364c18a92d49f346f800ffed9e52abc7af507143eff1e5631e2
7
- data.tar.gz: e5d93de8c674af3aa2f27dc18a52c06bf35afd3a0e9ab0b4ad01522664015e86e8e83faa4938ec5dda2ee16df5f76bec22229f9c3c8557e6f89fcf7f41b87a58
6
+ metadata.gz: 74614aefd969cdbc977b7c793a8c2f09f434200ae28407d75af925112fcd85b3da3f14fc112fa3d704573762909c25d03111c509b172452574183ccc3836b749
7
+ data.tar.gz: 60a60f1c17d835d44423bb1a4fa24bcec477ff9854bfb0b33791220de4edfd2b273942a9fbce8b486aa6ba4f5fec397efc87b38687ff8e6058a46778f2938788
@@ -12,7 +12,7 @@ Lint/HandleExceptions:
12
12
  - 'spec/unit/**/*'
13
13
  - 'spec/integration/**/*'
14
14
  - 'lib/active_fedora/cleaner.rb'
15
- - 'lib/active_fedora/associations/builder/contains.rb'
15
+ - 'lib/active_fedora/associations/builder/has_subresource.rb'
16
16
 
17
17
  Lint/AssignmentInCondition:
18
18
  Enabled: false
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency "deprecation"
27
27
  s.add_dependency "ldp", '~> 0.5.0'
28
28
 
29
+ s.add_development_dependency "rails"
29
30
  s.add_development_dependency "rdoc"
30
31
  s.add_development_dependency "yard"
31
32
  # Pin rake to 10.0 due to https://github.com/lsegal/yard/issues/947
@@ -86,6 +86,7 @@ module ActiveFedora #:nodoc:
86
86
  autoload :InheritableAccessors
87
87
  autoload :Inheritance
88
88
  autoload :InboundRelationConnection
89
+ autoload :InitializingConnection
89
90
  autoload :LdpCache
90
91
  autoload :LdpResource
91
92
  autoload :LdpResourceService
@@ -25,6 +25,7 @@ module ActiveFedora
25
25
  autoload :BelongsToAssociation
26
26
  autoload :HasAndBelongsToManyAssociation
27
27
  autoload :BasicContainsAssociation
28
+ autoload :HasSubresourceAssociation
28
29
  autoload :DirectlyContainsAssociation
29
30
  autoload :DirectlyContainsOneAssociation
30
31
  autoload :IndirectlyContainsAssociation
@@ -45,7 +46,8 @@ module ActiveFedora
45
46
  autoload :BelongsTo, 'active_fedora/associations/builder/belongs_to'
46
47
  autoload :HasMany, 'active_fedora/associations/builder/has_many'
47
48
  autoload :HasAndBelongsToMany, 'active_fedora/associations/builder/has_and_belongs_to_many'
48
- autoload :Contains, 'active_fedora/associations/builder/contains'
49
+ autoload :BasicContains, 'active_fedora/associations/builder/basic_contains'
50
+ autoload :HasSubresource, 'active_fedora/associations/builder/has_subresource'
49
51
  autoload :DirectlyContains, 'active_fedora/associations/builder/directly_contains'
50
52
  autoload :DirectlyContainsOne, 'active_fedora/associations/builder/directly_contains_one'
51
53
  autoload :IndirectlyContains, 'active_fedora/associations/builder/indirectly_contains'
@@ -104,6 +106,23 @@ module ActiveFedora
104
106
  end
105
107
 
106
108
  module ClassMethods
109
+ # This method is used to declare this resource acts like an LDP BasicContainer
110
+ #
111
+ # @param [Hash] options
112
+ # @option options [String] :class_name ('ActiveFedora::File') The name of the
113
+ # class that will represent the contained resources
114
+ #
115
+ # example:
116
+ # class FooHistory < ActiveFedora::Base
117
+ # is_a_container class_name: 'Thing'
118
+ # end
119
+ #
120
+ def is_a_container(options = {})
121
+ defaults = { class_name: 'ActiveFedora::File',
122
+ predicate: ::RDF::Vocab::LDP.contains }
123
+ Builder::BasicContains.build(self, :contains, defaults.merge(options))
124
+ end
125
+
107
126
  # This method is used to declare an ldp:DirectContainer on a resource
108
127
  # you must specify an is_member_of_relation or a has_member_relation
109
128
  #
@@ -176,9 +195,25 @@ module ActiveFedora
176
195
  # @option options [Boolean] :autocreate Always create this resource on new objects
177
196
  # @yield block executed by some types of child resources
178
197
  def contains(name, options = {}, &block)
198
+ Deprecation.warn(Associations, "contains is deprecated. Use has_subresource instead. This will be removed in ActiveFedora 10")
199
+ has_subresource(name, options, &block)
200
+ end
201
+
202
+ # This method is used to specify the details of a contained resource.
203
+ # Pass the name as the first argument and a hash of options as the second argument
204
+ # Note that this method doesn't actually execute the block, but stores it, to be executed
205
+ # by any the implementation of the resource(specified as :class_name)
206
+ #
207
+ # @param [String] name the handle to refer to this child as
208
+ # @param [Hash] options
209
+ # @option options [Class] :class_name The class that will represent this child, should extend ``ActiveFedora::File'' or ``ActiveFedora::Base''
210
+ # @option options [String] :url
211
+ # @option options [Boolean] :autocreate Always create this resource on new objects
212
+ # @yield block executed by some types of child resources
213
+ def has_subresource(name, options = {}, &block)
179
214
  options[:block] = block if block
180
- raise ArgumentError, "You must provide a name (dsid) for the datastream" unless name
181
- Associations::Builder::Contains.build(self, name.to_sym, options)
215
+ raise ArgumentError, "You must provide a path name (f.k.a. dsid) for the resource" unless name
216
+ Associations::Builder::HasSubresource.build(self, name.to_sym, options)
182
217
  end
183
218
 
184
219
  # Specifies a one-to-one association with another class. This method should only be used
@@ -1,61 +1,22 @@
1
1
  module ActiveFedora
2
2
  module Associations
3
- class BasicContainsAssociation < SingularAssociation #:nodoc:
4
- # Implements the reader method, e.g. foo.bar for Foo.has_one :bar
5
- def reader(force_reload = false)
6
- super || build
7
- end
8
-
3
+ class BasicContainsAssociation < ContainsAssociation #:nodoc:
9
4
  def find_target
10
- find_or_initialize_target do |record|
11
- configure_datastream(record) if reflection.options[:block]
12
- end
13
- end
5
+ uris = owner.resource.query(predicate: options[:predicate])
6
+ .map { |r| r.object.to_s }
14
7
 
15
- def target_uri
16
- "#{owner.id}/#{reflection.name}"
8
+ uris.map { |object_uri| klass.find(klass.uri_to_id(object_uri)) }
17
9
  end
18
10
 
19
- private
20
-
21
- def raise_on_type_mismatch!(record)
22
- return if record.is_a? LoadableFromJson::SolrBackedMetadataFile
23
- super
24
- end
25
-
26
- def find_or_initialize_target(&block)
27
- if reflection.klass < ActiveFedora::File
28
- reflection.build_association(target_uri, &block)
29
- else
30
- reflection.klass.find(target_uri)
31
- end
32
- rescue ActiveFedora::ObjectNotFoundError
33
- reflection.build_association(target_uri, &block)
34
- end
35
-
36
- def replace(record)
37
- if record
38
- raise_on_type_mismatch!(record)
39
- @updated = true
40
- end
41
-
42
- self.target = record
43
- end
44
-
45
- def new_record(method, attributes)
46
- record = super
47
- configure_datastream(record)
48
- record
49
- end
11
+ def insert_record(record, force = true, validate = true)
12
+ record.base_path_for_resource = owner.uri.to_s
13
+ super
14
+ end
50
15
 
51
- def configure_datastream(record)
52
- # If you called has_metadata with a block, pass the block into the File class
53
- if reflection.options[:block].class == Proc
54
- reflection.options[:block].call(record)
55
- end
56
- return unless record.new_record? && reflection.options[:autocreate]
57
- record.datastream_will_change!
58
- end
16
+ def add_to_target(record, skip_callbacks = false)
17
+ record.base_path_for_resource = owner.uri.to_s
18
+ super
19
+ end
59
20
  end
60
21
  end
61
22
  end
@@ -6,7 +6,7 @@ module ActiveFedora::Associations::Builder
6
6
 
7
7
  def self.build(model, name, options)
8
8
  model.indirectly_contains name, { has_member_relation: has_member_relation(options), through: proxy_class, foreign_key: proxy_foreign_key, inserted_content_relation: inserted_content_relation }.merge(indirect_options(options))
9
- model.contains contains_key(options), class_name: list_source_class
9
+ model.has_subresource contains_key(options), class_name: list_source_class
10
10
  model.orders name, through: contains_key(options)
11
11
  end
12
12
 
@@ -0,0 +1,7 @@
1
+ module ActiveFedora::Associations::Builder
2
+ class BasicContains < CollectionAssociation #:nodoc:
3
+ def self.macro
4
+ :is_a_container
5
+ end
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
1
  module ActiveFedora::Associations::Builder
2
- class Contains < SingularAssociation #:nodoc:
2
+ class HasSubresource < SingularAssociation #:nodoc:
3
3
  def self.macro
4
- :contains
4
+ :has_subresource
5
5
  end
6
6
 
7
7
  def self.valid_options(options)
@@ -1,7 +1,15 @@
1
- # This is the parent class of DirectlyContainsAssociation and IndirectlyContainsAssociation
1
+ # This is the parent class of BasicContainsAssociation, DirectlyContainsAssociation and IndirectlyContainsAssociation
2
2
  module ActiveFedora
3
3
  module Associations
4
4
  class ContainsAssociation < CollectionAssociation #:nodoc:
5
+ def insert_record(record, force = true, validate = true)
6
+ if force
7
+ record.save!
8
+ else
9
+ record.save(validate: validate)
10
+ end
11
+ end
12
+
5
13
  def reader
6
14
  @records ||= ContainerProxy.new(self)
7
15
  end
@@ -27,6 +35,16 @@ module ActiveFedora
27
35
  raise "Can't get uri. Owner isn't saved" if @owner.new_record?
28
36
  "#{@owner.uri}/#{@reflection.name}"
29
37
  end
38
+
39
+ private
40
+
41
+ def delete_records(records, method)
42
+ if method == :destroy
43
+ records.each(&:destroy)
44
+ else
45
+ records.each(&:delete)
46
+ end
47
+ end
30
48
  end
31
49
  end
32
50
  end
@@ -3,11 +3,7 @@ module ActiveFedora
3
3
  class DirectlyContainsAssociation < ContainsAssociation #:nodoc:
4
4
  def insert_record(record, force = true, validate = true)
5
5
  container.save!
6
- if force
7
- record.save!
8
- else
9
- record.save(validate: validate)
10
- end
6
+ super
11
7
  end
12
8
 
13
9
  def find_target
@@ -39,16 +35,6 @@ module ActiveFedora
39
35
  record.uri = ActiveFedora::Base.id_to_uri(container.mint_id)
40
36
  set_inverse_instance(record)
41
37
  end
42
-
43
- private
44
-
45
- def delete_records(records, method)
46
- if method == :destroy
47
- records.each(&:destroy)
48
- else
49
- records.each(&:delete)
50
- end
51
- end
52
38
  end
53
39
  end
54
40
  end
@@ -0,0 +1,61 @@
1
+ module ActiveFedora
2
+ module Associations
3
+ class HasSubresourceAssociation < SingularAssociation #:nodoc:
4
+ # Implements the reader method, e.g. foo.bar for Foo.has_one :bar
5
+ def reader(force_reload = false)
6
+ super || build
7
+ end
8
+
9
+ def find_target
10
+ find_or_initialize_target do |record|
11
+ configure_datastream(record) if reflection.options[:block]
12
+ end
13
+ end
14
+
15
+ def target_uri
16
+ "#{owner.id}/#{reflection.name}"
17
+ end
18
+
19
+ private
20
+
21
+ def raise_on_type_mismatch!(record)
22
+ return if record.is_a? LoadableFromJson::SolrBackedMetadataFile
23
+ super
24
+ end
25
+
26
+ def find_or_initialize_target(&block)
27
+ if reflection.klass < ActiveFedora::File
28
+ reflection.build_association(target_uri, &block)
29
+ else
30
+ reflection.klass.find(target_uri)
31
+ end
32
+ rescue ActiveFedora::ObjectNotFoundError
33
+ reflection.build_association(target_uri, &block)
34
+ end
35
+
36
+ def replace(record)
37
+ if record
38
+ raise_on_type_mismatch!(record)
39
+ @updated = true
40
+ end
41
+
42
+ self.target = record
43
+ end
44
+
45
+ def new_record(method, attributes)
46
+ record = super
47
+ configure_datastream(record)
48
+ record
49
+ end
50
+
51
+ def configure_datastream(record)
52
+ # If you called has_metadata with a block, pass the block into the File class
53
+ if reflection.options[:block].class == Proc
54
+ reflection.options[:block].call(record)
55
+ end
56
+ return unless record.new_record? && reflection.options[:autocreate]
57
+ record.datastream_will_change!
58
+ end
59
+ end
60
+ end
61
+ end
@@ -132,7 +132,7 @@ module ActiveFedora
132
132
  def create_singleton_association(file_path)
133
133
  undeclared_files << file_path.to_sym
134
134
 
135
- association = Associations::BasicContainsAssociation.new(self, Reflection::ContainsReflection.new(file_path, nil, { class_name: 'ActiveFedora::File' }, self.class))
135
+ association = Associations::HasSubresourceAssociation.new(self, Reflection::HasSubresourceReflection.new(file_path, nil, { class_name: 'ActiveFedora::File' }, self.class))
136
136
  @association_cache[file_path.to_sym] = association
137
137
 
138
138
  singleton_class.send :define_method, accessor_name(file_path) do
@@ -156,13 +156,10 @@ module ActiveFedora
156
156
  end
157
157
 
158
158
  module ClassMethods
159
- extend Deprecation
160
- self.deprecation_horizon = 'active-fedora version 10.0'
161
-
162
159
  def ds_specs
160
+ Deprecation.warn(self, "ds_specs is deprecated and will be removed in ActiveFedora 10.0")
163
161
  child_resource_reflections
164
162
  end
165
- deprecation_deprecate :ds_specs
166
163
 
167
164
  # This method is used to specify the details of a datastream.
168
165
  # You can pass the name as the first argument and a hash of options as the second argument
@@ -177,6 +174,7 @@ module ActiveFedora
177
174
  # @option args [Boolean] :autocreate Always create this datastream on new objects
178
175
  # @yield block executed by some kinds of datastreams
179
176
  def has_metadata(*args, &block)
177
+ Deprecation.warn(self, "has_metadata is deprecated and will be removed in ActiveFedora 10.0. Use has_subresource instead.")
180
178
  if args.first.is_a? String
181
179
  name = args.first
182
180
  args = args[1] || {}
@@ -187,9 +185,8 @@ module ActiveFedora
187
185
  name = args.delete(:name)
188
186
  raise ArgumentError, "You must provide a :type property for the datastream '#{name}'" unless args[:type]
189
187
  args[:class_name] = args.delete(:type).to_s
190
- contains(name, args, &block)
188
+ has_subresource(name, args, &block)
191
189
  end
192
- deprecation_deprecate :has_metadata
193
190
 
194
191
  # @overload has_file_datastream(name, args)
195
192
  # Declares a file datastream exists for objects of this type
@@ -204,6 +201,7 @@ module ActiveFedora
204
201
  # @option args :type (ActiveFedora::File) The class the datastream should have
205
202
  # @option args [Boolean] :autocreate Always create this datastream on new objects
206
203
  def has_file_datastream(*args)
204
+ Deprecation.warn(self, "has_file_datastream is deprecated and will be removed in ActiveFedora 10.0. Use has_subresource instead.")
207
205
  if args.first.is_a? String
208
206
  name = args.first
209
207
  args = args[1] || {}
@@ -213,9 +211,8 @@ module ActiveFedora
213
211
  end
214
212
  name = args.delete(:name)
215
213
  args[:class_name] = args.delete(:type).to_s
216
- contains(name, args)
214
+ has_subresource(name, args)
217
215
  end
218
- deprecation_deprecate :has_file_datastream
219
216
  end
220
217
  end
221
218
  end
@@ -75,7 +75,7 @@ module ActiveFedora
75
75
  module AutosaveAssociation
76
76
  extend ActiveSupport::Concern
77
77
 
78
- ASSOCIATION_TYPES = [:has_many, :belongs_to, :has_and_belongs_to_many, :directly_contains, :indirectly_contains].freeze
78
+ ASSOCIATION_TYPES = [:has_many, :belongs_to, :has_and_belongs_to_many, :directly_contains, :indirectly_contains, :is_a_container].freeze
79
79
 
80
80
  module AssociationBuilderExtension #:nodoc:
81
81
  def self.valid_options
@@ -50,7 +50,6 @@ module ActiveFedora
50
50
  include Versionable
51
51
  include LoadableFromJson
52
52
  include Schema
53
- include Pathing
54
53
  include Aggregation::BaseExtension
55
54
  end
56
55
 
@@ -1,6 +1,7 @@
1
1
  module ActiveFedora
2
2
  module Common
3
3
  extend ActiveSupport::Concern
4
+ include Pathing
4
5
 
5
6
  module ClassMethods
6
7
  def initialize_generated_modules # :nodoc:
@@ -18,6 +18,8 @@ module ActiveFedora
18
18
 
19
19
  def initialize(config)
20
20
  @config = config
21
+
22
+ validate_options
21
23
  end
22
24
 
23
25
  def host
@@ -42,7 +44,6 @@ module ActiveFedora
42
44
 
43
45
  def connection
44
46
  @connection ||= begin
45
- init_base_path
46
47
  build_connection
47
48
  end
48
49
  end
@@ -51,6 +52,10 @@ module ActiveFedora
51
52
  @clean_connection ||= CleanConnection.new(connection)
52
53
  end
53
54
 
55
+ def caching_connection(options = {})
56
+ CachingConnection.new(authorized_connection, options)
57
+ end
58
+
54
59
  def ldp_resource_service
55
60
  @service ||= LdpResourceService.new(connection)
56
61
  end
@@ -58,22 +63,6 @@ module ActiveFedora
58
63
  SLASH = '/'.freeze
59
64
  BLANK = ''.freeze
60
65
 
61
- # Call this to create a Container Resource to act as the base path for this connection
62
- def init_base_path
63
- return if @initialized
64
- connection = build_connection
65
-
66
- connection.head(root_resource_path)
67
- ActiveFedora::Base.logger.info "Attempted to init base path `#{root_resource_path}`, but it already exists" if ActiveFedora::Base.logger
68
- @initialized = true
69
- false
70
- rescue Ldp::NotFound
71
- unless host.downcase.end_with?("/rest")
72
- ActiveFedora::Base.logger.warn "Fedora URL (#{host}) does not end with /rest. This could be a problem. Check your fedora.yml config"
73
- end
74
- @initialized = connection.put(root_resource_path, BLANK).success?
75
- end
76
-
77
66
  # Remove a leading slash from the base_path
78
67
  def root_resource_path
79
68
  @root_resource_path ||= base_path.sub(SLASH, BLANK)
@@ -83,8 +72,8 @@ module ActiveFedora
83
72
  # The InboundRelationConnection does provide more data, useful for
84
73
  # things like ldp:IndirectContainers, but it's imposes a significant
85
74
  # performance penalty on every request
86
- # @connection ||= InboundRelationConnection.new(CachingConnection.new(authorized_connection))
87
- CachingConnection.new(authorized_connection, omit_ldpr_interaction_model: true)
75
+ # @connection ||= InboundRelationConnection.new(caching_connection(omit_ldpr_interaction_model: true))
76
+ InitializingConnection.new(caching_connection(omit_ldpr_interaction_model: true), root_resource_path)
88
77
  end
89
78
 
90
79
  def authorized_connection
@@ -94,5 +83,11 @@ module ActiveFedora
94
83
  connection.basic_auth(user, password)
95
84
  connection
96
85
  end
86
+
87
+ def validate_options
88
+ unless host.downcase.end_with?("/rest")
89
+ ActiveFedora::Base.logger.warn "Fedora URL (#{host}) does not end with /rest. This could be a problem. Check your fedora.yml config"
90
+ end
91
+ end
97
92
  end
98
93
  end