From 8db2e91e3e8df895deec84978e1c62f5b9c309b5 Mon Sep 17 00:00:00 2001 From: Victor Rubezhny Date: Thu, 27 Oct 2016 22:37:37 +0200 Subject: [PATCH] JBDS-4132 Could not load nodeJSInstall: node-v0.10.22-linux-x86_64 The destination directory for unpacking the Node.js runtime is changed from >.>/ to /.metadata/.plugins/>.>/ in order to prevent the attempts to extract the runtime zip-archive into the directories with restricted access rights. See: https://issues.jboss.org/browse/JBDS-4132 Issue: #441 Could not load nodeJSInstall: node-v0.10.22-linux-x86_64 Signed-off-by: Victor Rubezhny --- .../nodejs/internal/core/NodejsInstall.java | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/eclipse/tern.eclipse.ide.server.nodejs.core/src/tern/eclipse/ide/server/nodejs/internal/core/NodejsInstall.java b/eclipse/tern.eclipse.ide.server.nodejs.core/src/tern/eclipse/ide/server/nodejs/internal/core/NodejsInstall.java index d3be2a035..752da12d7 100644 --- a/eclipse/tern.eclipse.ide.server.nodejs.core/src/tern/eclipse/ide/server/nodejs/internal/core/NodejsInstall.java +++ b/eclipse/tern.eclipse.ide.server.nodejs.core/src/tern/eclipse/ide/server/nodejs/internal/core/NodejsInstall.java @@ -14,15 +14,18 @@ import java.io.File; import java.io.IOException; +import org.eclipse.core.internal.runtime.InternalPlatform; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; import tern.eclipse.ide.server.nodejs.core.INodejsInstall; import tern.eclipse.ide.server.nodejs.core.INodejsInstallProvider; import tern.utils.ZipUtils; +@SuppressWarnings("restriction") public class NodejsInstall implements INodejsInstall { private String id; @@ -56,23 +59,31 @@ private void createClass(IConfigurationElement element) throws IOException { String pluginId = element.getNamespaceIdentifier(); String path = element.getAttribute("path"); if (path != null && path.length() > 0) { - File baseDir = FileLocator.getBundleFile(Platform + File bundleDir = FileLocator.getBundleFile(Platform .getBundle(pluginId)); - this.path = new File(baseDir, path); - - // check if path exists, if it doesn't look for zip - if (!this.path.exists()) { - String zip = element.getAttribute("zip"); - - File zipFile = new File(baseDir, zip); - - if (zipFile.exists()) { - if (zipFile.getName().toLowerCase().endsWith(".zip")) { - ZipUtils.extract(zipFile, baseDir); - } + + IPath stateLocationPath = InternalPlatform.getDefault().getStateLocation(Platform + .getBundle(pluginId)); + + if (stateLocationPath != null) { + File baseDir = stateLocationPath.toFile(); - if(this.path.exists()) { - this.path.setExecutable(true); + this.path = new File(baseDir, path); + + // check if path exists, if it doesn't look for zip + if (!this.path.exists()) { + String zip = element.getAttribute("zip"); + + File zipFile = new File(bundleDir, zip); + + if (zipFile.exists()) { + if (zipFile.getName().toLowerCase().endsWith(".zip")) { + ZipUtils.extract(zipFile, baseDir); + } + + if(this.path.exists()) { + this.path.setExecutable(true); + } } } }