| | package com.ntlab.irisserver.resources; |
---|
| | |
---|
| | import com.ntlab.irisserver.utils.Base64Decode; |
---|
| | import org.apache.catalina.core.ApplicationContext; |
---|
| | import org.springframework.context.ApplicationContextAware; |
---|
| | import org.springframework.beans.BeansException; |
---|
| | import org.springframework.stereotype.Component; |
---|
| | |
---|
| | import javax.ws.rs.*; |
---|
| | import java.io.IOException; |
---|
| | |
---|
| | @Component |
---|
| | @Path("/rooms") |
---|
| | public class DrawingsRest { |
---|
| | |
---|
| | private ApplicationContext applicationContext; |
---|
| | |
---|
| | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
---|
| | this.applicationContext = applicationContext; |
---|
| | } |
---|
| | |
---|
| | @GET |
---|
| | @Path("/{rid}/game/drawings") |
---|
| | public String getDrawings(@PathParam("rid") int rid) { |
---|
| | public String getDrawings(@PathParam("rid") String rid) { |
---|
| | // 絵のデータ取得 |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | @GET |
---|
| | @Path("/{rid}/game/drawings/{dno}") |
---|
| | public String getDrawing(@PathParam("rid") int rid, @PathParam("dno") String dno ) { |
---|
| | public String getDrawing(@PathParam("rid") String rid, @PathParam("dno") int dno ) { |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | @PUT |
---|
| | @Path("/{rid}/game/drawings/{dno}") |
---|
| | public String putDrawing(@PathParam("rid") int rid, @PathParam("dno") String dno ) { |
---|
| | public String putDrawing(@PathParam("rid") String rid, @PathParam("dno") int dno, @FormParam("drawing") String drawing ) { |
---|
| | |
---|
| | String path1 = ""; |
---|
| | String path = ""; |
---|
| | |
---|
| | try { |
---|
| | path1 = applicationContext.getResource("file:").getFile(); |
---|
| | // 下記が本物だけど上手くいかない。。。 |
---|
| | //path1 = applicationContext.getResource("file:").getFile().getAbsolutePath() +"/apache-tomcat-9.0.10"+ "/webapps"; |
---|
| | System.out.println("0"+ path1.toString()); |
---|
| | System.out.println("!!!クライアントから届いたBASE64の文字列!!!:" + drawing.toString()); |
---|
| | path = Base64Decode.saveAsFile(rid, dno, path1, drawing); |
---|
| | |
---|
| | } catch (IOException e) { |
---|
| | e.printStackTrace(); |
---|
| | throw new WebApplicationException(500); |
---|
| | } |
---|
| | |
---|
| | // いったんnullにしとく |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | } |
---|
| | |