diff --git a/pom.xml b/pom.xml index 54f7b7c..6e5ed60 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,11 @@ - + + maven-restlet + Public online Restlet repository + http://maven.restlet.org + @@ -59,7 +63,11 @@ dicoogle-sdk 2.0-SNAPSHOT - + + org.restlet.jse + org.restlet.ext.json + 2.1.2 + org.eclipse.jetty diff --git a/src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/JsonWebService.java b/src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/JsonWebService.java new file mode 100644 index 0000000..a9998d7 --- /dev/null +++ b/src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/JsonWebService.java @@ -0,0 +1,58 @@ + +package pt.ieeta.dicoogle.plugin.demo.dicooglepluginsample; + +import org.json.JSONException; +import org.restlet.data.MediaType; +import org.restlet.ext.json.JsonRepresentation; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.restlet.resource.Get; +import org.restlet.resource.Post; +import org.restlet.resource.ServerResource; + +/** + * + * @author Luís A. Bastião Silva - + */ +public class JsonWebService extends ServerResource { + + + @Get + public Representation testJson(){ + StringRepresentation sr = new StringRepresentation("{\"name\":\"rsi\"}"); + + sr.setMediaType(MediaType.APPLICATION_JSON); + + return sr; + } + + + @Post("json") + public JsonRepresentation testJson(JsonRepresentation userJson){ + + org.json.JSONObject userObj = null; + try { + userObj = userJson.getJsonObject(); + System.out.println(userObj.getInt("id")); + System.out.println(userObj.getString("name")); + //return userObj.toString(); + } catch (JSONException e) { + e.printStackTrace(); + } + + + JsonRepresentation sr = new JsonRepresentation("{\"name\":\"rsi\"}"); + + sr.setMediaType(MediaType.APPLICATION_JSON); + + return sr; + } + + // You can handle all crud operations. Please, read the restlet documentation + + + + @Override + public String toString(){return "jsonDemo";} + +} diff --git a/src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIPluginSet.java b/src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIPluginSet.java index 4c20a45..f18b618 100644 --- a/src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIPluginSet.java +++ b/src/main/java/pt/ieeta/dicoogle/plugin/demo/dicooglepluginsample/RSIPluginSet.java @@ -44,6 +44,7 @@ public RSIPluginSet() throws IOException { RSIJettyWebServices = new ArrayList<>(); RSIwebservices.add(new RSIWebService()); + RSIwebservices.add(new JsonWebService()); RSIIndexerList.add(new RSIIndex(memoryDicomDB)); RSIJettyWebServices.add(new RSIJettyPlugin()); RSIQueryList.add(new RSIQuery(memoryDicomDB));