#!/usr/bin/env ruby # encoding: UTF-8 require File.expand_path(File.dirname(__FILE__) + '/../config/boot') require 'optparse' require 'druid-tools' VERSION = '0.3' class Accession < GeoHydra::Process def run(args) begin File.umask(002) flags = { :admin_policy => 'druid:gz830zp4734', :rights => 'stanford', :tags => [ "Registered By : #{%x{whoami}.strip} (GeoHydra)" ], :tmpdir => GeoHydra::Config.geohydra.tmpdir || 'tmp', :verbose => false, :configtest => false, :purge => false, :accessionWF => false, :contentMetadata => true, :debug => false, :shelve => false, :dryrun => false, :workspacedir => GeoHydra::Config.geohydra.workspace || 'workspace' } OptionParser.new do |opts| opts.version = VERSION opts.banner = < flags}) if flags[:debug] # Verify configuation if flags[:configtest] errs = 0 %w{workflow.url fedora.safeurl solrizer.url ssl.cert_file ssl.key_pass dor.service_root}.each do |k| begin k = "Dor::Config.#{k}" if eval(k).nil? $stderr.puts "ERROR: Configuration requires #{k}" errs += 1 end rescue Exception => e $stderr.puts e, e.backtrace end end puts "Configuration OK" if errs == 0 exit errs end if args.empty? STDIN.each do |line| pid = line.strip druid = DruidTools::Druid.new(pid, flags[:workspacedir]) GeoHydra::Accession.run(druid, flags) end else args.each do |pid| druid = DruidTools::Druid.new(pid, flags[:workspacedir]) GeoHydra::Accession.run(druid, flags) end end rescue SystemCallError => e $stderr.puts "ERROR: #{e.message}" $stderr.puts e.backtrace exit(-1) end end end # __MAIN__ Accession.new.run(ARGV)