Class: Hyrax::DataDestroyers::RepositoryMetadataDestroyer

Inherits:
Object
  • Object
show all
Defined in:
app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb

Overview

Note:

WARNING: DO NOT USE IN PRODUCTION! The methods in this class are destructive. Data can not be recovered.

Note:

When using Wings adapter, which wraps ActiveFedora, the persister wipe! method clears both Fedora and Solr. Optionally, an index_adapter may also be set to use Valkyrie to write to a second Solr core. If the Hyrax index adapter is the NullIndexingAdapter, that means that Valkyrie is not being used to index the repository metadata and does not need to be cleared using the Hyrax index adapter.

When using other Valkyrie persistence adapters, wipe! only clears the repository metadata from the datastore (e.g. ORM table in Postgres). The index adapter is used to clear metadata from Solr.

Clear all repository metadata from the datastore (e.g. Fedora, Postgres) and from Solr.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



23
24
25
# File 'app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb', line 23

def logger
  @logger
end

Class Method Details

.destroy_metadata(logger: Logger.new(STDOUT), allow_destruction_in_production: false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb', line 25

def (logger: Logger.new(STDOUT), allow_destruction_in_production: false)
  raise("RepositoryMetadataDestroyer is not for use in production!") if Rails.env.production? && !allow_destruction_in_production
  @logger = logger

  logger.info("Destroying all repository metadata...")

  unless Hyrax.index_adapter.is_a? Valkyrie::Indexing::NullIndexingAdapter
    conn = Hyrax.index_adapter.connection
    conn.delete_by_query('*:*', params: { 'softCommit' => true })
  end
  Hyrax.persister.wipe!

  logger.info("   repository metadata -- DESTROYED")
end