]>
gitweb.michael.orlitzky.com - mailshears.git/blob - lib/mv/mv_runner.rb
1 require 'common/domain'
2 require 'common/errors'
3 require 'common/runner'
8 def run(plugin
, src
, dst
)
10 if src
.is_a
?(Domain
) or dst
.is_a
?(Domain
) then
11 msg
= 'only users can be moved'
12 raise NotImplementedError
.new(msg
)
16 src_description
= plugin
.describe(src
)
17 plugin
.mv_user(src
, dst
)
18 dst_description
= plugin
.describe(dst
)
20 msg
= "Moved user #{src} "
22 # Only append the extra description if it's useful.
23 if not src_description
.nil? and
24 not src_description
.empty
? and
25 not src_description
== src
.to_s() then
26 msg +
= "(#{src_description}) "
31 # Only append the extra description if it's useful.
32 if not dst_description
.nil? and
33 not dst_description
.empty
? and
34 not dst_description
== dst
.to_s() then
35 msg +
= " (#{dst_description})"
41 rescue NonexistentUserError
=> e
42 # This means that the SOURCE user didn't exist, since a
43 # nonexistent destination user is perfectly expected.
44 report(plugin
, "Source user #{src.to_s()} not found.")
45 rescue NonexistentDomainError
=> e
46 # This could mean that the source domain doesn't exist, but in
47 # that case, we just report that the source user doesn't
48 # exist. So a nonexistent domain refers to a nonexistent
50 report(plugin
, "Destination domain #{dst.domainpart()} not found.")
51 rescue UserAlreadyExistsError
=> e
52 report(plugin
, "Destination user #{dst.to_s()} already exists.")