1 package org.columba.mail.gui.message.command; 17 18 import java.io.File ; 19 import java.util.logging.Logger ; 20 21 import org.columba.api.command.ICommandReference; 22 import org.columba.api.command.IWorkerStatusController; 23 import org.columba.core.base.Semaphore; 24 import org.columba.core.util.TempFileStore; 25 import org.columba.ristretto.message.MimeHeader; 26 27 28 33 public class SaveAttachmentTemporaryCommand extends SaveAttachmentCommand { 34 35 private static final Logger LOG = Logger.getLogger("org.columba.mail.gui.message.attachment.command"); 36 37 38 private File tempAttachmentFile; 39 40 private Semaphore commandSemaphore; 41 42 45 public SaveAttachmentTemporaryCommand(ICommandReference reference) { 46 super(reference); 47 commandSemaphore = new Semaphore(true); 48 } 49 50 51 protected File getDestinationFile(MimeHeader header) { 52 53 tempAttachmentFile = null; 54 String filename = getFilename(header); 55 if (filename != null) { 56 tempAttachmentFile = TempFileStore.createTempFile(filename); 57 } 58 return tempAttachmentFile; 59 } 60 61 62 public void execute(IWorkerStatusController worker) throws Exception { 63 super.execute(worker); 64 commandSemaphore.release(); 65 } 66 67 72 public File getTempAttachmentFile() { 73 return tempAttachmentFile; 74 } 75 76 79 public void waitForCommandToComplete() { 80 try { 81 commandSemaphore.waitUntilReleased(); 82 } catch (InterruptedException e) { 83 LOG.warning("The thread waiting for the Save Attachment Temporary command was interrupted."); 84 } 85 } 86 } 87 | Popular Tags |