Top Level Namespace

Defined Under Namespace

Modules: MARC2Solr

Constant Summary collapse

HC =

If we’re going to be talking to Solr, make sure it’s there!

Java::org.apache.commons.httpclient
WHOLE =
/^(\d{3})$/
CTRL =
/^(\d{3})\[(.+?)\]/
VAR =
/^(\d{3})(.+)/

Instance Method Summary collapse

Instance Method Details

#pingSolr(opts) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'bin/marc2solr', line 22

def pingSolr(opts)
  if opts[:dryrun]
    LOG.info "Dry run: not bothing to check and see if solr is alive"
  else
    url = opts.sussURL + '/admin/ping'
    client = HC.HttpClient.new 
    method = HC.methods.GetMethod.new(url)
    begin
      code = client.executeMethod(method)
    rescue 
      LOG.error "Can't ping solr URL '#{url}'" if defined? LOG
      raise ArgumentError, "(Not up?) Can't ping solr server at #{opts.sussURL}"
    end
    unless code == 200
      LOG.error "Can't ping solr URL '#{url}'" if defined? LOG
      raise ArgumentError, "Got response code #{code} from #{opts.sussURL}"
    end
  end
end

#usageObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'bin/solrmarc_to_marc2solr', line 15

def usage
  puts %q{
  solrmarc_to_marc2solr -- attempt to convert a solrmarc index file and
  translation maps to marc2solr format
  
  Usage:
  
    solrmarc_to_marc2solr /path/to/blah_index.properties /path/to/newdir
    
  This will:
   1. Tranlaste all the translation maps found in the directory "translation_maps"
      located in the same direcotry as blah_index.properites and put them in
      /path/to/newdir/translation_maps
   2. Translate blah_index.properties and put the resultling index.dsl file in
      /path/to/newdir/index.dsl
   3. Create a logfile, solrmarc_to_marc2solr.log in /path/to/newdir/ that
      lists the lines it couldn't read and didn't attempt to translate (e.g., most
      custom functions)
  }
  Process.exit
  
end