1 17 package org.columba.mail.spam.command; 18 19 import org.columba.api.command.ICommandReference; 20 import org.columba.api.command.IWorkerStatusController; 21 import org.columba.core.command.Command; 22 import org.columba.core.command.StatusObservableImpl; 23 import org.columba.core.logging.Logging; 24 import org.columba.mail.command.IMailFolderCommandReference; 25 import org.columba.mail.folder.IMailbox; 26 import org.columba.mail.spam.SpamController; 27 28 33 public class LearnMessageAsHamCommand extends Command { 34 35 private static final java.util.logging.Logger LOG = 36 java.util.logging.Logger.getLogger("org.columba.mail.spam.command"); 38 41 public LearnMessageAsHamCommand(ICommandReference reference) { 42 super(reference); 43 } 44 45 48 public void execute(IWorkerStatusController worker) throws Exception { 49 50 IMailFolderCommandReference r = (IMailFolderCommandReference) getReference(); 52 53 Object [] uids = r.getUids(); 55 56 IMailbox srcFolder = (IMailbox) r.getSourceFolder(); 58 59 ((StatusObservableImpl) srcFolder.getObservable()).setWorker(worker); 61 62 if (uids.length > 1) { 64 worker.setDisplayText("Training messages..."); 66 worker.setProgressBarMaximum(uids.length); 67 } 68 69 long startTime = System.currentTimeMillis(); 70 71 for (int j = 0; j < uids.length; j++) { 72 if (worker.cancelled()) { 73 break; 74 } 75 76 try { 77 78 SpamController.getInstance().trainMessageAsHam(srcFolder, 80 uids[j]); 81 82 if (uids.length > 1) { 83 worker.setProgressBarValue(j); 84 } 85 } catch (Exception e) { 86 if (Logging.DEBUG) { 87 e.printStackTrace(); 88 } 89 } 90 } 91 92 long endTime = System.currentTimeMillis(); 93 94 LOG.info("took me=" + (endTime - startTime) + "ms"); 96 } 97 } | Popular Tags |