Program: 39468
Project: 39468
Buggy source:
public String executeRequest(String clientId,ConcurrentHashMap<String,String> clientState,String request) throws Exception {
  StringBuffer rsb=new StringBuffer();
  String cmd;
  String[] args;
  if (request.indexOf(SPACE) != -1) {
    cmd=request.substring(0,request.indexOf(SPACE)).trim().toLowerCase();
    args=request.substring(request.indexOf(SPACE)).trim().split(SPACE);
  }
 else {
    cmd=request;
    args=new String[0];
  }
  if (cmd.equals(CMD_USE)) {
    if (null == dbs.get(args[0])) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      if (null != clientState.get(ST_DB))       clientState.remove(ST_DB);
      clientState.put(ST_DB,args[0]);
      rsb.append(R_OK);
    }
  }
 else   if (cmd.equals(CMD_CREATE)) {
    if (null != dbs.get(args[0])) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      dbs.put(args[0],new Graph());
      rsb.append(R_OK);
    }
  }
 else   if (cmd.equals(CMD_DROP)) {
    if (null == dbs.get(args[0])) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      dbs.remove(args[0]);
      rsb.append(R_OK);
    }
  }
 else   if (cmd.equals(CMD_NAMECON)) {
    clientState.put(ST_NAMECON,args[0] + "String_Node_Str" + clientId);
    rsb.append(clientState.get(ST_NAMECON));
    rsb.append(NL);
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_CLSTATE)) {
    JSONObject result=new JSONObject(clientState);
    rsb.append(result.toString(4));
    rsb.append(NL);
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_SSTAT)) {
    JSONObject result=new JSONObject();
    JSONObject names=new JSONObject();
    names.put("String_Node_Str",Graph.TYPE_FIELD);
    names.put("String_Node_Str",Graph.KEY_FIELD);
    names.put("String_Node_Str",Graph.WEIGHT_FIELD);
    names.put("String_Node_Str",Graph.EDGE_SOURCE_FIELD);
    names.put("String_Node_Str",Graph.EDGE_TARGET_FIELD);
    names.put("String_Node_Str",Graph.RELATION_FIELD);
    names.put("String_Node_Str",Graph.VERTEX_TYPE);
    names.put("String_Node_Str",Graph.EDGE_TYPE);
    result.put("String_Node_Str",names);
    rsb.append(result.toString(4));
    rsb.append(NL);
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_LISTG)) {
    for (    String name : dbs.keySet()) {
      rsb.append(name);
      rsb.append(NL);
    }
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_GSTAT)) {
    Graph gr0=dbs.get(args[0]);
    if (null == gr0) {
      rsb.append(R_NOT_EXIST);
    }
 else {
      JSONObject result=new JSONObject();
      result.put("String_Node_Str",gr0.numVertices());
      result.put("String_Node_Str",gr0.numEdges());
      rsb.append(result.toString(4));
      rsb.append(NL);
      rsb.append(R_OK);
    }
  }
 else {
    if (null == clientState.get(ST_DB)) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      String cldb=clientState.get(ST_DB);
      Graph gr=dbs.get(cldb);
      if (cmd.equals(CMD_EXISTS)) {
        String key=args[0];
        rsb.append("String_Node_Str" + gr.exists(key));
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_CVERT)) {
        String key=args[0];
        String json=request.substring(request.indexOf(SPACE + key) + (key.length() + 1)).trim();
        JSONObject jo=null;
        try {
          jo=new JSONObject(json);
          gr.addVertex(key,jo);
          rsb.append(R_OK);
        }
 catch (        org.json.JSONException jsonEx) {
          jsonEx.printStackTrace();
          rsb.append(R_ERR);
          rsb.append("String_Node_Str");
          rsb.append(jsonEx.getMessage());
        }
catch (        Exception ex) {
          ex.printStackTrace();
          rsb.append(R_ERR);
          rsb.append(SPACE);
          rsb.append(ex.getMessage());
        }
      }
 else       if (cmd.equals(CMD_CEDGE)) {
        String key=args[0];
        String vFromKey=args[1];
        String vToKey=args[2];
        String rel=args[3];
        double weight=1.0;
        String json;
        if (args[4].charAt(0) == '{') {
          json=request.substring(request.indexOf(SPACE + rel) + (rel.length() + 1)).trim();
        }
 else {
          weight=Double.parseDouble(args[4]);
          json=request.substring(request.indexOf(SPACE + args[4]) + (args[4].length() + 1)).trim();
        }
        JSONObject jo=null;
        try {
          jo=new JSONObject(json);
          jo.put(Graph.EDGE_SOURCE_FIELD,vFromKey);
          jo.put(Graph.EDGE_TARGET_FIELD,vToKey);
          jo.put(Graph.WEIGHT_FIELD,weight);
          jo.put(Graph.RELATION_FIELD,rel);
          gr.addEdge(key,jo,vFromKey,vToKey,rel,weight);
          rsb.append(R_OK);
        }
 catch (        org.json.JSONException jsonEx) {
          jsonEx.printStackTrace();
          rsb.append(R_ERR);
          rsb.append("String_Node_Str");
          rsb.append(jsonEx.getMessage());
        }
catch (        Exception ex) {
          ex.printStackTrace();
          rsb.append(R_ERR);
          rsb.append(SPACE);
          rsb.append(ex.getMessage());
        }
      }
 else       if (cmd.equals(CMD_DEL)) {
        String key=args[0];
        JSONObject obj=gr.get(key);
        if (null == obj) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          String _type=obj.getString(Graph.TYPE_FIELD);
          if (_type.equals(Graph.VERTEX_TYPE)) {
            JSONVertex jv=gr.getVertex(key);
            gr.removeVertex(jv);
            rsb.append(R_OK);
          }
 else           if (_type.equals(Graph.EDGE_TYPE)) {
            JSONEdge je=gr.getEdge(key);
            gr.removeEdge(je);
            rsb.append(R_OK);
          }
 else {
            rsb.append(R_ERR);
            rsb.append(SPACE);
            rsb.append(R_UNKNOWN_OBJECT_TYPE);
          }
        }
      }
 else       if (cmd.equals(CMD_GET)) {
        String key=args[0];
        JSONObject jo=gr.get(key);
        if (jo == null) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          rsb.append(prepareResult(jo));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_Q)) {
        String q=request.substring(request.indexOf(SPACE)).trim();
        List<JSONObject> results=gr.queryGraphIndex(q);
        JSONArray ja=new JSONArray();
        for (        JSONObject jo : results) {
          ja.put(jo);
        }
        JSONObject res=new JSONObject();
        res.put("String_Node_Str",ja);
        rsb.append(prepareResult(res));
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_QP)) {
        String q=request.substring(request.indexOf(SPACE)).trim();
        List<JSONObject> results=gr.queryProcessIndex(q);
        JSONArray ja=new JSONArray();
        for (        JSONObject jo : results) {
          ja.put(jo);
        }
        JSONObject res=new JSONObject();
        res.put("String_Node_Str",ja);
        rsb.append(prepareResult(res));
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_SPATH)) {
        String vFromKey=args[0];
        String vToKey=args[1];
        double radius=Double.POSITIVE_INFINITY;
        if (args.length == 3) {
          radius=Double.parseDouble(args[2]);
        }
        JSONObject result=gr.getShortestPath(vFromKey,vToKey,radius);
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(prepareResult(result));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_SET)) {
        String key=args[0];
        String attr=args[1];
        String val;
        if (args.length == 2) {
          val=null;
        }
 else {
          val=request.substring(request.indexOf(SPACE + args[1]) + (args[1].length() + 1)).trim();
        }
        if (attr.startsWith("String_Node_Str") && !attr.equals(Graph.WEIGHT_FIELD)) {
          rsb.append(R_ERR);
          rsb.append("String_Node_Str");
        }
 else {
          JSONObject obj=gr.get(key);
          if (null == obj) {
            rsb.append(R_NOT_FOUND);
          }
 else {
            String _type=obj.getString(Graph.TYPE_FIELD);
            if (_type.equals(Graph.VERTEX_TYPE)) {
              JSONVertex jv=gr.getVertex(key);
              if (null != val) {
                jv.put(attr,val);
              }
 else {
                jv.remove(attr);
              }
              gr.indexObject(key,_type,jv);
              rsb.append(R_OK);
            }
 else             if (_type.equals(Graph.EDGE_TYPE)) {
              JSONEdge je=gr.getEdge(key);
              if (null != val) {
                je.put(attr,val);
              }
 else {
                je.remove(attr);
              }
              if (attr.equals(Graph.WEIGHT_FIELD)) {
                gr.setEdgeWeight(je,Double.parseDouble(val));
              }
              gr.indexObject(key,_type,je.asJSONObject().getJSONObject(Graph.DATA_FIELD));
              rsb.append(R_OK);
            }
 else {
              rsb.append(R_ERR);
              rsb.append(R_UNKNOWN_OBJECT_TYPE);
            }
          }
        }
      }
 else       if (cmd.equals(CMD_INCW)) {
        String key=args[0];
        double w_amt=Double.parseDouble(args[1]);
        JSONEdge je=gr.getEdge(key);
        if (null == je) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          double weight=gr.getEdgeWeight(je);
          weight+=w_amt;
          gr.setEdgeWeight(je,weight);
          je.put(Graph.WEIGHT_FIELD,"String_Node_Str" + weight);
          gr.indexObject(key,Graph.EDGE_TYPE,je.asJSONObject().getJSONObject(Graph.DATA_FIELD));
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_SPY)) {
        String key=args[0];
        JSONObject obj=gr.get(key);
        if (null == obj) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          String _type=obj.getString(Graph.TYPE_FIELD);
          if (_type.equals(Graph.EDGE_TYPE)) {
            JSONEdge je=gr.getEdge(key);
            if (null == je) {
              rsb.append(R_NOT_FOUND);
            }
 else {
              rsb.append(je.asClientJSONObject().toString(4) + NL);
              rsb.append(R_OK);
            }
          }
 else           if (_type.equals(Graph.VERTEX_TYPE)) {
            JSONVertex jv=gr.getVertex(key);
            if (null == jv) {
              rsb.append(R_NOT_FOUND);
            }
 else {
              rsb.append(jv.toString(4) + NL);
              rsb.append(R_OK);
            }
          }
 else {
            rsb.append(R_ERR);
            rsb.append(R_UNKNOWN_OBJECT_TYPE);
          }
        }
      }
 else       if (cmd.equals(CMD_KSPATH)) {
        String vFromKey=args[0];
        String vToKey=args[1];
        int k=Integer.parseInt(args[2]);
        int maxHops=0;
        if (args.length > 3) {
          maxHops=Integer.parseInt(args[3]);
        }
        JSONObject result=gr.getKShortestPaths(vFromKey,vToKey,k,maxHops);
        rsb.append(prepareResult(result));
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_HC)) {
        List<JSONVertex> results=gr.getHamiltonianCycle();
        if (null == results) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          JSONObject res=new JSONObject();
          JSONArray cycle=new JSONArray();
          for (          JSONVertex jo : results) {
            cycle.put(jo);
          }
          res.put("String_Node_Str",cycle);
          rsb.append(prepareResult(res));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_EC)) {
        List<JSONVertex> results=gr.getEulerianCircuit();
        if (null == results) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          JSONObject res=new JSONObject();
          JSONArray circuit=new JSONArray();
          for (          JSONVertex jo : results) {
            circuit.put(jo);
          }
          res.put("String_Node_Str",circuit);
          rsb.append(prepareResult(res));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_EKMF)) {
        String vSourceKey=args[0];
        String vSinkKey=args[1];
        JSONObject flowResult=gr.getEKMF(vSourceKey,vSinkKey);
        if (null == flowResult) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(flowResult.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_CN)) {
        JSONObject result=new JSONObject();
        result.put("String_Node_Str",gr.getChromaticNumber());
        rsb.append(result.toString());
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_KMST)) {
        JSONObject result=gr.getKMST();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_VCG)) {
        JSONObject result=gr.getGreedyVertexCover();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_VC2A)) {
        JSONObject result=gr.get2ApproximationVertexCover();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_CSETV)) {
        String key=args[0];
        JSONVertex v=gr.getVertex(key);
        if (null == v) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          JSONObject result=gr.getConnectedSetByVertex(v);
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_CSETS)) {
        JSONObject result=gr.getConnectedSets();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_ISCON)) {
        rsb.append("String_Node_Str" + gr.isConnected());
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_UPATHEX)) {
        JSONVertex vFrom=gr.getVertex(args[0]);
        JSONVertex vTo=gr.getVertex(args[1]);
        if (null == vFrom || null == vTo) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          rsb.append("String_Node_Str" + gr.pathExists(vFrom,vTo));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_FAMC)) {
        JSONObject result=gr.getAllMaximalCliques();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_FBMC)) {
        JSONObject result=gr.getBiggestMaximalCliques();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_ASPV)) {
        JSONObject result=gr.getAllShortestPathsFrom(gr.getVertex(args[0]));
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_GCYC)) {
        JSONObject result=gr.getGraphCycles();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_VCYC)) {
        JSONObject result=gr.getGraphCyclesContainingVertex(gr.getVertex(args[0]));
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_EMIT)) {
        String key=args[0];
        String processName=args[1];
        String json=request.substring(request.indexOf(SPACE + processName) + (processName.length() + 1)).trim();
        JSONObject jo=null;
        jo=new JSONObject(json);
        gr.emit(key,processName,jo);
        rsb.append(R_OK);
      }
    }
  }
  if (rsb.toString().equals("String_Node_Str")) {
    log.info("String_Node_Str" + cmd);
    rsb.append(R_UNK);
    rsb.append(SPACE);
    rsb.append(cmd);
  }
  rsb.append(NL);
  return rsb.toString();
}

Fixed version (ground truth):
public String executeRequest(String clientId,ConcurrentHashMap<String,String> clientState,String request) throws Exception {
  StringBuffer rsb=new StringBuffer();
  String cmd;
  String[] args;
  if (request.indexOf(SPACE) != -1) {
    cmd=request.substring(0,request.indexOf(SPACE)).trim().toLowerCase();
    args=request.substring(request.indexOf(SPACE)).trim().split(SPACE);
  }
 else {
    cmd=request.trim().toLowerCase();
    args=new String[0];
  }
  if (cmd.equals(CMD_USE)) {
    if (null == dbs.get(args[0])) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      if (null != clientState.get(ST_DB))       clientState.remove(ST_DB);
      clientState.put(ST_DB,args[0]);
      rsb.append(R_OK);
    }
  }
 else   if (cmd.equals(CMD_CREATE)) {
    if (null != dbs.get(args[0])) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      dbs.put(args[0],new Graph());
      rsb.append(R_OK);
    }
  }
 else   if (cmd.equals(CMD_DROP)) {
    if (null == dbs.get(args[0])) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      dbs.remove(args[0]);
      rsb.append(R_OK);
    }
  }
 else   if (cmd.equals(CMD_NAMECON)) {
    clientState.put(ST_NAMECON,args[0] + "String_Node_Str" + clientId);
    rsb.append(clientState.get(ST_NAMECON));
    rsb.append(NL);
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_CLSTATE)) {
    JSONObject result=new JSONObject(clientState);
    rsb.append(result.toString(4));
    rsb.append(NL);
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_SSTAT)) {
    JSONObject result=new JSONObject();
    JSONObject names=new JSONObject();
    names.put("String_Node_Str",Graph.TYPE_FIELD);
    names.put("String_Node_Str",Graph.KEY_FIELD);
    names.put("String_Node_Str",Graph.WEIGHT_FIELD);
    names.put("String_Node_Str",Graph.EDGE_SOURCE_FIELD);
    names.put("String_Node_Str",Graph.EDGE_TARGET_FIELD);
    names.put("String_Node_Str",Graph.RELATION_FIELD);
    names.put("String_Node_Str",Graph.VERTEX_TYPE);
    names.put("String_Node_Str",Graph.EDGE_TYPE);
    result.put("String_Node_Str",names);
    rsb.append(result.toString(4));
    rsb.append(NL);
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_LISTG)) {
    for (    String name : dbs.keySet()) {
      rsb.append(name);
      rsb.append(NL);
    }
    rsb.append(R_OK);
  }
 else   if (cmd.equals(CMD_GSTAT)) {
    Graph gr0=dbs.get(args[0]);
    if (null == gr0) {
      rsb.append(R_NOT_EXIST);
    }
 else {
      JSONObject result=new JSONObject();
      result.put("String_Node_Str",gr0.numVertices());
      result.put("String_Node_Str",gr0.numEdges());
      rsb.append(result.toString(4));
      rsb.append(NL);
      rsb.append(R_OK);
    }
  }
 else {
    if (null == clientState.get(ST_DB)) {
      rsb.append(R_ERR);
      rsb.append("String_Node_Str");
    }
 else {
      String cldb=clientState.get(ST_DB);
      Graph gr=dbs.get(cldb);
      if (cmd.equals(CMD_EXISTS)) {
        String key=args[0];
        rsb.append("String_Node_Str" + gr.exists(key));
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_CVERT)) {
        String key=args[0];
        String json=request.substring(request.indexOf(SPACE + key) + (key.length() + 1)).trim();
        JSONObject jo=null;
        try {
          jo=new JSONObject(json);
          gr.addVertex(key,jo);
          rsb.append(R_OK);
        }
 catch (        org.json.JSONException jsonEx) {
          jsonEx.printStackTrace();
          rsb.append(R_ERR);
          rsb.append("String_Node_Str");
          rsb.append(jsonEx.getMessage());
        }
catch (        Exception ex) {
          ex.printStackTrace();
          rsb.append(R_ERR);
          rsb.append(SPACE);
          rsb.append(ex.getMessage());
        }
      }
 else       if (cmd.equals(CMD_CEDGE)) {
        String key=args[0];
        String vFromKey=args[1];
        String vToKey=args[2];
        String rel=args[3];
        double weight=1.0;
        String json;
        if (args[4].charAt(0) == '{') {
          json=request.substring(request.indexOf(SPACE + rel) + (rel.length() + 1)).trim();
        }
 else {
          weight=Double.parseDouble(args[4]);
          json=request.substring(request.indexOf(SPACE + args[4]) + (args[4].length() + 1)).trim();
        }
        JSONObject jo=null;
        try {
          jo=new JSONObject(json);
          jo.put(Graph.EDGE_SOURCE_FIELD,vFromKey);
          jo.put(Graph.EDGE_TARGET_FIELD,vToKey);
          jo.put(Graph.WEIGHT_FIELD,weight);
          jo.put(Graph.RELATION_FIELD,rel);
          gr.addEdge(key,jo,vFromKey,vToKey,rel,weight);
          rsb.append(R_OK);
        }
 catch (        org.json.JSONException jsonEx) {
          jsonEx.printStackTrace();
          rsb.append(R_ERR);
          rsb.append("String_Node_Str");
          rsb.append(jsonEx.getMessage());
        }
catch (        Exception ex) {
          ex.printStackTrace();
          rsb.append(R_ERR);
          rsb.append(SPACE);
          rsb.append(ex.getMessage());
        }
      }
 else       if (cmd.equals(CMD_DEL)) {
        String key=args[0];
        JSONObject obj=gr.get(key);
        if (null == obj) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          String _type=obj.getString(Graph.TYPE_FIELD);
          if (_type.equals(Graph.VERTEX_TYPE)) {
            JSONVertex jv=gr.getVertex(key);
            gr.removeVertex(jv);
            rsb.append(R_OK);
          }
 else           if (_type.equals(Graph.EDGE_TYPE)) {
            JSONEdge je=gr.getEdge(key);
            gr.removeEdge(je);
            rsb.append(R_OK);
          }
 else {
            rsb.append(R_ERR);
            rsb.append(SPACE);
            rsb.append(R_UNKNOWN_OBJECT_TYPE);
          }
        }
      }
 else       if (cmd.equals(CMD_GET)) {
        String key=args[0];
        JSONObject jo=gr.get(key);
        if (jo == null) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          rsb.append(prepareResult(jo));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_Q)) {
        String q=request.substring(request.indexOf(SPACE)).trim();
        List<JSONObject> results=gr.queryGraphIndex(q);
        JSONArray ja=new JSONArray();
        for (        JSONObject jo : results) {
          ja.put(jo);
        }
        JSONObject res=new JSONObject();
        res.put("String_Node_Str",ja);
        rsb.append(prepareResult(res));
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_QP)) {
        String q=request.substring(request.indexOf(SPACE)).trim();
        List<JSONObject> results=gr.queryProcessIndex(q);
        JSONArray ja=new JSONArray();
        for (        JSONObject jo : results) {
          ja.put(jo);
        }
        JSONObject res=new JSONObject();
        res.put("String_Node_Str",ja);
        rsb.append(prepareResult(res));
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_SPATH)) {
        String vFromKey=args[0];
        String vToKey=args[1];
        double radius=Double.POSITIVE_INFINITY;
        if (args.length == 3) {
          radius=Double.parseDouble(args[2]);
        }
        JSONObject result=gr.getShortestPath(vFromKey,vToKey,radius);
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(prepareResult(result));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_SET)) {
        String key=args[0];
        String attr=args[1];
        String val;
        if (args.length == 2) {
          val=null;
        }
 else {
          val=request.substring(request.indexOf(SPACE + args[1]) + (args[1].length() + 1)).trim();
        }
        if (attr.startsWith("String_Node_Str") && !attr.equals(Graph.WEIGHT_FIELD)) {
          rsb.append(R_ERR);
          rsb.append("String_Node_Str");
        }
 else {
          JSONObject obj=gr.get(key);
          if (null == obj) {
            rsb.append(R_NOT_FOUND);
          }
 else {
            String _type=obj.getString(Graph.TYPE_FIELD);
            if (_type.equals(Graph.VERTEX_TYPE)) {
              JSONVertex jv=gr.getVertex(key);
              if (null != val) {
                jv.put(attr,val);
              }
 else {
                jv.remove(attr);
              }
              gr.indexObject(key,_type,jv);
              rsb.append(R_OK);
            }
 else             if (_type.equals(Graph.EDGE_TYPE)) {
              JSONEdge je=gr.getEdge(key);
              if (null != val) {
                je.put(attr,val);
              }
 else {
                je.remove(attr);
              }
              if (attr.equals(Graph.WEIGHT_FIELD)) {
                gr.setEdgeWeight(je,Double.parseDouble(val));
              }
              gr.indexObject(key,_type,je.asJSONObject().getJSONObject(Graph.DATA_FIELD));
              rsb.append(R_OK);
            }
 else {
              rsb.append(R_ERR);
              rsb.append(R_UNKNOWN_OBJECT_TYPE);
            }
          }
        }
      }
 else       if (cmd.equals(CMD_INCW)) {
        String key=args[0];
        double w_amt=Double.parseDouble(args[1]);
        JSONEdge je=gr.getEdge(key);
        if (null == je) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          double weight=gr.getEdgeWeight(je);
          weight+=w_amt;
          gr.setEdgeWeight(je,weight);
          je.put(Graph.WEIGHT_FIELD,"String_Node_Str" + weight);
          gr.indexObject(key,Graph.EDGE_TYPE,je.asJSONObject().getJSONObject(Graph.DATA_FIELD));
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_SPY)) {
        String key=args[0];
        JSONObject obj=gr.get(key);
        if (null == obj) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          String _type=obj.getString(Graph.TYPE_FIELD);
          if (_type.equals(Graph.EDGE_TYPE)) {
            JSONEdge je=gr.getEdge(key);
            if (null == je) {
              rsb.append(R_NOT_FOUND);
            }
 else {
              rsb.append(je.asClientJSONObject().toString(4) + NL);
              rsb.append(R_OK);
            }
          }
 else           if (_type.equals(Graph.VERTEX_TYPE)) {
            JSONVertex jv=gr.getVertex(key);
            if (null == jv) {
              rsb.append(R_NOT_FOUND);
            }
 else {
              rsb.append(jv.toString(4) + NL);
              rsb.append(R_OK);
            }
          }
 else {
            rsb.append(R_ERR);
            rsb.append(R_UNKNOWN_OBJECT_TYPE);
          }
        }
      }
 else       if (cmd.equals(CMD_KSPATH)) {
        String vFromKey=args[0];
        String vToKey=args[1];
        int k=Integer.parseInt(args[2]);
        int maxHops=0;
        if (args.length > 3) {
          maxHops=Integer.parseInt(args[3]);
        }
        JSONObject result=gr.getKShortestPaths(vFromKey,vToKey,k,maxHops);
        rsb.append(prepareResult(result));
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_HC)) {
        List<JSONVertex> results=gr.getHamiltonianCycle();
        if (null == results) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          JSONObject res=new JSONObject();
          JSONArray cycle=new JSONArray();
          for (          JSONVertex jo : results) {
            cycle.put(jo);
          }
          res.put("String_Node_Str",cycle);
          rsb.append(prepareResult(res));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_EC)) {
        List<JSONVertex> results=gr.getEulerianCircuit();
        if (null == results) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          JSONObject res=new JSONObject();
          JSONArray circuit=new JSONArray();
          for (          JSONVertex jo : results) {
            circuit.put(jo);
          }
          res.put("String_Node_Str",circuit);
          rsb.append(prepareResult(res));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_EKMF)) {
        String vSourceKey=args[0];
        String vSinkKey=args[1];
        JSONObject flowResult=gr.getEKMF(vSourceKey,vSinkKey);
        if (null == flowResult) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(flowResult.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_CN)) {
        JSONObject result=new JSONObject();
        result.put("String_Node_Str",gr.getChromaticNumber());
        rsb.append(result.toString());
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_KMST)) {
        JSONObject result=gr.getKMST();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_VCG)) {
        JSONObject result=gr.getGreedyVertexCover();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_VC2A)) {
        JSONObject result=gr.get2ApproximationVertexCover();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_CSETV)) {
        String key=args[0];
        JSONVertex v=gr.getVertex(key);
        if (null == v) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          JSONObject result=gr.getConnectedSetByVertex(v);
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_CSETS)) {
        JSONObject result=gr.getConnectedSets();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_ISCON)) {
        rsb.append("String_Node_Str" + gr.isConnected());
        rsb.append(NL);
        rsb.append(R_OK);
      }
 else       if (cmd.equals(CMD_UPATHEX)) {
        JSONVertex vFrom=gr.getVertex(args[0]);
        JSONVertex vTo=gr.getVertex(args[1]);
        if (null == vFrom || null == vTo) {
          rsb.append(R_NOT_FOUND);
        }
 else {
          rsb.append("String_Node_Str" + gr.pathExists(vFrom,vTo));
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_FAMC)) {
        JSONObject result=gr.getAllMaximalCliques();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_FBMC)) {
        JSONObject result=gr.getBiggestMaximalCliques();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_ASPV)) {
        JSONObject result=gr.getAllShortestPathsFrom(gr.getVertex(args[0]));
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_GCYC)) {
        JSONObject result=gr.getGraphCycles();
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_VCYC)) {
        JSONObject result=gr.getGraphCyclesContainingVertex(gr.getVertex(args[0]));
        if (null == result) {
          rsb.append(R_NOT_EXIST);
        }
 else {
          rsb.append(result.toString());
          rsb.append(NL);
          rsb.append(R_OK);
        }
      }
 else       if (cmd.equals(CMD_EMIT)) {
        String key=args[0];
        String processName=args[1];
        String json=request.substring(request.indexOf(SPACE + processName) + (processName.length() + 1)).trim();
        JSONObject jo=null;
        jo=new JSONObject(json);
        gr.emit(key,processName,jo);
        rsb.append(R_OK);
      }
    }
  }
  if (rsb.toString().equals("String_Node_Str")) {
    log.info("String_Node_Str" + cmd);
    rsb.append(R_UNK);
    rsb.append(SPACE);
    rsb.append(cmd);
  }
  rsb.append(NL);
  return rsb.toString();
}