active-fedora 7.0.4 → 7.1.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/History.txt +51 -1
  4. data/active-fedora.gemspec +19 -19
  5. data/lib/active_fedora.rb +1 -6
  6. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +1 -1
  7. data/lib/active_fedora/associations/collection_association.rb +1 -1
  8. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +1 -1
  9. data/lib/active_fedora/attributes.rb +8 -0
  10. data/lib/active_fedora/base.rb +1 -1
  11. data/lib/active_fedora/callbacks.rb +1 -1
  12. data/lib/active_fedora/core.rb +13 -5
  13. data/lib/active_fedora/datastream_attribute.rb +1 -1
  14. data/lib/active_fedora/datastream_hash.rb +12 -6
  15. data/lib/active_fedora/fedora_attributes.rb +1 -1
  16. data/lib/active_fedora/file_configurator.rb +3 -3
  17. data/lib/active_fedora/fixture_loader.rb +2 -2
  18. data/lib/active_fedora/model.rb +2 -2
  19. data/lib/active_fedora/om_datastream.rb +2 -2
  20. data/lib/active_fedora/persistence.rb +22 -18
  21. data/lib/active_fedora/railtie.rb +5 -1
  22. data/lib/active_fedora/rdf.rb +11 -9
  23. data/lib/active_fedora/rdf/indexing.rb +1 -1
  24. data/lib/active_fedora/rdf/object_resource.rb +1 -1
  25. data/lib/active_fedora/rdf/rdf_datastream.rb +3 -3
  26. data/lib/active_fedora/relation/finder_methods.rb +16 -10
  27. data/lib/active_fedora/solr_instance_loader.rb +1 -1
  28. data/lib/active_fedora/solr_service.rb +1 -3
  29. data/lib/active_fedora/version.rb +1 -1
  30. data/spec/integration/attributes_spec.rb +4 -4
  31. data/spec/integration/base_spec.rb +32 -13
  32. data/spec/integration/complex_rdf_datastream_spec.rb +4 -4
  33. data/spec/integration/delete_all_spec.rb +1 -1
  34. data/spec/integration/load_from_solr_spec.rb +1 -1
  35. data/spec/integration/rdf_nested_attributes_spec.rb +4 -4
  36. data/spec/integration/scoped_query_spec.rb +6 -6
  37. data/spec/spec_helper.rb +5 -3
  38. data/spec/unit/attributes_spec.rb +19 -1
  39. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +9 -0
  40. data/spec/unit/datastreams_spec.rb +4 -0
  41. data/spec/unit/file_configurator_spec.rb +5 -5
  42. data/spec/unit/logger_spec.rb +20 -0
  43. data/spec/unit/om_datastream_spec.rb +1 -1
  44. data/spec/unit/persistence_spec.rb +50 -0
  45. data/spec/unit/query_spec.rb +15 -5
  46. data/spec/unit/rdf_resource_datastream_spec.rb +3 -3
  47. data/spec/unit/rdfxml_rdf_datastream_spec.rb +1 -1
  48. data/spec/unit/solr_config_options_spec.rb +1 -1
  49. data/spec/unit/solr_service_spec.rb +1 -1
  50. metadata +33 -168
  51. data/lib/active_fedora/rdf/configurable.rb +0 -59
  52. data/lib/active_fedora/rdf/list.rb +0 -155
  53. data/lib/active_fedora/rdf/nested_attributes.rb +0 -130
  54. data/lib/active_fedora/rdf/node_config.rb +0 -57
  55. data/lib/active_fedora/rdf/properties.rb +0 -94
  56. data/lib/active_fedora/rdf/repositories.rb +0 -36
  57. data/lib/active_fedora/rdf/resource.rb +0 -328
  58. data/lib/active_fedora/rdf/term.rb +0 -188
  59. data/spec/unit/rdf_configurable_spec.rb +0 -37
  60. data/spec/unit/rdf_list_nested_attributes_spec.rb +0 -99
  61. data/spec/unit/rdf_list_spec.rb +0 -180
  62. data/spec/unit/rdf_properties_spec.rb +0 -81
  63. data/spec/unit/rdf_repositories_spec.rb +0 -28
  64. data/spec/unit/rdf_resource_spec.rb +0 -345
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e75a0408125225a3ef0ae91e7de53d0560d10a6
4
- data.tar.gz: 56de97df291d2239583e16c500f99ab26df355af
3
+ metadata.gz: 481726bbeb31ad09149dbe0facfcc577a504f0da
4
+ data.tar.gz: 66f87369d95a41cb5c0d5fd02dccd43f89e589f7
5
5
  SHA512:
6
- metadata.gz: 3df7b3a6fd7aab417e3c10d589e0fc06bba37cbee05400ea9d4983314cdaf191239b54ed9202a38f75ce1d1e5dbf1b03ec74b60a0ded41856ac3f68c140fdf31
7
- data.tar.gz: d43e9f106e4b6f2c59eb12e36fe62c03d0e1b0040f60af2d373247aa25143499c1ce163ae39b75b3de353301a10abcc6535a01ad9e26c2085c0726dff4bd4c9e
6
+ metadata.gz: 82de3808e266997ca4e95144e6792877398deabddceb9cc7306ea0f7badecfe5d79a666915cb688a4fa2b5fcabc1997436b31593c39e52f7e6a204d3b48aaa77
7
+ data.tar.gz: f038a141b3d4136c9d5313e63137412a912f5a78632c0ca27efe235757e030e117f7d3b58d97c9544bfddb3a8e12b0b2b666a03145b1283957e8be9fffc6ae32
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -1,4 +1,54 @@
1
- v7.0.0 Unreleased
1
+ v7.1.0
2
+
3
+ 2014-07-17: Update Om and Rubydora depencencies [Justin Coyne]
4
+
5
+ 2014-07-17: Change the deprecation message so that it helps you find where the
6
+ problem is [Justin Coyne]
7
+
8
+ 2014-06-30: Refactoring ActiveFedora::Rdf to use ActiveTriples [Tom Johnson]
9
+
10
+ 2014-07-16: Make logger an accessor that can be set [Justin Coyne]
11
+
12
+ 2014-07-16: Remove mediashelf-loggable [Justin Coyne]
13
+
14
+ 2014-06-24: Replace ActiveFedora::Core#init_with with #init_with_object to avoid
15
+ a respond_to? false positive in Psych [Michael B. Klein]
16
+
17
+ 2014-06-24: Have DatastreamHash delegate to a Hash instead of descending from
18
+ one [Michael B. Klein]
19
+
20
+ 2014-06-24: Add solr_page_size as a valid option for HABTM [Justin Coyne]
21
+
22
+ 2014-06-23: Refactor for style/readability [Justin Coyne]
23
+
24
+ 2014-06-18: Adds :update_index option to `save' -- passing a false value will
25
+ prevent `update_index' from being called after the object is persisted. The
26
+ `create_needs_index?' and `update_needs_index?' methods, however, will not be
27
+ overridden when they return false. [David Chandek-Stark]
28
+
29
+ 2014-06-18: Fixed bug in ActiveFedora::FinderMethods#load_from_fedora so that it
30
+ casts when klass is ActiveFedora::Base and `cast' argument is nil, as intended.
31
+ Fixes #431 since by default it calls load_from_fedora(pid, nil) on each hit.
32
+ [David Chandek-Stark]
33
+
34
+ 2014-06-13: Created pid instance variable so value can be retained after destroy
35
+ Fixes #422 [David Chandek-Stark]
36
+
37
+ 2014-06-10: Added support to `exists?' finder method for a hash of conditions
38
+ Fixes #427 [David Chandek-Stark]
39
+
40
+ 2014-06-10: Deprecate setting multiple attribute to scalar value Deprecate
41
+ setting unique attribute to enumerable value [David Chandek-Stark]
42
+
43
+ 2014-06-10: Remove useage of RDF.Class from test code. That's not a real URI
44
+ [Justin Coyne]
45
+
46
+ 2014-06-10: Peg rspec to ~> 2.99 [Justin Coyne]
47
+
48
+ 2014-06-10: Put rspec options in a .rspec file for rspec 3 [Justin Coyne]
49
+
50
+
51
+ v7.0.0
2
52
 
3
53
  Removed update_indexed_attributes, update_datastream_attributes, get_values_from_datastream
4
54
 
@@ -14,27 +14,27 @@ Gem::Specification.new do |s|
14
14
  s.license = "APACHE2"
15
15
  s.required_ruby_version = '>= 1.9.3'
16
16
 
17
- s.add_dependency('rsolr', "~> 1.0.10.pre1")
18
- s.add_dependency('om', '~> 3.0.0')
19
- s.add_dependency('nom-xml', '>=0.5.1')
20
- s.add_dependency("activesupport", '>= 3.0.0')
21
- s.add_dependency("mediashelf-loggable")
22
- s.add_dependency("rubydora", '~>1.7.4')
23
- s.add_dependency("linkeddata")
24
- s.add_dependency("rdf-rdfxml", '~>1.1.0')
25
- s.add_dependency("deprecation")
26
- s.add_development_dependency("rdoc")
27
- s.add_development_dependency("yard")
28
- s.add_development_dependency("rake")
29
- s.add_development_dependency("jettywrapper", ">=1.4.0")
30
- s.add_development_dependency("rspec", ">= 2.9.0")
31
- s.add_development_dependency("equivalent-xml")
32
- s.add_development_dependency("rest-client")
33
- s.add_development_dependency("webmock")
34
- s.add_development_dependency("simplecov", '~> 0.7.1')
17
+ s.add_dependency 'rsolr', "~> 1.0.10"
18
+ s.add_dependency 'om', '~> 3.1'
19
+ s.add_dependency 'nom-xml', '>= 0.5.1'
20
+ s.add_dependency "activesupport", '>= 3.0.0'
21
+ s.add_dependency "rubydora", '~> 1.8'
22
+ s.add_dependency "active-triples", '~> 0.2.2'
23
+ s.add_dependency "rdf-rdfxml", '~> 1.1.0'
24
+ s.add_dependency "deprecation"
25
+ s.add_development_dependency "rdoc"
26
+ s.add_development_dependency "yard"
27
+ s.add_development_dependency "rake"
28
+ s.add_development_dependency "jettywrapper", ">=1.4.0"
29
+ s.add_development_dependency "rspec", "~> 2.99"
30
+ s.add_development_dependency "rspec-its"
31
+ s.add_development_dependency "equivalent-xml"
32
+ s.add_development_dependency "rest-client"
33
+ s.add_development_dependency "webmock"
34
+ s.add_development_dependency "simplecov", '~> 0.7.1'
35
35
 
36
36
  s.files = `git ls-files`.split("\n")
37
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
37
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
38
38
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
39
39
  s.extra_rdoc_files = [
40
40
  "LICENSE",
@@ -1,4 +1,3 @@
1
- require "loggable"
2
1
  require 'active_support'
3
2
  require "solrizer"
4
3
  require 'active_fedora/file_configurator'
@@ -7,7 +6,7 @@ require 'active_support/core_ext/class/attribute'
7
6
  require 'active_support/core_ext/object'
8
7
  require 'active_support/core_ext/hash/indifferent_access'
9
8
  require "active_support/core_ext/hash/except"
10
- require 'rdf'
9
+ require 'active_triples'
11
10
 
12
11
  SOLR_DOCUMENT_ID = Solrizer.default_field_mapper.id_field unless defined?(SOLR_DOCUMENT_ID)
13
12
  ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
@@ -100,10 +99,6 @@ module ActiveFedora #:nodoc:
100
99
  end
101
100
  end
102
101
 
103
-
104
-
105
- include Loggable
106
-
107
102
  class << self
108
103
  attr_reader :fedora_config, :solr_config, :config_options
109
104
  attr_accessor :configurator
@@ -2,7 +2,7 @@ module ActiveFedora::Associations::Builder
2
2
  class HasAndBelongsToMany < CollectionAssociation #:nodoc:
3
3
  self.macro = :has_and_belongs_to_many
4
4
 
5
- self.valid_options += [:inverse_of]
5
+ self.valid_options += [:inverse_of, :solr_page_size]
6
6
 
7
7
  def build
8
8
  reflection = super
@@ -246,7 +246,7 @@ module ActiveFedora
246
246
  begin
247
247
  targets = find_target
248
248
  rescue ObjectNotFoundError => e
249
- ActiveFedora::Base.logger.error "Solr and Fedora may be out of sync:\n" + e.message
249
+ ActiveFedora::Base.logger.error "Solr and Fedora may be out of sync:\n" + e.message if ActiveFedora::Base.logger
250
250
  reset
251
251
  end
252
252
 
@@ -19,7 +19,7 @@ module ActiveFedora
19
19
  @owner.add_relationship(@reflection.options[:property], record)
20
20
 
21
21
  if @owner.new_record? and @reflection.options[:inverse_of]
22
- logger.warn("has_and_belongs_to_many #{@reflection.inspect} is cowardly refusing to insert the inverse relationship into #{record}, because #{@owner} is not persisted yet.")
22
+ ActiveFedora::Base.logger.warn("has_and_belongs_to_many #{@reflection.inspect} is cowardly refusing to insert the inverse relationship into #{record}, because #{@owner} is not persisted yet.") if ActiveFedora::Base.logger
23
23
  elsif @reflection.options[:inverse_of]
24
24
  record.add_relationship(@reflection.options[:inverse_of], @owner)
25
25
  record.save
@@ -3,6 +3,7 @@ module ActiveFedora
3
3
  extend ActiveSupport::Concern
4
4
  extend ActiveSupport::Autoload
5
5
  include ActiveModel::Dirty
6
+ extend Deprecation
6
7
 
7
8
  autoload :Serializers
8
9
 
@@ -138,6 +139,13 @@ module ActiveFedora
138
139
  def create_attribute_setter(field, dsid, args)
139
140
  find_or_create_defined_attribute(field, dsid, args)
140
141
  define_method "#{field}=".to_sym do |v|
142
+ if self.class.multiple?(field)
143
+ unless v.nil? || v.respond_to?(:each)
144
+ Deprecation.warn(ActiveFedora::Attributes, "You attempted to set the attribute `#{field}' on `#{self.class}' to a scalar value. However, this attribute is declared as being multivalued. This behavior is deprecated and will raise an ArgumentError in active-fedora 8.0.0")
145
+ end
146
+ elsif v.respond_to?(:each) # unique
147
+ Deprecation.warn(ActiveFedora::Attributes, "You attempted to set the attribute `#{field}' on `#{self.class}' to an enumerable value. However, this attribute is declared as being singular. This behavior is deprecated and will raise an ArgumentError in active-fedora 8.0.0")
148
+ end
141
149
  self[field]=v
142
150
  end
143
151
  end
@@ -30,7 +30,6 @@ module ActiveFedora
30
30
  include Sharding
31
31
  include ActiveFedora::Persistence
32
32
  include Scoping
33
- include Loggable
34
33
  include Indexing
35
34
  include ActiveModel::Conversion
36
35
  include Validations
@@ -49,4 +48,5 @@ module ActiveFedora
49
48
  include Rdf::Identifiable
50
49
  end
51
50
 
51
+ ActiveSupport.run_load_hooks(:active_fedora, Base)
52
52
  end
@@ -236,7 +236,7 @@ module ActiveFedora
236
236
  run_callbacks(:save) { super }
237
237
  end
238
238
 
239
- def create #:nodoc:
239
+ def create(*) #:nodoc:
240
240
  run_callbacks(:create) { super }
241
241
  end
242
242
 
@@ -3,6 +3,14 @@ module ActiveFedora
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  attr_reader :inner_object
6
+ included do
7
+ ##
8
+ # :singleton-method:
9
+ #
10
+ # Accepts a logger conforming to the interface of Log4r which can be
11
+ # retrieved on both a class and instance level by calling +logger+.
12
+ mattr_accessor :logger, instance_writer: false
13
+ end
6
14
 
7
15
  # Constructor. You may supply a custom +:pid+, or we call the Fedora Rest API for the
8
16
  # next available Fedora pid, and mark as new object.
@@ -27,7 +35,7 @@ module ActiveFedora
27
35
  raise ActiveFedora::ObjectNotFoundError, "Can't reload an object that hasn't been saved" unless persisted?
28
36
  clear_association_cache
29
37
  clear_relationships
30
- init_with(self.class.find(self.pid).inner_object)
38
+ init_with_object(self.class.find(self.pid).inner_object)
31
39
  end
32
40
 
33
41
  # Initialize an empty model object and set the +inner_obj+
@@ -38,9 +46,9 @@ module ActiveFedora
38
46
  # end
39
47
  #
40
48
  # post = Post.allocate
41
- # post.init_with(DigitalObject.find(pid))
49
+ # post.init_with_object(DigitalObject.find(pid))
42
50
  # post.properties.title # => 'hello world'
43
- def init_with(inner_obj)
51
+ def init_with_object(inner_obj)
44
52
  @association_cache = {}
45
53
  @inner_object = inner_obj
46
54
  unless @inner_object.is_a? SolrDigitalObject
@@ -108,7 +116,7 @@ module ActiveFedora
108
116
  unless klass.ancestors.include? ActiveFedora::Base
109
117
  raise "Cannot adapt #{self.class.name} to #{klass.name}: Not a ActiveFedora::Base subclass"
110
118
  end
111
- klass.allocate.init_with(inner_object)
119
+ klass.allocate.init_with_object(inner_object)
112
120
  end
113
121
 
114
122
  # Examines the :has_model assertions in the RELS-EXT.
@@ -147,7 +155,7 @@ module ActiveFedora
147
155
  if self.inner_object.is_a? DigitalObject
148
156
  raise "#{self.inspect} is already a full digital object"
149
157
  end
150
- self.init_with DigitalObject.find(self.class,self.pid)
158
+ self.init_with_object DigitalObject.find(self.class,self.pid)
151
159
  end
152
160
 
153
161
  module ClassMethods
@@ -48,7 +48,7 @@ module ActiveFedora
48
48
  return obj.inner_object.fetch(field)
49
49
  rescue NoMethodError => e
50
50
  # couldn't get it from solr, so try from fedora.
51
- logger.info "Couldn't get #{field} out of solr, because #{e.message}. Trying another way."
51
+ ActiveFedora::Base.logger.info "Couldn't get #{field} out of solr, because #{e.message}. Trying another way." if ActiveFedora::Base.logger
52
52
  end
53
53
  end
54
54
  # Load from fedora
@@ -1,9 +1,14 @@
1
+ require 'forwardable'
2
+
1
3
  module ActiveFedora
2
- class DatastreamHash < Hash
4
+ class DatastreamHash
5
+ extend Forwardable
6
+
7
+ def_delegators :@hash, *(Hash.instance_methods(false))
3
8
 
4
- def initialize (obj)
9
+ def initialize (obj, &block)
5
10
  @obj = obj
6
- super()
11
+ @hash = Hash.new &block
7
12
  end
8
13
 
9
14
  def [] (key)
@@ -11,18 +16,19 @@ module ActiveFedora
11
16
  ds = Datastream.new(@obj.inner_object, key, :controlGroup=>'X')
12
17
  self[key] = ds
13
18
  end
14
- super
19
+ @hash[key]
15
20
  end
16
21
 
17
22
  def []= (key, val)
18
23
  @obj.inner_object.datastreams[key]=val
19
- super
20
- end
24
+ @hash[key]=val
25
+ end
21
26
 
22
27
  def freeze
23
28
  each_value do |datastream|
24
29
  datastream.freeze
25
30
  end
31
+ @hash.freeze
26
32
  super
27
33
  end
28
34
  end
@@ -7,7 +7,7 @@ module ActiveFedora
7
7
  # if there is no fedora object (loaded from solr) get the instance var
8
8
  # TODO make inner_object a proxy that can hold the pid
9
9
  def pid
10
- @inner_object.pid
10
+ @pid ||= @inner_object.pid
11
11
  end
12
12
 
13
13
  def id ### Needed for the nested form helper
@@ -101,7 +101,7 @@ module ActiveFedora
101
101
  def load_fedora_config
102
102
  return @fedora_config unless @fedora_config.empty?
103
103
  @fedora_config_path = get_config_path(:fedora)
104
- logger.info("ActiveFedora: loading fedora config from #{File.expand_path(@fedora_config_path)}")
104
+ ActiveFedora::Base.logger.info("ActiveFedora: loading fedora config from #{File.expand_path(@fedora_config_path)}") if ActiveFedora::Base.logger
105
105
 
106
106
  begin
107
107
  config_erb = ERB.new(IO.read(@fedora_config_path)).result(binding)
@@ -126,7 +126,7 @@ module ActiveFedora
126
126
  return @solr_config unless @solr_config.empty?
127
127
  @solr_config_path = get_config_path(:solr)
128
128
 
129
- logger.info("ActiveFedora: loading solr config from #{File.expand_path(@solr_config_path)}")
129
+ ActiveFedora::Base.logger.info "ActiveFedora: loading solr config from #{File.expand_path(@solr_config_path)}" if ActiveFedora::Base.logger
130
130
  begin
131
131
  config_erb = ERB.new(IO.read(@solr_config_path)).result(binding)
132
132
  rescue Exception => e
@@ -191,7 +191,7 @@ module ActiveFedora
191
191
  # Last choice, check for the default config file
192
192
  config_path = File.join(ActiveFedora.root, "config", "#{config_type}.yml")
193
193
  if File.file? config_path
194
- logger.warn "Using the default #{config_type}.yml that comes with active-fedora. If you want to override this, pass the path to #{config_type}.yml to ActiveFedora - ie. ActiveFedora.init(:#{config_type}_config_path => '/path/to/#{config_type}.yml') - or set Rails.root and put #{config_type}.yml into \#{Rails.root}/config."
194
+ ActiveFedora::Base.logger.warn "Using the default #{config_type}.yml that comes with active-fedora. If you want to override this, pass the path to #{config_type}.yml to ActiveFedora - ie. ActiveFedora.init(:#{config_type}_config_path => '/path/to/#{config_type}.yml') - or set Rails.root and put #{config_type}.yml into \#{Rails.root}/config." if ActiveFedora::Base.logger
195
195
  return config_path
196
196
  else
197
197
  raise ConfigurationError, "Couldn't load #{config_type} config file!"
@@ -15,10 +15,10 @@ module ActiveFedora
15
15
  ActiveFedora::Base.find(pid, cast: true).delete
16
16
  1
17
17
  rescue ActiveFedora::ObjectNotFoundError
18
- logger.debug "The object #{pid} has already been deleted (or was never created)."
18
+ ActiveFedora::Base.logger.debug "The object #{pid} has already been deleted (or was never created)." if ActiveFedora::Base.logger
19
19
  0
20
20
  rescue Errno::ECONNREFUSED => e
21
- logger.debug "Can't connect to Fedora! Are you sure jetty is running?"
21
+ ActiveFedora::Base.logger.debug "Can't connect to Fedora! Are you sure jetty is running?" if ActiveFedora::Base.logger
22
22
  0
23
23
  end
24
24
  end
@@ -21,14 +21,14 @@ module ActiveFedora
21
21
  raise "model URI incorrectly formatted: #{uri}" unless model_value
22
22
 
23
23
  unless class_exists?(model_value)
24
- logger.warn "#{model_value} is not a real class"
24
+ ActiveFedora::Base.logger.warn "#{model_value} is not a real class" if ActiveFedora::Base.logger
25
25
  return false
26
26
  end
27
27
  result = ActiveFedora.class_from_string(model_value)
28
28
  unless result.nil?
29
29
  model_ns = (result.respond_to? :pid_namespace) ? result.pid_namespace : ContentModel::CMODEL_NAMESPACE
30
30
  if model_ns != pid_ns
31
- logger.warn "Model class namespace '#{model_ns}' does not match uri: '#{uri}'"
31
+ ActiveFedora::Base.logger.warn "Model class namespace '#{model_ns}' does not match uri: '#{uri}'" if ActiveFedora::Base.logger
32
32
  end
33
33
  end
34
34
  result
@@ -5,7 +5,7 @@ module ActiveFedora
5
5
 
6
6
  before_save do
7
7
  if content.blank?
8
- logger.warn "Cowardly refusing to save a datastream with empty content: #{self.inspect}"
8
+ ActiveFedora::Base.logger.warn "Cowardly refusing to save a datastream with empty content: #{self.inspect}" if ActiveFedora::Base.logger
9
9
  false
10
10
  end
11
11
  end
@@ -247,7 +247,7 @@ module ActiveFedora
247
247
  current_params = params.clone
248
248
  current_params.delete_if do |term_pointer,new_values|
249
249
  if term_pointer.kind_of?(String)
250
- logger.warn "WARNING: #{dsid} ignoring {#{term_pointer.inspect} => #{new_values.inspect}} because #{term_pointer.inspect} is a String (only valid OM Term Pointers will be used). Make sure your html has the correct field_selector tags in it."
250
+ ActiveFedora::Base.logger.warn "WARNING: #{dsid} ignoring {#{term_pointer.inspect} => #{new_values.inspect}} because #{term_pointer.inspect} is a String (only valid OM Term Pointers will be used). Make sure your html has the correct field_selector tags in it." if ActiveFedora::Base.logger
251
251
  true
252
252
  else
253
253
  !self.class.terminology.has_term?(*OM.destringify(term_pointer))
@@ -4,7 +4,6 @@ module ActiveFedora
4
4
  extend ActiveSupport::Concern
5
5
  extend Deprecation
6
6
  self.deprecation_horizon = 'active-fedora version 8.0.0'
7
-
8
7
 
9
8
  def new?
10
9
  new_record?
@@ -16,7 +15,6 @@ module ActiveFedora
16
15
  new_record?
17
16
  end
18
17
  deprecation_deprecate :new_object?
19
-
20
18
 
21
19
  ## Required by associations
22
20
  def new_record?
@@ -32,15 +30,19 @@ module ActiveFedora
32
30
  @destroyed
33
31
  end
34
32
 
35
- #Saves a Base object, and any dirty datastreams, then updates
36
- #the Solr index for this object.
37
- def save(*)
38
- # If it's a new object, set the conformsTo relationship for Fedora CMA
39
- new_record? ? create : update_record
33
+ # Saves a Base object, and any dirty datastreams, then updates
34
+ # the Solr index for this object, unless option :update_index=>false is present.
35
+ # Indexing is also controlled by the `create_needs_index?' and `update_needs_index?' methods.
36
+ #
37
+ # @param [Hash] options
38
+ # @option options [Boolean] :update_index (true) set false to skip indexing
39
+ # @return [Boolean] true if save was successful, otherwise false
40
+ def save(options={})
41
+ new_record? ? create(options) : update_record(options)
40
42
  end
41
43
 
42
- def save!(*)
43
- save
44
+ def save!(options={})
45
+ save(options)
44
46
  end
45
47
 
46
48
  # This can be overriden to assert a different model
@@ -73,10 +75,10 @@ module ActiveFedora
73
75
  end
74
76
  end
75
77
 
76
- pid = self.pid ## cache so it's still available after delete
78
+ @pid ||= self.pid ## cache so it's still available after delete
77
79
  begin
78
80
  @inner_object.delete
79
- rescue RestClient::ResourceNotFound =>e
81
+ rescue RestClient::ResourceNotFound => e
80
82
  raise ObjectNotFoundError, "Unable to find #{pid} in the repository"
81
83
  end
82
84
  if ENABLE_SOLR_UPDATES
@@ -128,13 +130,13 @@ module ActiveFedora
128
130
 
129
131
  protected
130
132
 
131
- # Determines whether a create operation cause a solr index of this object.
132
- # Override this if you need different behavior
133
+ # Determines whether a create operation causes a solr index of this object by default.
134
+ # Override this if you need different behavior.
133
135
  def create_needs_index?
134
136
  ENABLE_SOLR_UPDATES
135
137
  end
136
138
 
137
- # Determines whether an update operation cause a solr index of this object.
139
+ # Determines whether an update operation causes a solr index of this object by default.
138
140
  # Override this if you need different behavior
139
141
  def update_needs_index?
140
142
  ENABLE_SOLR_UPDATES
@@ -143,14 +145,16 @@ module ActiveFedora
143
145
  private
144
146
 
145
147
  # Deals with preparing new object to be saved to Fedora, then pushes it and its datastreams into Fedora.
146
- def create
148
+ def create(options={})
147
149
  assign_pid
148
150
  assert_content_model
149
- persist(create_needs_index?)
151
+ should_update_index = create_needs_index? && options.fetch(:update_index, true)
152
+ persist(should_update_index)
150
153
  end
151
154
 
152
- def update_record
153
- persist(update_needs_index?)
155
+ def update_record(options={})
156
+ should_update_index = update_needs_index? && options.fetch(:update_index, true)
157
+ persist(should_update_index)
154
158
  end
155
159
 
156
160
  # replace the unsaved digital object with a saved digital object