public function undeployArchive(ContainerNodeInterface $containerNode, \SplFileInfo $archive)
{
try {
// create webapp folder name based on the archive's basename
$webappFolderName = new \SplFileInfo($this->getWebappsDir($containerNode, basename($archive->getFilename(), $this->getExtensionSuffix())));
// check if app has to be undeployed
if ($this->isUndeployable($archive) && $webappFolderName->isDir()) {
// flag webapp as undeploing
$this->flagArchive($archive, ExtractorInterface::FLAG_UNDEPLOYING);
// backup files that are NOT part of the archive
$this->backupArchive($containerNode, $archive);
// delete directories previously backed up
$this->removeDir($webappFolderName);
// flag webapp as undeployed
$this->flagArchive($archive, ExtractorInterface::FLAG_UNDEPLOYED);
// log a message that the application has successfully been deployed
$this->getInitialContext()->getSystemLogger()->info(sprintf('Application archive %s has succussfully been undeployed', $archive->getBasename($this->getExtensionSuffix())));
}
} catch (\Exception $e) {
// log error
$this->getInitialContext()->getSystemLogger()->error($e->__toString());
// flag webapp as failed
$this->flagArchive($archive, ExtractorInterface::FLAG_FAILED);
}
}