try {
if (server.isInstance()) {
// if it's on instance, we should clean up
// the bits
deployment.undeploy(appName, deploymentContext);
deploymentContext.clean();
if (!Boolean.valueOf(application.getDirectoryDeployed()) && source.exists()) {
FileUtils.whack(new File(source.getURI()));
}
deployment.unregisterAppFromDomainXML(appName, target);
} else {