示例#1
0
 @POST
 @Produces("application/json")
 public String create(@PathParam("sid") String systemIdd, @Context UriInfo ui) {
   String systemId = java.net.URLDecoder.decode(systemIdd);
   MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
   String command = queryParams.getFirst("command");
   SCSCPClient sys = Wupsifer.getInstance().getClients().get(systemId);
   Wupsifer w = Wupsifer.getInstance();
   try {
     w.compute(sys, OpenMathBase.parse(command));
   } catch (Exception ignored) {
     return ("Failure");
   }
   return "OK";
 }
示例#2
0
 @GET
 @Produces("application/json")
 public String index(@PathParam("sid") String systemIdd) {
   String systemId = java.net.URLDecoder.decode(systemIdd);
   Wupsifer w = Wupsifer.getInstance();
   SCSCPClient client = w.getClients().get(systemId);
   if (null == client) return "[]";
   List<Computation> cc = client.getComputations();
   DateFormat df = DateFormat.getInstance();
   JSONStringer js = new JSONStringer();
   try {
     // Begin array
     js.array();
     for (Computation c : cc) {
       js.object();
       js.key("id").value(c.getToken());
       js.key("startedAt").value(df.format(c.getStartedAt()));
       js.key("finishedAt").value(df.format(c.getStartedAt()));
       js.endObject();
     }
     js.endArray();
     // end array
   } catch (Exception e) {
     e.printStackTrace();
     System.exit(1);
   }
   return js.toString();
 }
示例#3
0
 @GET
 @Produces("application/json")
 @Path("/{id}")
 public String show(@PathParam("sid") String systemIdd, @PathParam("id") String idd) {
   String systemId = java.net.URLDecoder.decode(systemIdd);
   String id = java.net.URLDecoder.decode(idd);
   SCSCPClient sys = Wupsifer.getInstance().getClients().get(systemId);
   Computation c = sys.getComputation(id);
   //        System.out.println(" ----> " + c.toString() + " " + id + " " + systemId);
   DateFormat df = DateFormat.getInstance();
   JSONStringer js = new JSONStringer();
   try {
     js.object();
     js.key("id").value(c.getToken());
     js.key("startedAt").value(df.format(c.getStartedAt()));
     js.key("finishedAt").value(df.format(c.getStartedAt()));
     js.key("commandL").value(c.getRequest().toLatex());
     js.key("commandP").value(c.getRequest().toPopcorn());
     js.key("commandX").value(c.getRequest().toXml());
     js.key("resultL").value(c.getResult().toLatex());
     js.key("resultP").value(c.getResult().toPopcorn());
     js.key("resultX").value(c.getResult().toXml());
     js.endObject();
   } catch (Exception e) {
     e.printStackTrace();
     System.exit(1);
   }
   return js.toString();
 }
示例#4
0
 public Wupslet() {
   w = Wupsifer.getInstance();
 }