Created
October 28, 2010 06:37
-
-
Save brianjriddle/650775 to your computer and use it in GitHub Desktop.
jruby script to index up our polopoly content. Creates a client and calls a method. Most of the skript is setting up the classpath.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sets up classpath needed to run the script, notice that commons-httpclient-3.1.jar | |
# need come before jbossall-client.jar as the jboss jar includes an | |
# older httpclient and will not work with solr | |
require 'java' | |
module Polopoly | |
polopoly_libs = ["/install/lib/servlet.jar", | |
"/install/lib/polopoly.jar", | |
"/install/lib/polopoly-community.jar", | |
"/install/lib/lucene-core-1.9.1.jar", | |
"/custom/lib/solrmasterconfiguration.jar", | |
"/custom/client-lib/xmlbeans_contentinfo.jar", | |
"/custom/client-lib/xbean.jar", | |
"/custom/client-lib/tv4.jar", | |
"/custom/client-lib/xmlbeans_texttv.jar", | |
"/custom/client-lib/slf4j-jdk14-1.5.5.jar", | |
"/custom/client-lib/slf4j-api-1.5.5.jar", | |
"/custom/client-lib/spring-1.2.6.jar", | |
"/custom/client-lib/commons-logging-1.1.1.jar", | |
"/custom/client-lib/commons-httpclient-3.0.jar", | |
"/custom/client-lib/commons-codec-1.3.jar", | |
"/custom/client-lib/apache-solr-solrj-1.4.jar", | |
"/custom/client-lib/apache-solr-core-1.4.jar", | |
"/custom/client-lib/tv4plugin-1.0.5.jar"] | |
jboss_libs = ["/client/jbossall-client.jar"] | |
if ENV['POLOPOLY_HOME'].eql? nil or ENV['JBOSS_HOME'].eql? nil | |
puts "must set POLOPOLY_HOME and JBOSS_HOME" | |
exit | |
end | |
polopoly_libs.each do |lib| | |
require ENV["POLOPOLY_HOME"] + lib | |
end | |
jboss_libs.each do |lib| | |
require ENV["JBOSS_HOME"] + lib | |
end | |
include_package "com.polopoly.cm" | |
include_package "com.polopoly.pear" | |
end | |
if ARGV.empty? or not ARGV.length == 1 | |
puts "usage: #{__FILE__} contentids.txt" | |
else | |
application = Polopoly::ApplicationFactory.createApplication([ENV["POLOPOLY_HOME"] + "/pear/config/polopolyclient.properties"].to_java(:string)) | |
cm_server = application.getPolicyCMServer | |
File.open(ARGV[0]).readlines.each do |content_id| | |
major, minor = content_id.split '.' | |
begin | |
article = cm_server.getPolicy(Polopoly::ContentId.new(major.to_i, minor.to_i)) | |
unless article.nil? | |
puts "#{major}.#{minor.chomp} - #{article.name}" | |
article.addToSolrIndex | |
end | |
rescue | |
puts "FAILED to index #{major}.#{minor.chomp}" | |
puts $! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment