You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2006/09/05 21:14:26 UTC

svn commit: r440446 - in /james/server/trunk/src/java/org/apache/james: management/ remotemanager/ services/

Author: norman
Date: Tue Sep  5 12:14:25 2006
New Revision: 440446

URL: http://svn.apache.org/viewvc?view=rev&rev=440446
Log:
Add jmx support for BayesianAnalyzerManagement and some refactoring. Thx Bernd for the patch. See JAMES-590

Added:
    james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagementMBean.java
Modified:
    james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.java
    james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.xinfo
    james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
    james/server/trunk/src/java/org/apache/james/services/BayesianAnalyzerManagementService.java

Modified: james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.java?view=diff&rev=440446&r1=440445&r2=440446
==============================================================================
--- james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.java (original)
+++ james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.java Tue Sep  5 12:14:25 2006
@@ -30,7 +30,9 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
+import java.io.InputStream;
 import java.sql.SQLException;
+import java.sql.Connection;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -58,7 +60,7 @@
 /**
  * Management for BayesianAnalyzer
  */
-public class BayesianAnalyzerManagement implements BayesianAnalyzerManagementService, Serviceable, Initializable, Contextualizable, Configurable {
+public class BayesianAnalyzerManagement implements BayesianAnalyzerManagementService, Serviceable, Initializable, Contextualizable, Configurable, BayesianAnalyzerManagementMBean {
 
     private final static String HAM = "HAM";
     private final static String SPAM = "SPAM";
@@ -134,7 +136,7 @@
     /**
      * @see org.apache.james.services.BayesianAnalyzerManagementService#addHamFromDir(String)
      */
-    public int addHamFromDir(String dir) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException {
+    public int addHamFromDir(String dir) throws BayesianAnalyzerManagementException {
         if (repos == null) throw new BayesianAnalyzerManagementException("RepositoryPath not configured");
         
         return feedBayesianAnalyzerFromDir(dir,HAM);
@@ -143,7 +145,7 @@
     /**
      * @see org.apache.james.services.BayesianAnalyzerManagementService#addSpamFromDir(String)
      */
-    public int addSpamFromDir(String dir) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException {
+    public int addSpamFromDir(String dir) throws BayesianAnalyzerManagementException {
         if (repos == null) throw new BayesianAnalyzerManagementException("RepositoryPath not configured");
         
         return feedBayesianAnalyzerFromDir(dir,SPAM);
@@ -152,7 +154,7 @@
     /**
      * @see org.apache.james.services.BayesianAnalyzerManagementService#addHamFromMbox(String)
      */
-    public int addHamFromMbox(String file) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException {
+    public int addHamFromMbox(String file) throws BayesianAnalyzerManagementException {
         if (repos == null) throw new BayesianAnalyzerManagementException("RepositoryPath not configured");
         return feedBayesianAnalyzerFromMbox(file,HAM);
     }
@@ -160,7 +162,7 @@
     /**
      * @see org.apache.james.services.BayesianAnalyzerManagementService#addSpamFromMbox(String)
      */
-    public int addSpamFromMbox(String file) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException {
+    public int addSpamFromMbox(String file) throws BayesianAnalyzerManagementException {
         if (repos == null) throw new BayesianAnalyzerManagementException("RepositoryPath not configured");
         return feedBayesianAnalyzerFromMbox(file,SPAM);
     }
@@ -171,50 +173,83 @@
      * @param dir The directory which contains the emails which should be used to feed the BayesianAnalysis
      * @param type The type to train. HAM or SPAM
      * @return count The count of trained messages
-     * @throws IOException 
-     * @throws FileNotFoundException 
-     * @throws SQLException 
+     * @throws BayesianAnalyzerManagementException
      * @throws IllegalArgumentException Get thrown if the directory is not valid
      */
-    private int feedBayesianAnalyzerFromDir(String dir, String type) throws FileNotFoundException, IOException, SQLException, IllegalArgumentException {
-    
+    private int feedBayesianAnalyzerFromDir(String dir, String type) throws BayesianAnalyzerManagementException {
+
         //Clear out any existing word/counts etc..
         analyzer.clear();
-        
+
         File tmpFile = new File(dir);
         int count = 0;
-        
+
         synchronized(JDBCBayesianAnalyzer.DATABASE_LOCK) {
 
             // check if the provided dir is really a directory
             if (tmpFile.isDirectory()) {
                 File[] files = tmpFile.listFiles();
-        
+
                 for (int i = 0; i < files.length; i++) {
-                    if (type.equalsIgnoreCase(HAM)) {
-                        analyzer.addHam(new BufferedReader(new FileReader(files[i])));
-                        count++;
-                    } else if (type.equalsIgnoreCase(SPAM)) {
-                        analyzer.addSpam(new BufferedReader(new FileReader(files[i])));
-                        count++;
-                    }  
+                    BufferedReader stream = null;
+                    try {
+                        stream = new BufferedReader(new FileReader(files[i]));
+                    } catch (FileNotFoundException e) {
+                        throw new BayesianAnalyzerManagementException("acessing mail file failed.", e);
+                    }
+                    addMailToCorpus(type, stream);
+                    count++;
                 }
-              
-                //Update storage statistics.
-                if (type.equalsIgnoreCase(HAM)) {
-                    analyzer.updateHamTokens(component.getConnection());
-                } else if (type.equalsIgnoreCase(SPAM)) {
-                    analyzer.updateSpamTokens(component.getConnection());
-                } 
-    
+
+                updateTokens(type);
+
             } else {
                throw new IllegalArgumentException("Please provide an valid directory");
             }
         }
-        
+
         return count;
     }
-    
+
+    /**
+     * Update the tokens 
+     * 
+     * @param type The type whichs tokens should be updated. Valid types are HAM or SPAM
+     * @throws BayesianAnalyzerManagementException
+     */
+    private void updateTokens(String type) throws BayesianAnalyzerManagementException {
+        //Update storage statistics.
+        try {
+            Connection connection = component.getConnection();
+            if (type.equalsIgnoreCase(HAM)) {
+                analyzer.updateHamTokens(connection);
+            } else if (type.equalsIgnoreCase(SPAM)) {
+                analyzer.updateSpamTokens(connection);
+            }
+        } catch (SQLException e) {
+            throw new BayesianAnalyzerManagementException("updating tokens failed.", e);
+        }
+    }
+
+    /**
+     * Add mail to corpus 
+     * 
+     * @param type The type to add to corpus. Valid types are HAM or SPAM
+     * @param stream The stream which is used to transfer the data
+     * @throws BayesianAnalyzerManagementException
+     */
+    private void addMailToCorpus(String type, BufferedReader stream) throws BayesianAnalyzerManagementException {
+        try {
+            if (type.equalsIgnoreCase(HAM)) {
+                analyzer.addHam(stream);
+            } else if (type.equalsIgnoreCase(SPAM)) {
+                analyzer.addSpam(stream);
+            }
+        } catch (IOException e) {
+            throw new BayesianAnalyzerManagementException("adding to corpus failed.", e);
+        }
+    }
+
 
     /**
      * Helper method to train the BayesianAnalysis from mbox file
@@ -222,65 +257,75 @@
      * @param mboxFile The mbox file
      * @param type The type to train. HAM or SPAM
      * @return count The count of trained messages
-     * @throws IOException 
-     * @throws FileNotFoundException 
-     * @throws SQLException 
-     * @throws IllegalArgumentException Get thrown if the file is not a valid mbox file
+     * @throws BayesianAnalyzerManagementException
      */
-    private int feedBayesianAnalyzerFromMbox(String mboxFile, String type) throws FileNotFoundException, IOException, SQLException, IllegalArgumentException {
+    private int feedBayesianAnalyzerFromMbox(String mboxFile, String type) throws BayesianAnalyzerManagementException {
         int count = 0;
-        
+
         //Clear out any existing word/counts etc..
         analyzer.clear();
-        
+
         File tmpFile = new File(mboxFile);
-        
-        if (MboxFile.isValid(tmpFile) == true ) { 
+
+        if (MboxFile.isValid(tmpFile)) {
             MboxFile mbox = new MboxFile(tmpFile,MboxFile.READ_ONLY);
-        
+
             synchronized(JDBCBayesianAnalyzer.DATABASE_LOCK) {
-                for (int i = 0; i < mbox.getMessageCount(); i++) {
-                    if (type.equalsIgnoreCase(HAM)) {
-                
-                        analyzer.addHam(new BufferedReader(new InputStreamReader(mbox.getMessageAsStream(i))));
-                        count++;
-                    } else if (type.equalsIgnoreCase(SPAM)) {
-                        analyzer.addSpam(new BufferedReader(new InputStreamReader(mbox.getMessageAsStream(i))));
-                        count++;
-                    }  
+                int messageCount = 0;
+                try {
+                    messageCount = mbox.getMessageCount();
+                } catch (IOException e) {
+                    throw new BayesianAnalyzerManagementException(e);
                 }
-              
+                for (int i = 0; i < messageCount; i++) {
+                    InputStream message = null;
+                    try {
+                        message = mbox.getMessageAsStream(i);
+                    } catch (IOException e) {
+                        throw new BayesianAnalyzerManagementException("could not access mail from mbox streanm", e);
+                    }
+                    BufferedReader stream = new BufferedReader(new InputStreamReader(message));
+                    addMailToCorpus(type, stream);
+                    count++;
+                }
+
                 //Update storage statistics.
-                if (type.equalsIgnoreCase(HAM)) {
-                    analyzer.updateHamTokens(component.getConnection());
-                } else if (type.equalsIgnoreCase(SPAM)) {
-                    analyzer.updateSpamTokens(component.getConnection());
-                } 
+                updateTokens(type);
             }
         } else {
             throw new IllegalArgumentException("Please provide an valid mbox file");
         }
-        
+
         return count;
     }
     
     /**
      * @see org.apache.james.services.BayesianAnalyzerManagementService#exportData(String)
      */
-    public void exportData(String file) throws IOException, BayesianAnalyzerManagementException, SQLException {
+    public void exportData(String file) throws BayesianAnalyzerManagementException {
         if (repos == null) throw new BayesianAnalyzerManagementException("RepositoryPath not configured");
-    
-        synchronized(JDBCBayesianAnalyzer.DATABASE_LOCK) {    
-            analyzer.loadHamNSpam(component.getConnection());
-        
+
+        synchronized(JDBCBayesianAnalyzer.DATABASE_LOCK) {
+            try {
+                analyzer.loadHamNSpam(component.getConnection());
+            } catch (SQLException e) {
+                throw new BayesianAnalyzerManagementException("loading ham and spam failed.", e);
+            }
+
             int hamMessageCount = analyzer.getHamMessageCount();
             int spamMessageCount = analyzer.getSpamMessageCount();
             Map hamTokenCounts = analyzer.getHamTokenCounts();
             Map spamTokenCounts = analyzer.getSpamTokenCounts();
-            
+
             XStream xstream = new XStream(new DomDriver());
             xstream.alias("bayesianAnalyzer", BayesianAnalyzerXml.class);
-            PrintWriter printwriter = new PrintWriter(new FileOutputStream(file));
+            FileOutputStream fileOutputStream = null;
+            try {
+                fileOutputStream = new FileOutputStream(file);
+            } catch (FileNotFoundException e) {
+                throw new BayesianAnalyzerManagementException("opening export file failed", e);
+            }
+            PrintWriter printwriter = new PrintWriter(fileOutputStream);
             printwriter.println(xstream.toXML(new BayesianAnalyzerXml(hamMessageCount,spamMessageCount,hamTokenCounts,spamTokenCounts)));
             printwriter.close();
         }
@@ -289,29 +334,35 @@
     /**
      * @see org.apache.james.services.BayesianAnalyzerManagementService#importData(String)
      */
-    public void importData(String file) throws IOException, BayesianAnalyzerManagementException, SQLException, FileNotFoundException {
-    if (repos == null) throw new BayesianAnalyzerManagementException("RepositoryPath not configured");
+    public void importData(String file) throws BayesianAnalyzerManagementException {
+        if (repos == null) throw new BayesianAnalyzerManagementException("RepositoryPath not configured");
 
         synchronized(JDBCBayesianAnalyzer.DATABASE_LOCK){
             XStream xstream = new XStream(new DomDriver());
-            
-            BayesianAnalyzerXml bAnalyzerXml = (BayesianAnalyzerXml) xstream.fromXML(new FileReader(file));
-        
+
+            FileReader fileReader = null;
+            try {
+                fileReader = new FileReader(file);
+            } catch (FileNotFoundException e) {
+                throw new BayesianAnalyzerManagementException("opening input file failed", e);
+            }
+            BayesianAnalyzerXml bAnalyzerXml = (BayesianAnalyzerXml) xstream.fromXML(fileReader);
+
             // clear old data
             analyzer.clear();
             analyzer.tokenCountsClear();
-            
+
             //TODO: Drop old corpus in database;
-            
+
             // add the new data
             analyzer.setHamMessageCount(bAnalyzerXml.getHamMessageCount());
             analyzer.setSpamMessageCount(bAnalyzerXml.getSpamMessageCount());
             analyzer.setHamTokenCounts(bAnalyzerXml.getHamTokenCounts());
             analyzer.setSpamTokenCounts(bAnalyzerXml.getSpamTokenCounts());
-            analyzer.updateHamTokens(component.getConnection());
-            analyzer.updateSpamTokens(component.getConnection());
+            updateTokens(HAM);
+            updateTokens(SPAM);
         }
-        
+
     }
     
     private JDBCBayesianAnalyzer analyzer = new JDBCBayesianAnalyzer() {

Modified: james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.xinfo
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.xinfo?view=diff&rev=440446&r1=440445&r2=440446
==============================================================================
--- james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.xinfo (original)
+++ james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagement.xinfo Tue Sep  5 12:14:25 2006
@@ -11,6 +11,11 @@
     <service name="org.apache.james.services.BayesianAnalyzerManagementService" version="1.0" />
   </services>
   
+  <!-- interfaces that may be exported to manange this block -->
+  <management-access-points>
+    <service name="org.apache.james.management.BayesianAnalyzerManagementMBean"/>
+  </management-access-points>
+
   <dependencies>
     <dependency>
       <service name="org.apache.avalon.cornerstone.services.datasources.DataSourceSelector" version="1.0"/>

Added: james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagementMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagementMBean.java?view=auto&rev=440446
==============================================================================
--- james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagementMBean.java (added)
+++ james/server/trunk/src/java/org/apache/james/management/BayesianAnalyzerManagementMBean.java Tue Sep  5 12:14:25 2006
@@ -0,0 +1,85 @@
+package org.apache.james.management;
+
+/**
+ * Expose spool management functionality through JMX.
+ *
+ * @phoenix:mx-topic name="BayesianAnalyzerAdministration"
+ */
+public interface BayesianAnalyzerManagementMBean {
+
+    /**
+     * adds data to existing corpus by importing all the mails contained in the given dir as ham
+     *
+     * @phoenix:mx-operation
+     * @phoenix:mx-description adds data to existing corpus by importing all the mails contained in the given dir as ham
+     *
+     * @param dir full path to the directory containing mail files
+     * @return number of processes mails
+     *
+     * @throws BayesianAnalyzerManagementException
+     */
+    int addHamFromDir(String dir) throws BayesianAnalyzerManagementException;
+
+    /**
+     * adds data to existing corpus by importing all the mails contained in the given dir as spam
+     *
+     * @phoenix:mx-operation
+     * @phoenix:mx-description adds data to existing corpus by importing all the mails contained in the given dir as spam
+     *
+     * @param dir full path to the directory containing mail files
+     * @return number of processes mails
+     *
+     * @throws BayesianAnalyzerManagementException
+     */
+    int addSpamFromDir(String dir) throws BayesianAnalyzerManagementException;
+
+    /**
+     * adds data to existing corpus by importing all the mails contained in the given mbox as ham
+     *
+     * @phoenix:mx-operation
+     * @phoenix:mx-description adds data to existing corpus by importing all the mails contained in the given mbox as ham
+     *
+     * @param file path to the mbox file
+     * @return number of processes mails
+     *
+     * @throws BayesianAnalyzerManagementException
+     */
+    int addHamFromMbox(String file) throws BayesianAnalyzerManagementException;
+
+    /**
+     * adds data to existing corpus by importing all the mails contained in the given mbox as spam
+     *
+     * @phoenix:mx-operation
+     * @phoenix:mx-description adds data to existing corpus by importing all the mails contained in the given mbox as spam
+     *
+     * @param file path to the mbox file
+     * @return number of processes mails
+     *
+     * @throws BayesianAnalyzerManagementException
+     */
+    int addSpamFromMbox(String file) throws BayesianAnalyzerManagementException;
+
+    /**
+     * exports the corpus to a file
+     *
+     * @phoenix:mx-operation
+     * @phoenix:mx-description exports the corpus to a file
+     *
+     * @param file path to the mbox file
+     *
+     * @throws BayesianAnalyzerManagementException
+     */
+    void exportData(String file) throws BayesianAnalyzerManagementException;
+
+    /**
+     * imports the corpus from a file
+     *
+     * @phoenix:mx-operation
+     * @phoenix:mx-description imports the corpus from a file
+     *
+     * @param file path to the mbox file
+     *
+     * @throws BayesianAnalyzerManagementException
+     */
+    void importData(String file) throws BayesianAnalyzerManagementException;
+}

Modified: james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java?view=diff&rev=440446&r1=440445&r2=440446
==============================================================================
--- james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java (original)
+++ james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java Tue Sep  5 12:14:25 2006
@@ -21,10 +21,8 @@
 
 package org.apache.james.remotemanager;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.Socket;
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -1095,7 +1093,6 @@
      *            the argument passed in with the command
      */
     private boolean doADDHAM(String argument) {
-        String exception = null;
         String [] args = null;
         int count = 0;
         
@@ -1125,27 +1122,15 @@
             out.println("Feed the BayesianAnalysis with " + count + " HAM");
             out.flush();
         
-        } catch (SQLException e) {
-            exception = e.getMessage();
-        } catch (FileNotFoundException e) {
-            exception = e.getMessage();
-        } catch (IllegalArgumentException e) {
-            exception = e.getMessage();
-        } catch (IOException e) {
-            exception = e.getMessage();
         } catch (BayesianAnalyzerManagementException e) {
-            writeLoggedFlushedResponse("Command disabled. Configure BayesianAnalyzerMangement to enable it");    
+            getLogger().error("Error on feeding BayesianAnalysis: " + e);
+            out.println("Error on feeding BayesianAnalysis: " + e);
+            out.flush();
             return true;
-        } finally {          
+        } finally {
             theWatchdog.start();
         }
     
-        // check if any exception was thrown
-        if (exception != null) {
-            getLogger().error("Error on feeding BayesianAnalysis: " + exception);
-            out.println("Error on feeding BayesianAnalysis: " + exception);
-            out.flush();
-        }
         return true;
     }
     
@@ -1157,7 +1142,6 @@
      *            the argument passed in with the command
      */
     private boolean doADDSPAM(String argument) {
-        String exception = null;
         String [] args = null;
         int count = 0;
         
@@ -1186,35 +1170,21 @@
             out.println("Feed the BayesianAnalysis with " + count + " SPAM");
             out.flush();
             
-        } catch (SQLException e) {
-            exception = e.getMessage();
-        } catch (FileNotFoundException e) {
-            exception = e.getMessage();
-        } catch (IllegalArgumentException e) {
-            exception = e.getMessage();
-        } catch (IOException e) {
-            exception = e.getMessage();
         } catch (BayesianAnalyzerManagementException e) {
-            writeLoggedFlushedResponse("Command disabled. Configure BayesianAnalyzerMangement to enable it");    
+            getLogger().error("Error on feeding BayesianAnalysis: " + e);
+            out.println("Error on feeding BayesianAnalysis: " + e);
+            out.flush();
             return true;
-        } finally {          
+        } finally {
             theWatchdog.start();
         }
     
-        // check if any exception was thrown
-        if (exception != null) {
-            getLogger().error("Error on feeding BayesianAnalysis: " + exception);
-            out.println("Error on feeding BayesianAnalysis: " + exception);
-            out.flush();
-        }
         return true;
     }
     
    
     
     private boolean doEXPORTBAYESIANDATA(String argument) {
-        String exception = null;
-
         // check if the command was called correct
         if (argument == null || argument.trim().equals("")) {
             writeLoggedFlushedResponse("Usage: EXPORTBAYESIANALYZERDATA [dir]");
@@ -1230,33 +1200,20 @@
             out.println("Exported the BayesianAnalysis data");
             out.flush();
 
-        } catch (SQLException e) {
-            exception = e.getMessage();
-        } catch (FileNotFoundException e) {
-            exception = e.getMessage();
-        } catch (IllegalArgumentException e) {
-            exception = e.getMessage();
-        } catch (IOException e) {
-            exception = e.getMessage();
         } catch (BayesianAnalyzerManagementException e) {
-            writeLoggedFlushedResponse("Command disabled. Configure BayesianAnalyzerMangement to enable it");    
-            return true;
-        } finally {          
+            getLogger().error("Error on exporting BayesianAnalysis data: " + e);
+            out.println("Error on exporting BayesianAnalysis data: " + e);
+            out.flush();
+            return false;
+        } finally {
             theWatchdog.start();
         }
     
         // check if any exception was thrown
-        if (exception != null) {
-            getLogger().error("Error on exporting BayesianAnalysis data: " + exception);
-            out.println("Error on exporting BayesianAnalysis data: " + exception);
-            out.flush();
-        }
         return true;
     }
     
     private boolean doIMPORTBAYESIANDATA(String argument) {
-        String exception = null;
-
         // check if the command was called correct
         if (argument == null || argument.trim().equals("")) {
             writeLoggedFlushedResponse("Usage: IMPORTBAYESIANALYZERDATA [dir]");
@@ -1272,27 +1229,15 @@
             out.println("Imported the BayesianAnalysis data");
             out.flush();
 
-        } catch (SQLException e) {
-            exception = e.getMessage();
-        } catch (FileNotFoundException e) {
-            exception = e.getMessage();
-        } catch (IllegalArgumentException e) {
-            exception = e.getMessage();
-        } catch (IOException e) {
-            exception = e.getMessage();
         } catch (BayesianAnalyzerManagementException e) {
-            writeLoggedFlushedResponse("Command disabled. Configure BayesianAnalyzerMangement to enable it");    
-            return true;
-        } finally {          
+            getLogger().error("Error on importing BayesianAnalysis data: " + e);
+            out.println("Error on importing BayesianAnalysis data: " + e);
+            out.flush();
+            return false;
+        } finally {
             theWatchdog.start();
         }
     
-        // check if any exception was thrown
-        if (exception != null) {
-            getLogger().error("Error on importing BayesianAnalysis data: " + exception);
-            out.println("Error on imporitng BayesianAnalysis data: " + exception);
-            out.flush();
-        }
         return true;
     }
 }

Modified: james/server/trunk/src/java/org/apache/james/services/BayesianAnalyzerManagementService.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/services/BayesianAnalyzerManagementService.java?view=diff&rev=440446&r1=440445&r2=440446
==============================================================================
--- james/server/trunk/src/java/org/apache/james/services/BayesianAnalyzerManagementService.java (original)
+++ james/server/trunk/src/java/org/apache/james/services/BayesianAnalyzerManagementService.java Tue Sep  5 12:14:25 2006
@@ -42,7 +42,7 @@
      * @throws SQLException
      * @throws BayesianAnalyzerManagementException If the service is not configured
      */
-    public int addSpamFromDir(String dir) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException;
+    public int addSpamFromDir(String dir) throws BayesianAnalyzerManagementException;
     
     /**
      * Feed the BayesianAnalyzer with ham. The given directory  contain the mail files
@@ -55,7 +55,7 @@
      * @throws SQLException
      * @throws BayesianAnalyzerManagementException If the service is not configured
      */
-    public int addHamFromDir(String dir) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException;
+    public int addHamFromDir(String dir) throws  BayesianAnalyzerManagementException;
     
     /**
      * Feed the BayesianAnalyzer with ham. The given file must be a valid mbox file
@@ -68,7 +68,7 @@
      * @throws SQLException
      * @throws BayesianAnalyzerManagementException If the service is not configured
      */
-    public int addSpamFromMbox(String file) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException;
+    public int addSpamFromMbox(String file) throws  BayesianAnalyzerManagementException;
     
     /**
      * Feed the BayesianAnalyzer with ham. The given file must be a valid mbox file
@@ -81,7 +81,7 @@
      * @throws SQLException
      * @throws BayesianAnalyzerManagementException If the service is not configured
      */
-    public int addHamFromMbox(String file) throws FileNotFoundException, IllegalArgumentException, IOException, SQLException, BayesianAnalyzerManagementException;
+    public int addHamFromMbox(String file) throws BayesianAnalyzerManagementException;
 
     /**
      * Export the data to a xml file
@@ -91,7 +91,7 @@
      * @throws BayesianAnalyzerManagementException If the service is not configured
      * @throws SQLException
      */
-    public void exportData(String file) throws IOException, BayesianAnalyzerManagementException, SQLException;
+    public void exportData(String file) throws BayesianAnalyzerManagementException;
     
     /**
      * Import the data from a xml file
@@ -102,5 +102,5 @@
      * @throws BayesianAnalyzerManagementException IF the service is not configured
      * @throws SQLException
      */
-    public void importData(String file) throws IOException, BayesianAnalyzerManagementException, SQLException;
+    public void importData(String file) throws  BayesianAnalyzerManagementException;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org