1 22 package org.objectweb.petals.jbi.management.deployment.deploy; 23 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.net.URI ; 27 import java.util.HashMap ; 28 29 import org.apache.commons.io.FileUtils; 30 import org.objectweb.petals.jbi.management.deployment.DeploymentContextConstants; 31 import org.objectweb.petals.jbi.management.deployment.DeploymentUtils; 32 import org.objectweb.petals.processor.Task; 33 import org.objectweb.petals.util.LoggingUtil; 34 35 41 public class CopyArchiveToInstalledDirTask implements Task { 42 43 46 protected LoggingUtil log; 47 48 public CopyArchiveToInstalledDirTask(LoggingUtil log) { 49 super(); 50 this.log = log; 51 } 52 53 public void execute(HashMap context) throws Exception { 54 URI saArchiveURI = (URI ) context 55 .get(DeploymentContextConstants.ARCHIVE_URI); 56 57 File file = DeploymentUtils.getArchiveFile(saArchiveURI); 58 File installedArchive = DeploymentUtils.getInstalledArchive(file); 59 60 FileUtils.copyFile(file, installedArchive); 61 62 } 63 64 public void undo(HashMap context) { 65 URI saArchiveURI = (URI ) context 66 .get(DeploymentContextConstants.ARCHIVE_URI); 67 68 File file = DeploymentUtils.getArchiveFile(saArchiveURI); 69 File installedArchive = DeploymentUtils.getInstalledArchive(file); 70 71 try { 72 FileUtils.forceDelete(installedArchive); 73 } catch (IOException e) { 74 String msg = "Failed to revert a CopyArchiveToInstalledDirTask"; 75 log.error(msg, e); 76 } 77 78 } 79 80 } 81 | Popular Tags |