Skip to content

Commit

Permalink
- Upgraded codebase to use Rails 2.3.2. Main changes:
Browse files Browse the repository at this point in the history
  - Updated the Annotations and Favourites plugins (to also use the latest plugin_test_helper).
  - WSDL parsing - loading XML into a Hash has changed now... <serviceType> is now x['service_type'].
  - Many other small tweaks to get things working properly.

I have carried out some extensive testing but we still need much more testing to ascertain stability. We especially need to test Soaplab Server submission and new user account signups.

- Integrated the “Better Logging” plugin for Rails (http://github.com/pauldowman/better_logging/tree/master) to provide better log outputs. (Unfortunately this has resulted in losing the rotated log files mechanism. This is necessary because ActiveSupport::BufferedLogger.new is the recommended logger, NOT Logger.new).

- Revamped the way the cache client is set up to make it more consistent and also easier to fix for Passenger. Also, we now use the latest memcache-client instead of the one supplied by Rails (as the former is significantly faster).

- Installed the geokit-rails plugin, in place of the old geokit plugin, which relies on the geokit gem (which has been vendored).

git-svn-id: svn+ssh://rubyforge.org/var/svn/biocatalogue/trunk@763 1acaf488-1b9d-4964-8077-0a2fdb83ef00
  • Loading branch information
jits committed Jun 6, 2009
1 parent 0cb4c13 commit 28ac66d
Show file tree
Hide file tree
Showing 147 changed files with 6,223 additions and 1,330 deletions.
14 changes: 7 additions & 7 deletions .loadpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<loadpath>
<pathentry path="" type="src"/>
<pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
<pathentry path="GEM_LIB/rake-0.8.3/lib" type="var"/>
<pathentry path="GEM_LIB/activeresource-2.2.2/lib" type="var"/>
<pathentry path="GEM_LIB/rails-2.2.2/lib" type="var"/>
<pathentry path="GEM_LIB/actionmailer-2.2.2/lib" type="var"/>
<pathentry path="GEM_LIB/activesupport-2.2.2/lib" type="var"/>
<pathentry path="GEM_LIB/activerecord-2.2.2/lib" type="var"/>
<pathentry path="GEM_LIB/actionpack-2.2.2/lib" type="var"/>
<pathentry path="GEM_LIB/rake-0.8.7/lib" type="var"/>
<pathentry path="GEM_LIB/activeresource-2.3.2/lib" type="var"/>
<pathentry path="GEM_LIB/rails-2.3.2/lib" type="var"/>
<pathentry path="GEM_LIB/actionmailer-2.3.2/lib" type="var"/>
<pathentry path="GEM_LIB/activesupport-2.3.2/lib" type="var"/>
<pathentry path="GEM_LIB/activerecord-2.3.2/lib" type="var"/>
<pathentry path="GEM_LIB/actionpack-2.3.2/lib" type="var"/>
</loadpath>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BioCatalogue: app/controllers/application.rb
# BioCatalogue: app/controllers/application_controller.rb
#
# Copyright (c) 2009, University of Manchester, The European Bioinformatics
# Institute (EMBL-EBI) and the University of Southampton.
Expand All @@ -11,21 +11,19 @@
# Need to do this so that we play nice with the annotations and favourites plugin.
# THIS DOES UNFORTUNATELY MEAN THAT A SERVER RESTART IS REQUIRED WHENEVER CHANGES ARE MADE
# TO THIS FILE, EVEN IN DEVELOPMENT MODE.
require_dependency RAILS_ROOT + '/vendor/plugins/annotations/lib/app/controllers/application'
require_dependency RAILS_ROOT + '/vendor/plugins/favourites/lib/app/controllers/application'
require_dependency RAILS_ROOT + '/vendor/plugins/annotations/lib/app/controllers/application_controller'
require_dependency RAILS_ROOT + '/vendor/plugins/favourites/lib/app/controllers/application_controller'
#---

class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time

# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery :secret => 'bc5fa0462513829e6a733e8947c24994'

# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
filter_parameter_logging :password

protect_from_forgery

layout "application_wide"

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def show
@results = BioCatalogue::Search.search_all(@query)
rescue Exception => ex
flash.now[:error] = "Search failed. Possible bad search term. Please report this if it continues for other searches."
logger.error("ERROR: search failed for query: '#{@query}'. Exception:")
logger.error("Search failed for query: '#{@query}'. Exception:")
logger.error(ex.message)
logger.error(ex.backtrace.join("\n"))
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def search
@results = BioCatalogue::Search.search(@query, @type)
rescue Exception => ex
flash.now[:error] = "Search failed. Possible bad search term. Please report this if it continues for other searches."
logger.error("ERROR: search failed for query: '#{@query}'. Exception:")
logger.error("Search failed for query: '#{@query}'. Exception:")
logger.error(ex.message)
logger.error(ex.backtrace.join("\n"))
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/soap_services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def load_wsdl
end
rescue Exception => ex
@error_message = "Failed to load the WSDL location provided."
logger.error("ERROR: failed to load WSDL from location - #{wsdl_location}. Exception:")
logger.error("Failed to load WSDL from location - #{wsdl_location}. Exception:")
logger.error(ex.message)
logger.error(ex.backtrace.join("\n"))
end
Expand Down Expand Up @@ -220,7 +220,7 @@ def bulk_create
end
rescue Exception => ex
@error_urls << url
logger.error("ERROR: failed to register service - #{url}. Bulk registration Exception:")
logger.error("Failed to register service - #{url}. Bulk registration Exception:")
logger.error(ex)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/soaplab_servers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def load_wsdl
@wsdl_geo_location = BioCatalogue::Util.url_location_lookup(wsdl_location)
rescue Exception => ex
@error_message = "Failed to load the WSDL location provided."
logger.error("ERROR: failed to load WSDL from location - #{wsdl_location}. Exception:")
logger.error("Failed to load WSDL from location - #{wsdl_location}. Exception:")
logger.error(ex)
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/rest_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def submit_service(endpoint, actual_submitter, annotations_data)
end
rescue Exception => ex
#ActiveRecord::RecordNotSaved, ActiveRecord::RecordInvalid
logger.error("ERROR: failed to submit REST service - #{endpoint}. Exception:")
logger.error("Failed to submit REST service - #{endpoint}. Exception:")
logger.error(ex.message)
logger.error(ex.backtrace.join("\n"))
success = false
Expand All @@ -104,7 +104,7 @@ def submit_service(endpoint, actual_submitter, annotations_data)
begin
self.process_annotations_data(annotations_data, actual_submitter)
rescue Exception => ex
logger.error("ERROR: failed to process annotations after REST service creation. REST service ID: #{self.id}. Exception:")
logger.error("Failed to process annotations after REST service creation. REST service ID: #{self.id}. Exception:")
logger.error(ex.message)
logger.error(ex.backtrace.join("\n"))
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/soap_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def submit_service(endpoint, actual_submitter, annotations_data)
end
rescue Exception => ex
#ActiveRecord::RecordNotSaved, ActiveRecord::RecordInvalid
logger.error("ERROR: failed to submit SOAP service - #{endpoint}. Exception:")
logger.error("Failed to submit SOAP service - #{endpoint}. Exception:")
logger.error(ex.message)
logger.error(ex.backtrace.join("\n"))
success = false
Expand All @@ -186,7 +186,7 @@ def submit_service(endpoint, actual_submitter, annotations_data)
begin
self.process_annotations_data(annotations_data, actual_submitter)
rescue Exception => ex
logger.error("ERROR: failed to process annotations after SOAP service creation. SOAP service ID: #{self.id}. Exception:")
logger.error("Failed to process annotations after SOAP service creation. SOAP service ID: #{self.id}. Exception:")
logger.error(ex.message)
logger.error(ex.backtrace.join("\n"))
end
Expand Down
10 changes: 5 additions & 5 deletions app/models/soaplab_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ def save_services(current_user)
c_success = soap_service.submit_service( data["endpoint"], current_user, {} )
if c_success
new_wsdls << url
logger.info("INFO: registered service - #{url}. SUCCESS:")
logger.info("Registered service - #{url}. SUCCESS:")
else
error_urls << url
logger.error("ERROR: post_create failed for service - #{url}. ")
logger.error("post_create failed for service - #{url}. ")
end
end
rescue Exception => ex
error_urls << url
logger.error("ERROR: failed to register service - #{url}. soaplab registration Exception:")
logger.error("failed to register service - #{url}. soaplab registration Exception:")
logger.error(ex)
end
end
Expand Down Expand Up @@ -92,7 +92,7 @@ def get_soaplab1_data(proxy)
}
return data
rescue Exception => ex
logger.error("ERROR: failed to get data from sooaplab server:")
logger.error("Failed to get data from sooaplab server:")
logger.error(ex)
return {}
end
Expand Down Expand Up @@ -127,7 +127,7 @@ def get_soaplab2_data(proxy)
}
return data
rescue Exception => ex
logger.error("ERROR: failed to get data from sooaplab server:")
logger.error("Failed to get data from sooaplab server:")
logger.error(ex)
return {}
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def activate!
self.save!
return true
rescue Exception => ex
logger.error("ERROR: failed to activate user #{self.id}. Exception:")
logger.error("Failed to activate user #{self.id}. Exception:")
logger.error(ex)
return false
end
Expand All @@ -83,7 +83,7 @@ def generate_security_token!
self.save!
return true
rescue Exception => ex
logger.error("ERROR: failed to generate the security token for user #{self.id}. Exception:")
logger.error("Failed to generate the security token for user #{self.id}. Exception:")
logger.error(ex)
return false
end
Expand All @@ -97,7 +97,7 @@ def reset_password!(password = nil, password_confirmation = nil)
self.save!
return true
rescue Exception => ex
logger.error("ERROR: failed to reset password for user #{self.id}. Exception:")
logger.error("Failed to reset password for user #{self.id}. Exception:")
logger.error(ex)
return false
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/services/_listing.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
:show_add_option => false,
:show_modify_options => false } -%>

<div style="margin: 0.8em 0">
<div style="margin: 1.1em 0 0.8em 0;">
<%= render :partial => "annotations/descriptions",
:locals => { :annotatable => service_version_instance,
:show_header => false,
:truncate_desc => 150,
:truncate_desc => 100,
:auto_link_desc => false,
:show_modify_options => false,
:show_none_text => false } -%>
Expand Down
1 change: 1 addition & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
end
end

Expand Down
8 changes: 5 additions & 3 deletions config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Expand All @@ -27,6 +27,8 @@
# config.gem "aws-s3", :lib => "aws/s3"
config.gem 'disqus', :version => '1.0.1'
config.gem 'soap4r', :version => '1.5.8'
config.gem 'mperham-memcache-client', :version => '>= 1.7.3', :lib => 'memcache', :source => "http://gems.github.com"
config.gem 'geokit'

# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
Expand All @@ -38,7 +40,6 @@

# Rotate logs when they reach a size of 10M and keep no more than 10 of these
#config.logger = Logger.new(config.log_path, 10, (1024**2)*10)
config.logger = Logger.new(config.log_path, 100, (1024**2)*10)

# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
Expand Down Expand Up @@ -80,7 +81,8 @@
PhusionPassenger.on_event(:starting_worker_process) do |forked|
if forked
# We're in smart spawning mode.
CACHE.reset
# Reset caches..
BioCatalogue::CacheHelper.reset_caches
else
# We're in conservative spawning mode. We don't need to do anything.
end
Expand Down
8 changes: 1 addition & 7 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,4 @@
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false


# From: http://www.whatcodecraves.com/articles/2009/03/17/rails_2.2.2_chicken_and_egg_migrations_headache/ -

# kids, this is what an ugly hack looks like. Don't worry, Rails
# 2.3 will fix this.
config.cache_classes = (File.basename($0) == "rake" && !ARGV.grep(/db:/).empty?) ? false : true

config.action_view.cache_template_loading = true
8 changes: 0 additions & 8 deletions config/initializers/biocat_local.rb.pre
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,3 @@ Disqus::defaults[:developer] = true # allows for threads to work on localhost du

# Enable or disable endpoint status check icon in view
DISABLE_STATUS_CHECK = true

# ============
# Cache config
# ------------

ActionController::Base.cache_store = :mem_cache_store, "127.0.0.1:11211", { :namespace => "BioCatalogue", :multithread => true }

# ============
15 changes: 14 additions & 1 deletion config/initializers/biocat_main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,24 @@
require 'object'
require 'addressable/uri'
require 'system_timer'
require 'libxml'
require 'dnsruby'

# Never explicitly load the memcache-client library as we need to use
# the specific one vendored in our codebase.
#require 'memcache'

# Change XML backend that Rails uses to a faster one
#XmlMini.backend = 'LibXML' # Not working currently. TODO: set this up when implementing the XML REST API.

# Initialise the country codes library
CountryCodes

# Set up loggers to STDOUT if in script/console (so now things like SQL queries etc are shown in the console).
# Set up caches
BioCatalogue::CacheHelper.setup_caches

# Set up loggers to STDOUT if in script/console
# (so now things like SQL queries etc are shown in the console instead of the development/production/etc logs).
if "irb" == $0
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActionController::Base.logger = Logger.new(STDOUT)
Expand Down
61 changes: 61 additions & 0 deletions config/initializers/geokit_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
if defined? Geokit

# These defaults are used in Geokit::Mappable.distance_to and in acts_as_mappable
Geokit::default_units = :miles
Geokit::default_formula = :sphere

# This is the timeout value in seconds to be used for calls to the geocoder web
# services. For no timeout at all, comment out the setting. The timeout unit
# is in seconds.
Geokit::Geocoders::timeout = 3

# These settings are used if web service calls must be routed through a proxy.
# These setting can be nil if not needed, otherwise, addr and port must be
# filled in at a minimum. If the proxy requires authentication, the username
# and password can be provided as well.
Geokit::Geocoders::proxy_addr = nil
Geokit::Geocoders::proxy_port = nil
Geokit::Geocoders::proxy_user = nil
Geokit::Geocoders::proxy_pass = nil

# This is your yahoo application key for the Yahoo Geocoder.
# See http://developer.yahoo.com/faq/index.html#appid
# and http://developer.yahoo.com/maps/rest/V1/geocode.html
Geokit::Geocoders::yahoo = 'REPLACE_WITH_YOUR_YAHOO_KEY'

# This is your Google Maps geocoder key.
# See http://www.google.com/apis/maps/signup.html
# and http://www.google.com/apis/maps/documentation/#Geocoding_Examples
Geokit::Geocoders::google = 'REPLACE_WITH_YOUR_GOOGLE_KEY'

# This is your username and password for geocoder.us.
# To use the free service, the value can be set to nil or false. For
# usage tied to an account, the value should be set to username:password.
# See http://geocoder.us
# and http://geocoder.us/user/signup
Geokit::Geocoders::geocoder_us = false

# This is your authorization key for geocoder.ca.
# To use the free service, the value can be set to nil or false. For
# usage tied to an account, set the value to the key obtained from
# Geocoder.ca.
# See http://geocoder.ca
# and http://geocoder.ca/?register=1
Geokit::Geocoders::geocoder_ca = false

# Uncomment to use a username with the Geonames geocoder
#Geokit::Geocoders::geonames="REPLACE_WITH_YOUR_GEONAMES_USERNAME"

# This is the order in which the geocoders are called in a failover scenario
# If you only want to use a single geocoder, put a single symbol in the array.
# Valid symbols are :google, :yahoo, :us, and :ca.
# Be aware that there are Terms of Use restrictions on how you can use the
# various geocoders. Make sure you read up on relevant Terms of Use for each
# geocoder you are going to use.
Geokit::Geocoders::provider_order = [:google,:us]

# The IP provider order. Valid symbols are :ip,:geo_plugin.
# As before, make sure you read up on relevant Terms of Use for each
# Geokit::Geocoders::ip_provider_order = [:geo_plugin,:ip]

end
Loading

0 comments on commit 28ac66d

Please sign in to comment.