| |
---|
| | import cactusServer.entities.Instance.State; |
---|
| | import cactusServer.entities.Plain; |
---|
| | import cactusServer.entities.Player; |
---|
| | import cactusServer.models.Instances; |
---|
| | import net.arnx.jsonic.JSON; |
---|
| | |
---|
| | @Path("/instances") |
---|
| | @RequestScoped |
---|
| | public class InstancesRest { |
---|
| |
---|
| | public InstancesRest() { |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
---|
| | |
---|
| | |
---|
| | // @Path("/test") |
---|
| | // @GET |
---|
| | // @Produces(MediaType.TEXT_PLAIN) |
---|
| | // public String hoge() { |
---|
| | // return "deploy jenkins from tomcat"; |
---|
| | // } |
---|
| | |
---|
| | @Path("/{instanceId}") |
---|
| | @GET |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Instance getInstance(@PathParam("instanceId") String instanceId) { |
---|
| | return Instances.getInstance().getInstance(instanceId); |
---|
| | //@Produces(MediaType.APPLICATION_JSON) |
---|
| | @Produces(MediaType.TEXT_PLAIN) |
---|
| | public String getInstance(@PathParam("instanceId") String instanceId) { |
---|
| | return JSON.encode(Instances.getInstance().getInstance(instanceId)); |
---|
| | } |
---|
| | |
---|
| | @Path("{instanceId}/areas") |
---|
| | @GET |
---|
| | //@Produces(MediaType.APPLICATION_JSON) |
---|
| | @Produces(MediaType.TEXT_PLAIN) |
---|
| | public String getArea(@PathParam("areaId") String areaId) { |
---|
| | HashMap<String, Area> areaMap = new HashMap<>(); |
---|
| | return JSON.encode(areaMap); |
---|
| | } |
---|
| | |
---|
| | @Path("/{instanceId}/areas/{areaId}") |
---|
| | @GET |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Area getArea(@PathParam("instanceId") String instanceId, @PathParam("areaId") String areaId) { |
---|
| | //@Produces(MediaType.APPLICATION_JSON) |
---|
| | @Produces(MediaType.TEXT_PLAIN) |
---|
| | public String getArea(@PathParam("instanceId") String instanceId, @PathParam("areaId") String areaId) { |
---|
| | Instance instance = Instances.getInstance().getInstance(instanceId); |
---|
| | if (instance != null) { |
---|
| | return instance.getArea(areaId); |
---|
| | return JSON.encode(instance.getArea(areaId)); |
---|
| | } |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | |
---|
| | |
---|
| | @GET |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public HashMap<String, Instance> getInstances(){ |
---|
| | return Instances.getInstance().getInstances(); |
---|
| | //@Produces(MediaType.APPLICATION_JSON) |
---|
| | @Produces(MediaType.TEXT_PLAIN) |
---|
| | public String getInstances(){ |
---|
| | return JSON.encode(Instances.getInstance().getInstances()); |
---|
| | } |
---|
| | |
---|
| | @POST |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public HashMap<String, Instance> createInstance(@FormParam("name") String name, @FormParam("stageID") int stageID) { |
---|
| | //@Produces(MediaType.APPLICATION_JSON) |
---|
| | @Produces(MediaType.TEXT_PLAIN) |
---|
| | public String createInstance(@FormParam("name") String name, @FormParam("stageID") int stageID) { |
---|
| | HashMap<String, Instance> idMap = Instances.getInstance().createInstance(name, stageID); |
---|
| | HashMap<String, Instance> uriMap = new HashMap<>(); |
---|
| | for (String id : idMap.keySet()) { |
---|
| | String uri = (INSTANCES_URI + "/") + id; |
---|
| | uriMap.put(uri, idMap.get(id)); |
---|
| | } |
---|
| | return uriMap; |
---|
| | return JSON.encode(uriMap); |
---|
| | } |
---|
| | |
---|
| | @Path("/{instanceId}/areas") |
---|
| | @POST |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public HashMap<String, Area> createArea(@PathParam("instanceId") String instanceId, @FormParam("name") String name, |
---|
| | //@Produces(MediaType.APPLICATION_JSON) |
---|
| | @Produces(MediaType.TEXT_PLAIN) |
---|
| | public String createArea(@PathParam("instanceId") String instanceId, @FormParam("name") String name, |
---|
| | @FormParam("region") Plain[] region, @FormParam("permissions") HashSet<Allowed> permissions) { |
---|
| | Instance instance = Instances.getInstance().getInstance(instanceId); |
---|
| | HashMap<String, Area> idMap = instance.createArea(name, region, permissions); |
---|
| | HashMap<String, Area> uriMap = new HashMap<>(); |
---|
| | for (String id : idMap.keySet()) { |
---|
| | String uri = (INSTANCES_URI + "/" + instanceId + "/areas/") + id; |
---|
| | uriMap.put(uri, idMap.get(id)); |
---|
| | } |
---|
| | return uriMap; |
---|
| | return JSON.encode(uriMap); |
---|
| | } |
---|
| | |
---|
| | @Path("/{instanceId}") |
---|
| | @PUT |
---|
| | @Produces(MediaType.APPLICATION_JSON) |
---|
| | public Instance updateInstance(@PathParam("instanceId") String instanceId, @FormParam("state") Instance.State state) { |
---|
| | //@Produces(MediaType.APPLICATION_JSON) |
---|
| | @Produces(MediaType.TEXT_PLAIN) |
---|
| | public String updateInstance(@PathParam("instanceId") String instanceId, @FormParam("state") Instance.State state) { |
---|
| | Instance instance = Instances.getInstance().getInstance(instanceId); |
---|
| | return instance.update(state); |
---|
| | return JSON.encode(instance.update(state)); |
---|
| | } |
---|
| | |
---|
| | // @Path("/{instanceId}") |
---|
| | // @PUT |
---|
| | // @Produces(MediaType.APPLICATION_JSON) |
---|
| | // public Instance updateInstance(@FormParam("state") State state) { |
---|
| | // return Instances.getInstance(name, state, stageID) |
---|
| | // } |
---|
| | |
---|
| | |
---|
| | |
---|
| | |
---|
| | // @Path("/test") |
---|
| | // @GET |
---|
| | // @Produces(MediaType.TEXT_PLAIN) |
---|
| | // public String hoge() { |
---|
| | // return "deploy jenkins from tomcat"; |
---|
| | // } |
---|
| | |
---|
| | // @DELETE |
---|
| | // @Path("/destroyInstance") |
---|
| | // @Produces(MediaType.APPLICATION_JSON) |
---|
| | // public Instance destroy(@QueryParam("instanceId") String instanceId) { |
---|
| | // return Instances.getInstance().destroyInstance(instanceId); |
---|
| | // } |
---|
| | |
---|
| | // |
---|
| | // @Path("/{instanceId}") |
---|
| | // @PUT |
---|
| | // public Instance putInstance(@PathParam("InstanceId") String instanceId, |
---|
| | // @FormParam("areaId") String areaId, |
---|
| | // @FormParam("objectId") String objectId, @FormParam("characterId") String |
---|
| | // characterId) { |
---|
| | // |
---|
| | // } |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
確認お願いします
確認しました
784272f
intomaster
fromInstancesRest3
on 31 Jul 2018