diff --git a/src/main/java/cactusServer/resources/ObjectsRest.java b/src/main/java/cactusServer/resources/ObjectsRest.java index 626ab30..a8b9e41 100644 --- a/src/main/java/cactusServer/resources/ObjectsRest.java +++ b/src/main/java/cactusServer/resources/ObjectsRest.java @@ -25,7 +25,6 @@ @Path("/instances/{instanceId}/objects") public class ObjectsRest { - // @Path("/{instanceId}/objects/{objectId}") @Path("/{objectId}") @GET @Produces(MediaType.APPLICATION_JSON) @@ -43,7 +42,6 @@ return Instances.getInstance().getInstance(instanceId).getObjects(); } - // @Path("/{instanceId}/objects") @POST @Produces(MediaType.APPLICATION_JSON) public HashMap createObject(@PathParam("instanceId") String instanceId, @@ -60,20 +58,24 @@ } return uriMap; } - // @Path("/{instance-id}/objects/{object-id}") - @Path("/{object-id}") - @PUT - @Produces(MediaType.APPLICATION_JSON) - public Object updateObject(@FormParam("objectId") String objectId, - @FormParam("position") Position3D position, - @FormParam("velocity") Velocity3D velocity, - @FormParam("angularVelocity") AngularVelocity3D angularVelocity, - @FormParam("angle") Quaternion3D angle) { - Object object = updateObject(objectId, position, velocity, angularVelocity, angle); - if (object != null) { - return object; - }else { - throw new WebApplicationException(400); - } - } + + @Path("/{objectId}") + @PUT + @Produces(MediaType.APPLICATION_JSON) + public Object updateObject(@PathParam("instanceId") String instanceId, @PathParam("objectId") String objectId, + @FormParam("position") Position3D position, @FormParam("velocity") Velocity3D velocity, + @FormParam("angularVelocity") AngularVelocity3D angularVelocity, @FormParam("angle") Quaternion3D angle) { + Instance instance = Instances.getInstance().getInstance(instanceId); + if (instance != null) { + Object object = instance.getObject(objectId); + if (object != null) { + object.setAngle(angle); + object.setAngularVelocity(angularVelocity); + object.setPosition(position); + object.setVelocity(velocity); + return object; + } + } + throw new WebApplicationException(400); + } }