You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by pl...@apache.org on 2015/10/15 05:08:32 UTC

incubator-tinkerpop git commit: TINKERPOP3-858 Cleanup after failed plugin install

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP3-858 [created] b2d77de94


TINKERPOP3-858 Cleanup after failed plugin install


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/b2d77de9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/b2d77de9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/b2d77de9

Branch: refs/heads/TINKERPOP3-858
Commit: b2d77de94afbdbd13aa3fb512dedf4dd679be083
Parents: a28a1a8
Author: Jason Plurad <pl...@apache.org>
Authored: Wed Oct 14 23:05:31 2015 -0400
Committer: Jason Plurad <pl...@apache.org>
Committed: Wed Oct 14 23:05:31 2015 -0400

----------------------------------------------------------------------
 .../gremlin/console/commands/InstallCommand.groovy     |  6 ++++++
 .../gremlin/groovy/util/DependencyGrabber.groovy       | 13 +++++++++++++
 .../gremlin/server/util/GremlinServerInstall.java      |  8 ++++++--
 3 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b2d77de9/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
index a2efe2a..2bc7a60 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/commands/InstallCommand.groovy
@@ -53,6 +53,12 @@ class InstallCommand extends CommandSupport {
             final def pluginsThatNeedRestart = grabDeps(dep)
             return "Loaded: " + arguments + (pluginsThatNeedRestart.size() == 0 ? "" : " - restart the console to use $pluginsThatNeedRestart")
         } catch (Exception ex) {
+            if (!(ex instanceof IllegalStateException)) {
+                // IllegalStateException is thrown if a module with the same name is already installed.
+                final def uninstall = new UninstallCommand(shell, mediator)
+                final List<String> module = Collections.singletonList(artifact.getArtifact())
+                uninstall.execute(module)
+            }
             return ex.message
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b2d77de9/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
index f8065d7..e17c4a6 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabber.groovy
@@ -47,6 +47,19 @@ class DependencyGrabber {
         this.extensionDirectory = extensionDirectory
     }
 
+    def String deleteDependenciesFromPath(final Artifact artifact) {
+        final def dep = makeDepsMap(artifact)
+        final String extClassPath = getPathFromDependency(dep)
+        final File f = new File(extClassPath)
+        if (!f.exists()) {
+            return "There is no module with the name ${dep.module} to remove - $extClassPath"
+        }
+        else {
+            f.deleteDir()
+            return "Uninstalled ${dep.module}"
+        }
+    }
+
     def Set<String> copyDependenciesToPath(final Artifact artifact) {
         final def dep = makeDepsMap(artifact)
         final String extClassPath = getPathFromDependency(dep)

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b2d77de9/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java
index 03317d3..ffc8377 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/GremlinServerInstall.java
@@ -32,11 +32,15 @@ public class GremlinServerInstall {
         if (arguments.length != 3) {
             System.out.println("Usage: <group> <artifact> <version>");
         } else {
+            final Artifact artifact = new Artifact(arguments[0], arguments[1], arguments[2]);
+            final DependencyGrabber grabber = new DependencyGrabber(dummyClassLoader, getExtensionPath());
             try {
-                final Artifact artifact = new Artifact(arguments[0], arguments[1], arguments[2]);
-                final DependencyGrabber grabber = new DependencyGrabber(dummyClassLoader, getExtensionPath());
                 grabber.copyDependenciesToPath(artifact);
             } catch (Exception iae) {
+                if (!(iae instanceof IllegalStateException)) {
+                    // IllegalStateException is thrown if a module with the same name is already installed.
+                    grabber.deleteDependenciesFromPath(artifact);
+                }
                 System.out.println(String.format("Could not install the dependency: %s", iae.getMessage()));
                 iae.printStackTrace();
             }