|
|
@ -16,7 +16,6 @@ import java.io.File; |
|
|
|
import java.io.FileFilter; |
|
|
|
import java.io.FileFilter; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
@ -257,6 +256,7 @@ public class DefaultPluginManager implements PluginManager { |
|
|
|
// expand all plugin archives
|
|
|
|
// expand all plugin archives
|
|
|
|
FileFilter zipFilter = new ZipFileFilter(); |
|
|
|
FileFilter zipFilter = new ZipFileFilter(); |
|
|
|
File[] zipFiles = pluginsDirectory.listFiles(zipFilter); |
|
|
|
File[] zipFiles = pluginsDirectory.listFiles(zipFilter); |
|
|
|
|
|
|
|
if (zipFiles != null) { |
|
|
|
for (File zipFile : zipFiles) { |
|
|
|
for (File zipFile : zipFiles) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
expandPluginArchive(zipFile); |
|
|
|
expandPluginArchive(zipFile); |
|
|
@ -264,6 +264,7 @@ public class DefaultPluginManager implements PluginManager { |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// check for no plugins
|
|
|
|
// check for no plugins
|
|
|
|
List<FileFilter> filterList = new ArrayList<FileFilter>(); |
|
|
|
List<FileFilter> filterList = new ArrayList<FileFilter>(); |
|
|
@ -271,7 +272,10 @@ public class DefaultPluginManager implements PluginManager { |
|
|
|
filterList.add(new NotFileFilter(createHiddenPluginFilter())); |
|
|
|
filterList.add(new NotFileFilter(createHiddenPluginFilter())); |
|
|
|
FileFilter pluginsFilter = new AndFileFilter(filterList); |
|
|
|
FileFilter pluginsFilter = new AndFileFilter(filterList); |
|
|
|
File[] directories = pluginsDirectory.listFiles(pluginsFilter); |
|
|
|
File[] directories = pluginsDirectory.listFiles(pluginsFilter); |
|
|
|
log.debug("Found possible {} plugins: {}", directories.length, Arrays.asList(directories)); |
|
|
|
if (directories == null) { |
|
|
|
|
|
|
|
directories = new File[0]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
log.debug("Found possible {} plugins: {}", directories.length, directories); |
|
|
|
if (directories.length == 0) { |
|
|
|
if (directories.length == 0) { |
|
|
|
log.info("No plugins"); |
|
|
|
log.info("No plugins"); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -333,6 +337,51 @@ public class DefaultPluginManager implements PluginManager { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean deletePlugin(String pluginId) { |
|
|
|
|
|
|
|
if (!plugins.containsKey(pluginId)) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException(String.format("Unknown pluginId %s", pluginId)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PluginWrapper pw = getPlugin(pluginId); |
|
|
|
|
|
|
|
PluginState state = stopPlugin(pluginId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (PluginState.STOPPED != state) { |
|
|
|
|
|
|
|
log.error("Failed to stop plugin {} on delete", pluginId); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!unloadPlugin(pluginId)) { |
|
|
|
|
|
|
|
log.error("Failed to unload plugin {} on delete", pluginId); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File pluginFolder = new File(pluginsDirectory, pw.getPluginPath()); |
|
|
|
|
|
|
|
File pluginZip = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileFilter zipFilter = new ZipFileFilter(); |
|
|
|
|
|
|
|
File[] zipFiles = pluginsDirectory.listFiles(zipFilter); |
|
|
|
|
|
|
|
if (zipFiles != null) { |
|
|
|
|
|
|
|
// strip prepended / from the plugin path
|
|
|
|
|
|
|
|
String dirName = pw.getPluginPath().substring(1); |
|
|
|
|
|
|
|
// find the zip file that matches the plugin path
|
|
|
|
|
|
|
|
for (File zipFile : zipFiles) { |
|
|
|
|
|
|
|
String name = zipFile.getName().substring(0, zipFile.getName().lastIndexOf('.')); |
|
|
|
|
|
|
|
if (name.equals(dirName)) { |
|
|
|
|
|
|
|
pluginZip = zipFile; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pluginFolder.exists()) { |
|
|
|
|
|
|
|
FileUtils.delete(pluginFolder); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (pluginZip != null && pluginZip.exists()) { |
|
|
|
|
|
|
|
FileUtils.delete(pluginZip); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get plugin class loader for this path. |
|
|
|
* Get plugin class loader for this path. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|