| |
---|
| | |
---|
| | import java.util.HashSet; |
---|
| | import java.util.Map; |
---|
| | |
---|
| | import javax.validation.Valid; |
---|
| | import javax.ws.rs.BeanParam; |
---|
| | import javax.ws.rs.Consumes; |
---|
| | import javax.ws.rs.DELETE; |
---|
| | import javax.ws.rs.FormParam; |
---|
| | import javax.ws.rs.GET; |
---|
| | import javax.ws.rs.POST; |
---|
| |
---|
| | import javax.ws.rs.PathParam; |
---|
| | import javax.ws.rs.Produces; |
---|
| | import javax.ws.rs.QueryParam; |
---|
| | import javax.ws.rs.core.MediaType; |
---|
| | |
---|
| | import org.glassfish.jersey.process.internal.RequestScoped; |
---|
| | |
---|
| | import cactusServer.entities.AddressedEntity; |
---|
| | import cactusServer.entities.Angle; |
---|
| | import cactusServer.entities.Area; |
---|
| |
---|
| | import framework.physics.Velocity3D; |
---|
| | |
---|
| | |
---|
| | @Path("/instances") |
---|
| | @RequestScoped |
---|
| | public class InstancesRest { |
---|
| | public static final String INSTANCES_URI = "/CactusServer/rest/instances"; |
---|
| | public InstancesRest() { |
---|
| | |
---|
| |
---|
| | |
---|
| | |
---|
| | |
---|
| | |
---|
| | // @POST |
---|
| | // @Produces(MediaType.APPLICATION_JSON) |
---|
| | // public URIAddressedEntity create(@FormParam("name") String name, @FormParam("state") Instance.State state, @FormParam("stageModel") StageModel stageModel) { |
---|
| | // IDAddressedEntity ae = Instances.getInstance().createInstance(name, state, stageModel); |
---|
| | // return new URIAddressedEntity((INSTANCES_URI + "/" + ae.getId()), ae.getBody()); |
---|
| | // } |
---|
| | // |
---|
| | // @Path("/{instanceId}/areas") |
---|
| | // @POST |
---|
| | // @Produces(MediaType.APPLICATION_JSON) |
---|
| | // public URIAddressedEntity create(@PathParam("instanceId") String instanceId, @FormParam("name") String name, |
---|
| | // @FormParam("region") Plain[] region, @FormParam("permissions") HashSet<Allowed> permissions) { |
---|
| | // Instance instance = Instances.getInstance().getInstance(instanceId); |
---|
| | // IDAddressedEntity ae = instance.createArea(name, region, permissions); |
---|
| | // return new URIAddressedEntity((INSTANCES_URI + "/" + instanceId + "/areas/" + ae.getId()), ae.getBody()); |
---|
| | // } |
---|
| | // |
---|
| | // @Path("/{instanceId}/objects") |
---|
| | // @POST |
---|
| | // @Produces(MediaType.APPLICATION_JSON) |
---|
| | // public URIAddressedEntity create(@PathParam("instanceId") String instanceId, @FormParam("position") Position3D position, |
---|
| | // @FormParam("velocity") Velocity3D velocity, @FormParam("angularVelocity") AngularVelocity3D angularVelocity, |
---|
| | // @FormParam("angle") Angle angle, @FormParam("attribute") Attribute attribute, @FormParam("model") ObjectModel model) { |
---|
| | // Instance instance = Instances.getInstance().getInstance(instanceId); |
---|
| | // IDAddressedEntity ae = instance.createObject(position, velocity, angularVelocity, angle, attribute, model); |
---|
| | // return new URIAddressedEntity((INSTANCES_URI + "/" + instanceId + "/objects/" + ae.getId()), ae.getBody()); |
---|
| | // } |
---|
| | // |
---|
| | @POST |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public URIAddressedEntity create(@FormParam("int") int a, @FormParam("name") String name, @FormParam("state") Instance.State state, @FormParam("stageModel") String stageModel) { |
---|
| | System.out.println(a); |
---|
| | IDAddressedEntity ae = Instances.getInstance().createInstance(name, Instance.State.AVAILABLE, "11111"); |
---|
| | return new URIAddressedEntity((INSTANCES_URI + "/" + ae.getId()), ae.getBody()); |
---|
| | } |
---|
| | |
---|
| | @Path("/{instanceId}/areas") |
---|
| | @POST |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public URIAddressedEntity createArea(@PathParam("instanceId") String instanceId, @FormParam("name") String name, |
---|
| | @FormParam("region") Plain[] region, @FormParam("permissions") HashSet<Allowed> permissions) { |
---|
| | Instance instance = Instances.getInstance().getInstance(instanceId); |
---|
| | IDAddressedEntity ae = instance.createArea(name, region, permissions); |
---|
| | return new URIAddressedEntity((INSTANCES_URI + "/" + instanceId + "/areas/" + ae.getId()), ae.getBody()); |
---|
| | } |
---|
| | |
---|
| | @Path("/{instanceId}/objects") |
---|
| | @POST |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public URIAddressedEntity create(@PathParam("instanceId") String instanceId, @FormParam("position") Position3D position, |
---|
| | @FormParam("velocity") Velocity3D velocity, @FormParam("angularVelocity") AngularVelocity3D angularVelocity, |
---|
| | @FormParam("angle") Angle angle, @FormParam("attribute") Attribute attribute, @FormParam("model") ObjectModel model) { |
---|
| | Instance instance = Instances.getInstance().getInstance(instanceId); |
---|
| | IDAddressedEntity ae = instance.createObject(position, velocity, angularVelocity, angle, attribute, model); |
---|
| | return new URIAddressedEntity((INSTANCES_URI + "/" + instanceId + "/objects/" + ae.getId()), ae.getBody()); |
---|
| | } |
---|
| | |
---|
| | |
---|
| | // @DELETE |
---|
| | // @Path("/destroyInstance") |
---|
| | // @Produces(MediaType.APPLICATION_JSON) |
---|
| |
---|
| | |