Skip to content

Commit

Permalink
Merge pull request #444 from vrubezhny/jbds4132-master
Browse files Browse the repository at this point in the history
JBDS-4132 Could not load nodeJSInstall: node-v0.10.22-linux-x86_64 (master)
  • Loading branch information
angelozerr committed Oct 27, 2016
2 parents 1644e96 + 8db2e91 commit 02456a1
Showing 1 changed file with 26 additions and 15 deletions.
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 02456a1

Please sign in to comment.