Browse Source

fix untar of archive + make sure returned field is 'id' not '_id'

purplefox 11 years ago
parent
commit
9af5ee6a66
2 changed files with 12 additions and 5 deletions
  1. 1 1
      toolset/setup/linux/installer.py
  2. 11 4
      vertx/WebServer.java

+ 1 - 1
toolset/setup/linux/installer.py

@@ -291,7 +291,7 @@ class Installer:
     # Vert.x
     #
     self.__download("http://dl.bintray.com/vertx/downloads/vert.x-2.1M2.tar.gz?direct=true", "vert.x-2.1M2.tar.gz")
-    self.__run_command("tar xzf vert.x-2.1M1.tar.gz")
+    self.__run_command("tar xzf vert.x-2.1M2.tar.gz")
 
     #
     # Yesod

+ 11 - 4
vertx/WebServer.java

@@ -77,14 +77,21 @@ public class WebServer extends Verticle implements Handler<HttpServerRequest> {
     findRandom(ThreadLocalRandom.current(), new Handler<Message<JsonObject>>() {
       @Override
       public void handle(Message<JsonObject> reply) {
-        JsonObject body = reply.body();
-        JsonObject world = body.getObject("result");
+        JsonObject world = getResultFromReply(reply);
         String result = world.encode();
         sendResponse(req, result);
       }
     });
   }
 
+  private JsonObject getResultFromReply(Message<JsonObject> reply) {
+    JsonObject body = reply.body();
+    JsonObject world = body.getObject("result");
+    Object id = world.removeField("_id");
+    world.putValue("id", id);
+    return world;
+  }
+
   private void handleQueriesMongo(final HttpServerRequest req) {
     int queriesParam = 1;
     try {
@@ -136,8 +143,8 @@ public class WebServer extends Verticle implements Handler<HttpServerRequest> {
 
     @Override
     public void handle(Message<JsonObject> reply) {
-      JsonObject body = reply.body();
-      worlds.add(body.getObject("result"));
+      JsonObject world = getResultFromReply(reply);
+      worlds.add(world);
       if (worlds.size() == this.queries) {
         // All queries have completed; send the response.
         String result = worlds.encode();