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
15
16
# File 'lib/active_fedora/cleaner.rb', line 9

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

.cleanout_solrObject


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

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

.connectionObject


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

def self.connection
  ActiveFedora.fedora.connection
end

.delete_root_resourceObject


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

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

.delete_tombstoneObject


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

def self.delete_tombstone
  connection.delete(tombstone_path)
end

.log(message) ⇒ Object


54
55
56
# File 'lib/active_fedora/cleaner.rb', line 54

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

.reinitialize_repoObject


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

def self.reinitialize_repo
  ActiveFedora.fedora.init_base_path
end

.root_resource_pathObject


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

def self.root_resource_path
  ActiveFedora.fedora.root_resource_path
end

.solr_connectionObject


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

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

.tombstone_pathObject


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

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