Permalink
Browse files

added REST and HTTP versions of list column family handler

  • Loading branch information...
1 parent f23f64f commit 8ccf899e018f103606a9cdca20c5150c66ddcc13 @zznate committed Mar 6, 2013
@@ -0,0 +1,37 @@
+package org.usergrid.vx.handler.rest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.usergrid.vx.experimental.IntraReq;
+import org.usergrid.vx.experimental.Operations;
+import org.vertx.java.core.Handler;
+import org.vertx.java.core.Vertx;
+import org.vertx.java.core.buffer.Buffer;
+import org.vertx.java.core.eventbus.Message;
+import org.vertx.java.core.http.HttpServerRequest;
+import org.vertx.java.core.json.JsonObject;
+
+/**
+ * @author zznate
+ */
+public class ColumnFamilyMetaHandler extends IntraHandlerRest {
+
+ private Logger log = LoggerFactory.getLogger(ColumnFamilyMetaHandler.class);
+
+ public ColumnFamilyMetaHandler(Vertx vertx) {
+ super(vertx);
+ }
+
+ @Override
+ public void handleRequestAsync(final HttpServerRequest request, Buffer buffer) {
+ log.debug("In ColumnFamilyMetaHandler#handleRequestAsync");
+ IntraReq req = new IntraReq();
+ req.add(Operations.listColumnFamilyOp(request.params().get("ks")));
+ vertx.eventBus().send("request.json", req.toJson(), new Handler<Message<JsonObject>>() {
+ @Override
+ public void handle(Message<JsonObject> event) {
+ request.response.end(event.body.toString());
+ }
+ });
+ }
+}
@@ -0,0 +1,35 @@
+package org.usergrid.vx.server.operations;
+
+import org.apache.cassandra.config.KSMetaData;
+import org.apache.cassandra.config.Schema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.vertx.java.core.Handler;
+import org.vertx.java.core.eventbus.Message;
+import org.vertx.java.core.json.JsonArray;
+import org.vertx.java.core.json.JsonObject;
+
+import java.util.List;
+
+/**
+ * @author zznate
+ */
+public class ListColumnFamilyHandler implements Handler<Message<JsonObject>> {
+
+ private Logger log = LoggerFactory.getLogger(ListColumnFamilyHandler.class);
+
+ @Override
+ public void handle(Message<JsonObject> event) {
+ log.debug("in ListColumnFamilyHandler#handle");
+
+ Integer id = event.body.getInteger("id");
+
+ JsonObject params = event.body.getObject("op");
+ JsonObject state = event.body.getObject("state");
+
+ KSMetaData ks = Schema.instance.getKSMetaData(HandlerUtils.determineKs(params, state, null));
+ JsonObject response = new JsonObject().putArray(id.toString(), new JsonArray(ks.cfMetaData().keySet().toArray()));
+
+ event.reply(response);
+ }
+}

0 comments on commit 8ccf899

Please sign in to comment.