fix: always download plugins in the install plugin folder
@@ -87,34 +87,25 @@ public class PluginManager implements org.openbaton.nfvo.core.interfaces.PluginM
throw new AlreadyExistingException("Plugin of type " + type + " is already installed");
}
}
- File pluginFolder = new File(pluginDir);
- File[] plugins = pluginFolder.listFiles();
- boolean found = false;
- if (plugins != null) {
- for (File plugin : plugins) {
- if (plugin.getName().toLowerCase().contains(type)) {
- log.info(
- "The plugin "
- + name
- + " is already downloaded, but is not started. Starting plugin now.");
- found = true;
- startPlugin(plugin.getPath(), name);
- break;
- }
- }
- }
- if (!found) {
+
String url = "http://" + marketIp + ":" + marketPort + "/api/v1/vim-drivers/" + id + "/jar";
+ String path = pluginDir + "/install-plugin/";
log.info("Download URL: " + url);
+
+ File installDir = new File(pluginDir + "/install-plugin");
+
+ if (!installDir.exists()) {
+ installDir.mkdirs();
+ }
+
URL pluginURL = new URL(url);
URLConnection conn = pluginURL.openConnection();
String headerField = conn.getHeaderField("Content-Disposition");
if (headerField != null && headerField.contains("filename=\"")) {
filename =
- headerField.substring(
- headerField.indexOf("filename=\"") + 10, headerField.length() - 1);
+ headerField.substring(headerField.indexOf("filename=\"") + 10, headerField.length() - 1);
}
- String path = pluginDir + "/" + filename;
+ path += filename;
FileOutputStream out = new FileOutputStream(path);
try {
BufferedInputStream fileInputStream = new BufferedInputStream(conn.getInputStream());
@@ -133,7 +124,6 @@ public class PluginManager implements org.openbaton.nfvo.core.interfaces.PluginM
}
startPlugin(path, name);
}
- }
@Override
public void startPlugin(String path, String name) throws IOException {
