]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/mailshears/plugins/dovecot_mailstore.rb
Factor out common code that can be used to mv (rename) accounts.
[mailshears.git] / lib / mailshears / plugins / dovecot_mailstore.rb
index 965d2d293a5047252287ea1722f8e7c40278fc58..635d6efe6ffed1e10a5031f3018e9558fefa827d 100644 (file)
@@ -1,17 +1,19 @@
 # Needed for rm_rf.
 require 'fileutils'
 
-require 'mailshears/errors'
-require 'mailshears/filesystem'
-require 'mailshears/mailstore'
-require 'mailshears/plugin'
+require 'common/filesystem'
+require 'common/mailstore'
+require 'common/plugin'
+require 'mailshears/rm_plugin'
 
 class DovecotMailstore < Mailstore
 
   include Plugin
+  include RmPlugin
 
   def initialize
-    @domain_root = Configuration::mail_root
+    cfg = Configuration.new()
+    @domain_root = cfg.mail_root
   end
 
   def describe_domain(domain)
@@ -19,7 +21,7 @@ class DovecotMailstore < Mailstore
       domain_path = get_domain_path(domain)
       return domain_path
     rescue NonexistentDomainError => e
-      return "Doesn't Exist"
+      return "Doesn't exist: #{e.to_s}"
     end
   end
 
@@ -28,7 +30,7 @@ class DovecotMailstore < Mailstore
       account_path = get_account_path(account)
       return account_path
     rescue NonexistentAccountError => e
-      return "Doesn't Exist"
+      return "Doesn't exist: #{e.to_s}"
     end
   end
 
@@ -79,7 +81,7 @@ class DovecotMailstore < Mailstore
         usernames.each do |username|
           accounts << "#{username}@#{domain}"
         end
-      rescue NonexistentDomainError => e
+      rescue NonexistentDomainError
         # Party hard.
       end
     end
@@ -97,7 +99,7 @@ class DovecotMailstore < Mailstore
     if File.directory?(domain_path)
       return domain_path
     else
-      raise NonexistentDomainError
+      raise NonexistentDomainError.new(domain)
     end
   end
 
@@ -116,7 +118,7 @@ class DovecotMailstore < Mailstore
     begin
       domain_path = get_domain_path(domain_part)
     rescue NonexistentDomainError
-      raise NonexistentAccountError
+      raise NonexistentAccountError.new(account)
     end
 
     account_path = File.join(domain_path, user_part)
@@ -124,7 +126,7 @@ class DovecotMailstore < Mailstore
     if File.directory?(account_path)
       return account_path
     else
-      raise NonexistentAccountError
+      raise NonexistentAccountError(account)
     end
   end