Sha256: e606ff4f36eee661ebc837a7a21d6c1fbd2204b234d12ee0e00b460dcbf56115
Contents?: true
Size: 1.92 KB
Versions: 4
Compression:
Stored size: 1.92 KB
Contents
module LyberCore class LyberCore::Destroyer require 'active-fedora' require 'open-uri' attr_reader :repository attr_reader :workflow attr_reader :registration_robot attr_reader :druid_list attr_reader :current_druid # Given a repository, a workflow and the name of a robot that registers objects in fedora # we can generate a list of all the druids that were created by that robot def initialize(repository, workflow, registration_robot) @repository = repository @workflow = workflow @registration_robot = registration_robot @druid_list = self.get_druid_list end def get_druid_list begin Dor::WorkflowService.get_objects_for_workstep @registration_robot, '', @workflow, default_repository: @repository rescue Exception => e raise e, "Couldn't fetch druid list" end end # Iterate through the druids in @druid_list and delete each of them from FEDORA def delete_druids begin connect_to_fedora @druid_list.each do |druid| @current_druid = druid LyberCore::Log.info("Deleting #{@current_druid}") begin obj = ActiveFedora::Base.load_instance(@current_druid) obj.delete rescue ActiveFedora::ObjectNotFoundError LyberCore::Log.info("#{@current_druid} does not exist in this repository") end end rescue Exception => e raise e end end def connect_to_fedora begin if @repository == "dor" repo_url = FEDORA_URI elsif @repository == "sdr" repo_url = SEDORA_URI else raise "I don't know how to connect to repository #{@repository}" end LyberCore::Log.info("connecting to #{repo_url}") Fedora::Repository.register(repo_url) rescue Errno::ECONNREFUSED => e raise e, "Can't connect to Fedora at url #{repo_url}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lyber-core-3.3.1 | lib/lyber_core/destroyer.rb |
lyber-core-3.3.0 | lib/lyber_core/destroyer.rb |
lyber-core-3.2.5 | lib/lyber_core/destroyer.rb |
lyber-core-3.2.4 | lib/lyber_core/destroyer.rb |