private void removePlugin(String deployName) { // In case of a deploy error the container already undeployed the corrupt plugin // Delete the plugin from work folder try { if (hasPlugin(deployName)) { File pluginDirectory = getPluginDirectoryUnchecked(deployName); FileUtils.deleteDirectory(pluginDirectory); } } catch (Exception e1) { log.warn("Could not delete plugin classpath files from the container. Check the plugin implementation!", e1); } }
private void undeployFromFilesystem(String deployName) throws LimbusException { checkState(); if (hasPlugin(deployName)) { Classpath classpath = findPlugin(deployName); try { container.undeployPlugin(classpath); } finally { removePlugin(deployName); } } }
/** * Deploys the specified ZIP file to this container. * * @param zipDeployment * The ZIP file. * @param permissions * The permissions to be granted for classes of this classpath. * @throws LimbusException * Thrown on any error while unpacking or deploying this ZIP file. */ @Override public void deployZipFile(File zipDeployment, Set<Permission> permissions) throws LimbusException { checkState(); String deployName = toDeployName(zipDeployment.getName()); if (hasPlugin(deployName)) { throw new LimbusException(String.format("The plugin '%s' is already deployed.", deployName)); } try { File deployDirectory = getCreateOrFailPluginDirectory(deployName); Zip.unpack(zipDeployment, deployDirectory); } catch (Exception e) { throw new LimbusException(String.format("Cannot unpack ZIP plugin bundle %s", zipDeployment.getAbsolutePath()), e); } // Trigger deploy deployFromFilesystem(deployName, permissions); }