示例#1
0
  @Path("/read")
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response readResponse(String input) throws Exception {
    JSONObject test = new JSONObject(input);
    Datastore ds = MongoConnection.getServer();
    List<ClientObject> clientObjects =
        ds.createQuery(ClientObject.class)
            .filter("client_bs_obj.device_id =", test.getString("client_bs_obj.device_id"))
            .asList();
    Resource resourceO =
        clientObjects
            .get(0)
            .getObjectMap()
            .get(test.getInt("ObjectId"))
            .getObjInstanceMap()
            .get(test.getInt("ObjectInsId"))
            .getResourceMap()
            .get(test.getInt("resourceId"));
    ObjectMapper mapper = new ObjectMapper();
    Resource resourceN = mapper.readValue(test.getString("value"), Resource.class);

    resourceO.getValue().putAll(resourceN.getValue());

    ds.save(clientObjects.get(0));

    CountDownLatch signalRead = Info.getCountDownMessage(test.getString("client_bs_obj.device_id"));
    signalRead.countDown();

    return Response.status(200).entity("success").build();
  }