]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/mv_runner.rb
ee762e1e70cf4198c1630b3404973d20c75ac264
1 require 'common/errors'
2 require 'common/runner'
7 def run(plugin
, src
, dst
)
8 # Why think too hard? An user has an @, a domain doesn't.
9 if not src
.include?('@') then
10 # We only support moving users right now, and the destination
11 # domain must already exist.
12 raise NotImplementedError
.new('Only users can be moved.')
15 # Handle this once so we don't have to do it in every plugin.
16 if not dst
.include?('@') then
17 msg
= "the destination user #{dst} is not valid"
18 raise InvalidUserError
.new(msg
)
22 src_description
= plugin
.describe_user(src
)
23 plugin
.mv_user(src
, dst
)
24 msg
= "Moved user #{src} (#{src_description}) "
27 rescue InvalidUserError
=> e
28 report(plugin
, e
.message
)
29 rescue NonexistentUserError
=> e
30 report(plugin
, e
.message
)
31 rescue NonexistentDomainError
=> e
32 report(plugin
, e
.message
)
33 rescue StandardError
=> e
34 msg
= "There was an error (#{e.to_s}) moving the user: #{e.message}"
36 Kernel
.exit(ExitCodes
::DATABASE_ERROR)