Module: ActiveFedora::Cleaner

Defined in:
lib/active_fedora/cleaner.rb

Class Method Summary collapse

Class Method Details

.clean!Object



3
4
5
6
7
# File 'lib/active_fedora/cleaner.rb', line 3

def self.clean!
  cleanout_fedora
  reinitialize_repo
  cleanout_solr
end

.cleanout_fedoraObject



9
10
11
12
13
14
# File 'lib/active_fedora/cleaner.rb', line 9

def self.cleanout_fedora
  delete_root_resource
  delete_tombstone
rescue Ldp::HttpError => exception
  log "#cleanout_fedora in spec_helper.rb raised #{exception}"
end

.cleanout_solrObject



41
42
43
44
# File 'lib/active_fedora/cleaner.rb', line 41

def self.cleanout_solr
  restore_spec_configuration if solr_connection.nil?
  solr_connection.delete_by_query('*:*', params: { 'softCommit' => true })
end

.connectionObject



33
34
35
# File 'lib/active_fedora/cleaner.rb', line 33

def self.connection
  ActiveFedora.fedora.connection
end

.delete_root_resourceObject



16
17
18
19
# File 'lib/active_fedora/cleaner.rb', line 16

def self.delete_root_resource
  connection.delete(root_resource_path)
rescue Ldp::Gone
end

.delete_tombstoneObject



21
22
23
# File 'lib/active_fedora/cleaner.rb', line 21

def self.delete_tombstone
  connection.delete(tombstone_path)
end

.log(message) ⇒ Object



50
51
52
# File 'lib/active_fedora/cleaner.rb', line 50

def self.log(message)
  ActiveFedora::Base.logger.debug message
end

.reinitialize_repoObject



46
47
48
# File 'lib/active_fedora/cleaner.rb', line 46

def self.reinitialize_repo
  ActiveFedora::Fedora.reset!
end

.root_resource_pathObject



29
30
31
# File 'lib/active_fedora/cleaner.rb', line 29

def self.root_resource_path
  ActiveFedora.fedora.root_resource_path
end

.solr_connectionObject



37
38
39
# File 'lib/active_fedora/cleaner.rb', line 37

def self.solr_connection
  ActiveFedora::SolrService.instance&.conn
end

.tombstone_pathObject



25
26
27
# File 'lib/active_fedora/cleaner.rb', line 25

def self.tombstone_path
  root_resource_path + "/fcr:tombstone"
end