Skip to content

Commit

Permalink
JBDS-4132 Could not load nodeJSInstall: node-v0.10.22-linux-x86_64
Browse files Browse the repository at this point in the history
The destination directory for unpacking the Node.js runtime is changed
from <tern.eclipse.ide.server.nodejs.embed.<os<.distribution>>.<platform>>/<node.js rintime zip-filename>
to <User's workspace>/.metadata/.plugins/<tern.eclipse.ide.server.nodejs.embed.<os<.distribution>>.<platform>>/<node.js rintime zip-filename>
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 <[email protected]>
  • Loading branch information
vrubezhny committed Oct 27, 2016
1 parent 1644e96 commit 8db2e91
Showing 1 changed file with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit 8db2e91

Please sign in to comment.