]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/mv_runner.rb
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.')
16 src_description
= plugin
.describe_user(src
)
17 plugin
.mv_user(src
, dst
)
18 msg
= "Moved user #{src} (#{src_description}) "
21 rescue InvalidUserError
=> e
22 report(plugin
, e
.message
)
23 rescue NonexistentUserError
=> e
24 report(plugin
, e
.message
)
25 rescue NonexistentDomainError
=> e
26 report(plugin
, e
.message
)
27 rescue StandardError
=> e
28 msg
= "There was an error (#{e.to_s}) moving the user: #{e.message}"
30 Kernel
.exit(ExitCodes
::DATABASE_ERROR)