umlaut 3.0.0alpha2 → 3.0.0alpha3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/link_router_controller.rb +0 -14
- data/app/controllers/resolve_controller.rb +1 -14
- data/app/controllers/umlaut/controller_behavior.rb +15 -0
- data/app/models/sfx_db/sfx_db_base.rb +4 -0
- data/lib/generators/umlaut/install_generator.rb +1 -1
- data/lib/tasks/umlaut_migrate_permalinks.rake +106 -0
- data/lib/umlaut/version.rb +1 -1
- data/lib/umlaut.rb +9 -8
- data/test/dummy/config/database.yml +53 -0
- data/test/dummy/log/development.log +0 -12981
- metadata +115 -181
- data/lib/service_adaptors/sfx-new.rb +0 -557
- data/test/dummy/config/database.yml-jh +0 -19
- data/test/dummy/tmp/cache/assets/C5F/340/sprockets%2F99692920160b7a279b86a80415b79db7 +0 -0
- data/test/dummy/tmp/cache/assets/C70/4D0/sprockets%2F034ad2036e623081bd352800786dfe80 +0 -0
- data/test/dummy/tmp/cache/assets/C73/920/sprockets%2Fd371318f22900492fd180f17c5e2a504 +0 -9268
- data/test/dummy/tmp/cache/assets/C80/980/sprockets%2Fc94807409c1523d43e18d25f35d93c41 +0 -0
- data/test/dummy/tmp/cache/assets/C8F/780/sprockets%2Fe47e28558116fb5f8038754e60d1961d +0 -11769
- data/test/dummy/tmp/cache/assets/CAA/EB0/sprockets%2F1d179210e8b76f1ea63c802688a015e4 +0 -9271
- data/test/dummy/tmp/cache/assets/CBB/9C0/sprockets%2F706f28923fb754cad04b9107c89986a1 +0 -0
- data/test/dummy/tmp/cache/assets/CBF/B60/sprockets%2F08ca89671549936265dcb673bf02e36f +0 -0
- data/test/dummy/tmp/cache/assets/CC9/9F0/sprockets%2F306166316e2cafd13c15e62b51a2339d +0 -0
- data/test/dummy/tmp/cache/assets/CF6/F20/sprockets%2F5b2ffa1103079dfd555197838f87a99f +0 -0
- data/test/dummy/tmp/cache/assets/CF7/2B0/sprockets%2F25a7c73655bd3598173b39d9f98bcd46 +0 -862
- data/test/dummy/tmp/cache/assets/CFE/080/sprockets%2F37fe9f4255baddbd549a659914929398 +0 -0
- data/test/dummy/tmp/cache/assets/D22/060/sprockets%2F9aec77b768e91a802d284271c58e2f7e +0 -21357
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D33/6D0/sprockets%2F500129c57f1146e556ec3aacd6cd38c1 +0 -0
- data/test/dummy/tmp/cache/assets/D33/FD0/sprockets%2F2ba0b4e6334a77b923e5f770381bb2bf +0 -0
- data/test/dummy/tmp/cache/assets/D42/C20/sprockets%2Fbcf14e437b1582bf93b77670acf8e090 +0 -21353
- data/test/dummy/tmp/cache/assets/D50/A30/sprockets%2F7d8b294ac433db5d056538f8cf7c66b9 +0 -0
- data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -872
- data/test/dummy/tmp/cache/assets/D65/590/sprockets%2Fc1bb92fc3406a126b7dd302edc96d629 +0 -0
- data/test/dummy/tmp/cache/assets/D71/6B0/sprockets%2Fde558b71b494cf09b1bf055c8dff0353 +0 -0
- data/test/dummy/tmp/cache/assets/D72/610/sprockets%2Fa8c708eeb30ef93de34d755d4f45d023 +0 -859
- data/test/dummy/tmp/cache/assets/D76/AD0/sprockets%2Fe2158cde93188cf5ab6457bc6d6602ec +0 -0
- data/test/dummy/tmp/cache/assets/D7A/E40/sprockets%2F9622ffcc499a57627cd1bb18fe31b8e4 +0 -11772
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
- data/test/dummy/tmp/cache/assets/D9B/770/sprockets%2F8aacf02eb7dbb0949704b28f27b87e0b +0 -0
- data/test/dummy/tmp/cache/assets/DA6/A80/sprockets%2F92e26d8e58d5bcc8b8f6c25d1b05b9c1 +0 -0
- data/test/dummy/tmp/cache/assets/DE8/790/sprockets%2Fd1333bde2b9aafcc712d11dd09ab35d8 +0 -0
- data/test/dummy/tmp/cache/assets/DF7/F30/sprockets%2F7bc16c4109b17fabe29f8ddbbf732d1c +0 -374
- data/test/dummy/tmp/cache/assets/E03/570/sprockets%2F493bdc0ac14cd4f57fdfe4253f992bde +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E0B/4B0/sprockets%2F7988df51a61c81ce6ede4a2d4c8cce4f +0 -377
- data/test/dummy/tmp/cache/assets/E5F/960/sprockets%2Fdc007b6cad5c7ef08e33ec28cfff0ef6 +0 -0
@@ -31,20 +31,6 @@ class LinkRouterController < UmlautController
|
|
31
31
|
|
32
32
|
protected
|
33
33
|
|
34
|
-
# Must return a Hash where each key is a unique service name, and
|
35
|
-
# each value a hash that defines a service. Like the hash in services.yml
|
36
|
-
# under default/services. By default, this method in fact just loads
|
37
|
-
# and returns that hash, but can be over-ridden with local logic for
|
38
|
-
# determining proper list of services for current request.
|
39
|
-
#
|
40
|
-
# Local over-ride could even in theory return a custom subclass of Collection,
|
41
|
-
# with customized dispatch behavior. Probably not a great idea though.
|
42
|
-
def create_collection
|
43
|
-
# trim out ones with disabled:true
|
44
|
-
services = ServiceStore.config["default"]["services"].reject {|id, hash| hash["disabled"] == true}
|
45
|
-
|
46
|
-
return Collection.new(@user_request, services)
|
47
|
-
end
|
48
34
|
|
49
35
|
|
50
36
|
# Used to calculate a destination/target url for an Umlaut response item.
|
@@ -137,20 +137,7 @@ class ResolveController < UmlautController
|
|
137
137
|
protected
|
138
138
|
|
139
139
|
|
140
|
-
|
141
|
-
# each value a hash that defines a service. Like the hash in services.yml
|
142
|
-
# under default/services. By default, this method in fact just loads
|
143
|
-
# and returns that hash, but can be over-ridden with local logic for
|
144
|
-
# determining proper list of services for current request.
|
145
|
-
#
|
146
|
-
# Local over-ride could even in theory return a custom subclass of Collection,
|
147
|
-
# with customized dispatch behavior. Probably not a great idea though.
|
148
|
-
def create_collection
|
149
|
-
# trim out ones with disabled:true
|
150
|
-
services = ServiceStore.config["default"]["services"].reject {|id, hash| hash && hash["disabled"] == true}
|
151
|
-
|
152
|
-
return Collection.new(@user_request, services)
|
153
|
-
end
|
140
|
+
|
154
141
|
|
155
142
|
# Retrives or sets up the relevant Umlaut Request, and returns it.
|
156
143
|
def init_processing
|
@@ -16,5 +16,20 @@ module Umlaut::ControllerBehavior
|
|
16
16
|
UmlautConfigurable.set_default_configuration!(controller.umlaut_config)
|
17
17
|
end
|
18
18
|
|
19
|
+
protected
|
20
|
+
|
21
|
+
# Returns a Collection object with currently configured services.
|
22
|
+
# Loads from Rails.root/config/umlaut_services.yml
|
23
|
+
#
|
24
|
+
# Local app can in theory override in local UmlautController to have
|
25
|
+
# different custom behavior for calculating the collection, but this
|
26
|
+
# is not entirely tested yet.
|
27
|
+
def create_collection
|
28
|
+
# trim out ones with disabled:true
|
29
|
+
services = ServiceStore.config["default"]["services"].reject {|id, hash| hash && hash["disabled"] == true}
|
30
|
+
|
31
|
+
return Collection.new(@user_request, services)
|
32
|
+
end
|
33
|
+
|
19
34
|
|
20
35
|
end
|
@@ -18,6 +18,10 @@ module SfxDb
|
|
18
18
|
def readonly?()
|
19
19
|
return true
|
20
20
|
end
|
21
|
+
|
22
|
+
# ActiveRecord likes it when we tell it this is an abstract
|
23
|
+
# class only.
|
24
|
+
self.abstract_class = true
|
21
25
|
|
22
26
|
# Atttempts to extract all URLs that SFX knows about from the db.
|
23
27
|
# This process is not 100%, becuase of the way SFX calculates URLs
|
@@ -0,0 +1,106 @@
|
|
1
|
+
namespace :umlaut do
|
2
|
+
|
3
|
+
desc "Migrate permalinks from an umlaut 2.x installation"
|
4
|
+
task :migrate_permalinks, [:connection] => [:environment] do |t,args|
|
5
|
+
old_connection_name = args[:connection] || "umlaut2_source"
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'activerecord-import'
|
9
|
+
ar_import = true
|
10
|
+
rescue LoadError
|
11
|
+
ar_import = false
|
12
|
+
end
|
13
|
+
|
14
|
+
# Turn off all caching we can think of with AR, cause it's gonna
|
15
|
+
# take too much memory!
|
16
|
+
IdentityMap.enabled = false
|
17
|
+
|
18
|
+
|
19
|
+
unless ActiveRecord::Base.configurations[old_connection_name]
|
20
|
+
raise Exception.new("You must have a connection for '#{old_connection_name}' configured in database.yml, pointing to the Umlaut 2.x source db.")
|
21
|
+
end
|
22
|
+
|
23
|
+
puts "\nWARNING: We will delete all existing permalinks from the '#{Rails.env}' database:"
|
24
|
+
puts " " + {}.merge(Permalink.connection_config).inspect
|
25
|
+
print "Sure you want to continue? (yes to continue) "
|
26
|
+
continue = $stdin.gets
|
27
|
+
raise Exception.new("Cancelled by user") unless continue.chomp == "yes"
|
28
|
+
|
29
|
+
Permalink.delete_all
|
30
|
+
|
31
|
+
# dynamically create a model for Permalinks in old
|
32
|
+
# db, set up with connection info to old db.
|
33
|
+
OldPermalink = Class.new(ActiveRecord::Base) do
|
34
|
+
self.set_table_name("permalinks")
|
35
|
+
# just to be safe
|
36
|
+
def read_only?
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
# Can't include this line in dynamic class generation above,
|
41
|
+
# have to do it now that we have a constant assigned, for it
|
42
|
+
# to work.
|
43
|
+
OldPermalink.establish_connection old_connection_name.to_sym
|
44
|
+
|
45
|
+
puts "\nThis may take a while #{"(include activerecord-import gem for faster importing)" unless ar_import}...\n"
|
46
|
+
|
47
|
+
# Read all the old Permalinks in, write em out to new
|
48
|
+
# db, _with same primary key_ since PK is used for actual
|
49
|
+
# user-facing permalinks. We don't copy the Referent relationship,
|
50
|
+
# we just copy enough to recreate, context_obj_serialized.
|
51
|
+
could_not_migrate = {
|
52
|
+
:count => 0,
|
53
|
+
:highest_id => 0,
|
54
|
+
:latest_date => 0
|
55
|
+
}
|
56
|
+
bulk_queue = []
|
57
|
+
i = 0
|
58
|
+
OldPermalink.find_each(:batch_size => 20000) do |old_p|
|
59
|
+
i += 1
|
60
|
+
|
61
|
+
if old_p.context_obj_serialized.blank?
|
62
|
+
could_not_migrate[:count] += 1
|
63
|
+
count_not_migrate[:highest_id] = [count_not_migrate[:highest_id], old_p.id].max
|
64
|
+
could_not_migrate[:latest_date] = [could_not_migrate[:latest_date], old_p.created_on].max
|
65
|
+
else
|
66
|
+
new_p = Permalink.new
|
67
|
+
new_p.id = old_p.id # keep the id the same!
|
68
|
+
new_p.created_on = old_p.created_on # why not keep it the same?
|
69
|
+
new_p.orig_rfr_id = old_p.orig_rfr_id # why not
|
70
|
+
|
71
|
+
# the important thing to be able to actually resolve it
|
72
|
+
new_p.context_obj_serialized = old_p.context_obj_serialized
|
73
|
+
|
74
|
+
if ar_import
|
75
|
+
bulk_queue << new_p
|
76
|
+
else
|
77
|
+
new_p.save!
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
print(".") if i % 1000 == 0
|
82
|
+
|
83
|
+
if ar_import && i % 10000 == 0
|
84
|
+
print "+"
|
85
|
+
Permalink.import(bulk_queue, :validate => false, :timestamps => false)
|
86
|
+
bulk_queue.clear
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
unless bulk_queue.empty?
|
92
|
+
print "+"
|
93
|
+
Permalink.import(bulk_queue, :validate => false, :timestamps => false)
|
94
|
+
end
|
95
|
+
|
96
|
+
puts "\nDone."
|
97
|
+
|
98
|
+
if could_not_migrate[:count] > 0
|
99
|
+
puts "\n\nCould not migrate #{could_not_migrate[:count]} permalinks"
|
100
|
+
puts " Ending at permalink #{could_not_migrate[:highest_id]}, "
|
101
|
+
puts " created at #{could_not_migrate[:latest_date]}"
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/lib/umlaut/version.rb
CHANGED
data/lib/umlaut.rb
CHANGED
@@ -25,13 +25,14 @@ module Umlaut
|
|
25
25
|
# I don't entirely understand what's going on.
|
26
26
|
#config.eager_load_paths << File.join(self.root, "lib")
|
27
27
|
|
28
|
-
# This makes our rake tasks visible.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
28
|
+
# This makes our rake tasks visible. NOT NEEDED, tasks in lib/tasks
|
29
|
+
# are avail by default, this ends up doing a double load.
|
30
|
+
#rake_tasks do
|
31
|
+
# Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..'))) do
|
32
|
+
# Dir.glob(File.join('lib', 'tasks', '*.rake')).each do |railtie|
|
33
|
+
# load railtie
|
34
|
+
# end
|
35
|
+
# end
|
36
|
+
#end
|
36
37
|
end
|
37
38
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
# UMLAUT: mysql db with mysql2 adapter strongly recommended for Umlaut, in both
|
8
|
+
# production and development. sqlite3 has unclear semantics under threaded
|
9
|
+
# concurrency which umlaut uses, and in many cases simply does not work.
|
10
|
+
#
|
11
|
+
# A high (connection) pool setting is also, sadly, generally
|
12
|
+
# required at present.
|
13
|
+
#
|
14
|
+
# development:
|
15
|
+
# adapter: mysql2
|
16
|
+
# host:
|
17
|
+
# username:
|
18
|
+
# password:
|
19
|
+
# database:
|
20
|
+
# pool: 30
|
21
|
+
|
22
|
+
development:
|
23
|
+
adapter: mysql2
|
24
|
+
database: umlaut3_dev
|
25
|
+
pool: 30
|
26
|
+
timeout: 5000
|
27
|
+
username: umlaut_app
|
28
|
+
password: uu21
|
29
|
+
host: app01.mse.jhu.edu
|
30
|
+
|
31
|
+
# Warning: The database defined as "test" will be erased and
|
32
|
+
# re-generated from your development database when you run "rake".
|
33
|
+
# Do not set this db to the same as development or production.
|
34
|
+
test:
|
35
|
+
adapter: sqlite3
|
36
|
+
database: db/test.sqlite3
|
37
|
+
pool: 5
|
38
|
+
timeout: 5000
|
39
|
+
|
40
|
+
production:
|
41
|
+
adapter: sqlite3
|
42
|
+
database: db/production.sqlite3
|
43
|
+
pool: 5
|
44
|
+
timeout: 5000
|
45
|
+
|
46
|
+
|
47
|
+
umlaut2_source:
|
48
|
+
adapter: mysql2
|
49
|
+
host: app01.mse.jhu.edu
|
50
|
+
database: umlaut_production
|
51
|
+
username: umlaut_app
|
52
|
+
password: uu21
|
53
|
+
encoding: utf8
|