/** * Completely delete & destroy this Web application. When a request is made to an undeployed * webapp resource, an HTTP 404 (Not Found) will be returned. * * @throws CarbonException If an error occurs while undeploying this webapp */ public void undeploy() throws CarbonException { PrivilegedCarbonContext currentCarbonAppContextHolder = PrivilegedCarbonContext.getThreadLocalCarbonContext(); currentCarbonAppContextHolder.setApplicationName( TomcatUtil.getApplicationNameFromContext(this.context.getBaseName())); // lazyunload the context of WebApplication lazyUnload(); File webappDir; File warFile; if (webappFile.getAbsolutePath().endsWith(".war")) { String filePath = webappFile.getAbsolutePath(); webappDir = new File(filePath.substring(0, filePath.lastIndexOf('.'))); warFile = webappFile; } else { webappDir = webappFile; warFile = new File(webappFile.getAbsolutePath().concat(".war")); } // Delete the exploded dir of war based webapps upon undeploy. But omit deleting // Delete the exploded dir of war based webapps upon undeploy. But omit deleting // directory based webapps. // Also delete .war file upon deletion of the relevant exploded dir if (TomcatUtil.checkUnpackWars() && webappDir.exists() && !webappFile.isDirectory() && !FileManipulator.deleteDir(webappDir)) { throw new CarbonException("exploded Webapp directory " + webappDir + " deletion failed"); } if (TomcatUtil.checkUnpackWars() && webappFile.isDirectory() && warFile.exists() && !FileManipulator.deleteDir(warFile)) { throw new CarbonException("Webapp file " + warFile + " deletion failed"); } }
private void copySampleFile(String sourcePath, String destPath) { File sourceFile = new File(sourcePath); File destFile = new File(destPath); try { FileManipulator.copyFile(sourceFile, destFile); } catch (IOException e) { log.error("Error while copying the other into Jaggery server", e); } }
/** * Completely delete & destroy this Web application * * @throws CarbonException If an error occurs while undeploying this webapp */ public void delete() throws CarbonException { handleHotUpdateToHost("delete"); undeploy(); if (webappFile.isFile() && !webappFile.delete()) { throw new CarbonException("Webapp file " + webappFile + " deletion failed"); } else if (webappFile.isDirectory() && !FileManipulator.deleteDir(webappFile)) { throw new CarbonException("Webapp Directory " + webappFile + " deletion failed"); } }