Class: Dor::CleanupService
- Inherits:
-
Object
- Object
- Dor::CleanupService
- Defined in:
- lib/dor/services/cleanup_service.rb
Overview
Remove all traces of the object’s data files from the workspace and export areas
Class Method Summary collapse
-
.cleanup(dor_item) ⇒ void
Delete all workspace and export entities for the druid.
- .cleanup_by_druid(druid) ⇒ Object
-
.cleanup_export(druid) ⇒ void
Remove copy of the data that was exported to preservation core.
- .cleanup_purl_doc_cache(druid) ⇒ Object
- .cleanup_stacks(druid) ⇒ Object
-
.cleanup_workspace_content(druid, base) ⇒ void
Remove the object’s data files from the workspace area.
-
.delete_from_dor(pid) ⇒ Object
Delete an object from DOR.
-
.nuke!(druid) ⇒ Object
Tries to remove any exsitence of the object in our systems Does the following: - Removes item from Dor/Fedora/Solr - Removes content from dor workspace - Removes content from assembly workspace - Removes content from sdr export area - Removes content from stacks - Removes content from purl - Removes active workflows.
- .remove_active_workflows(druid) ⇒ Object
-
.remove_branch(pathname) ⇒ void
Remove the specified directory and all its children.
Class Method Details
.cleanup(dor_item) ⇒ void
This method returns an undefined value.
Returns Delete all workspace and export entities for the druid.
9 10 11 12 |
# File 'lib/dor/services/cleanup_service.rb', line 9 def self.cleanup(dor_item) druid = dor_item.respond_to?(:druid) ? dor_item.druid : dor_item.id cleanup_by_druid druid end |
.cleanup_by_druid(druid) ⇒ Object
14 15 16 17 18 |
# File 'lib/dor/services/cleanup_service.rb', line 14 def self.cleanup_by_druid(druid) cleanup_workspace_content(druid, Config.cleanup.local_workspace_root) cleanup_workspace_content(druid, Config.cleanup.local_assembly_root) cleanup_export(druid) end |
.cleanup_export(druid) ⇒ void
This method returns an undefined value.
Returns remove copy of the data that was exported to preservation core.
29 30 31 32 33 34 35 |
# File 'lib/dor/services/cleanup_service.rb', line 29 def self.cleanup_export(druid) id = druid.split(':').last bag_dir = File.join(Config.cleanup.local_export_home, id) remove_branch(bag_dir) tarfile = "#{bag_dir}.tar" remove_branch(tarfile) end |
.cleanup_purl_doc_cache(druid) ⇒ Object
66 67 68 |
# File 'lib/dor/services/cleanup_service.rb', line 66 def self.cleanup_purl_doc_cache(druid) DruidTools::PurlDruid.new(druid, Config.stacks.local_document_cache_root).prune! end |
.cleanup_stacks(druid) ⇒ Object
62 63 64 |
# File 'lib/dor/services/cleanup_service.rb', line 62 def self.cleanup_stacks(druid) DruidTools::StacksDruid.new(druid, Config.stacks.local_stacks_root).prune! end |
.cleanup_workspace_content(druid, base) ⇒ void
This method returns an undefined value.
Returns remove the object’s data files from the workspace area.
23 24 25 |
# File 'lib/dor/services/cleanup_service.rb', line 23 def self.cleanup_workspace_content(druid, base) DruidTools::Druid.new(druid, base).prune! end |
.delete_from_dor(pid) ⇒ Object
Delete an object from DOR.
80 81 82 83 84 |
# File 'lib/dor/services/cleanup_service.rb', line 80 def self.delete_from_dor(pid) Dor::Config.fedora.client["objects/#{pid}"].delete Dor::SearchService.solr.delete_by_id(pid) Dor::SearchService.solr.commit end |
.nuke!(druid) ⇒ Object
Tries to remove any exsitence of the object in our systems
Does the following:
- Removes item from Dor/Fedora/Solr
- Removes content from dor workspace
- Removes content from assembly workspace
- Removes content from sdr export area
- Removes content from stacks
- Removes content from purl
- Removes active workflows
54 55 56 57 58 59 60 |
# File 'lib/dor/services/cleanup_service.rb', line 54 def self.nuke!(druid) cleanup_by_druid druid cleanup_stacks druid cleanup_purl_doc_cache druid remove_active_workflows druid delete_from_dor druid end |
.remove_active_workflows(druid) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/dor/services/cleanup_service.rb', line 70 def self.remove_active_workflows(druid) %w(dor sdr).each do |repo| dor_wfs = Dor::Config.workflow.client.get_workflows(druid, repo) dor_wfs.each { |wf| Dor::Config.workflow.client.delete_workflow(repo, druid, wf) } end end |
.remove_branch(pathname) ⇒ void
This method returns an undefined value.
Returns Remove the specified directory and all its children.
39 40 41 42 |
# File 'lib/dor/services/cleanup_service.rb', line 39 def self.remove_branch(pathname) pathname = Pathname(pathname) if pathname.instance_of? String pathname.rmtree if pathname.exist? end |