Example #1
0
 @Path("/deleteformbyid")
 @POST
 @Consumes(MediaType.APPLICATION_JSON)
 public Response deleteForm(
     @QueryParam("token") String token, @QueryParam("formid") String formID) {
   try {
     Utils.verify(token, 1);
   } catch (Exception ex) {
     return Response.status(401).entity(ex.getMessage()).build();
   }
   try {
     comp.nuhs.jaxb.Model.Form form = new comp.nuhs.jaxb.Model.Form();
     form.setFormID(formID);
     form.deleteForm();
     return Response.status(201).entity("").build();
   } catch (Exception ex) {
     return Response.status(400).entity(ex.getMessage()).build();
   }
 }
Example #2
0
 @Path("/getformbyid")
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public Response getForm(@QueryParam("token") String token, @QueryParam("formid") String formID) {
   try {
     String a = formID;
     a.equals("");
     Utils.verify(token, 2);
   } catch (Exception ex) {
     return Response.status(401).entity(ex.getMessage()).build();
   }
   comp.nuhs.jaxb.Model.Form form = new comp.nuhs.jaxb.Model.Form();
   try {
     form.setFormID(formID);
     form = form.getForm();
     return Response.status(201).entity(form).build();
   } catch (Exception ex) {
     return Response.status(400).entity(ex.getMessage()).build();
   }
 }
Example #3
0
 @Path("/getallforms")
 @GET
 @Produces(MediaType.APPLICATION_JSON)
 public Response getFormList(@QueryParam("token") String token) {
   try {
     Utils.verify(token, 2);
   } catch (Exception ex) {
     return Response.status(401).entity(ex.getMessage()).build();
   }
   ArrayList<comp.nuhs.jaxb.Model.Form> forms = null;
   comp.nuhs.jaxb.Model.Form form = new comp.nuhs.jaxb.Model.Form();
   try {
     forms = form.getFormList();
     if (forms.isEmpty()) return Response.status(404).entity("").build();
     GenericEntity<List<comp.nuhs.jaxb.Model.Form>> entity =
         new GenericEntity<List<comp.nuhs.jaxb.Model.Form>>(forms) {};
     return Response.status(201).entity(entity).build();
   } catch (Exception ex) {
     return Response.status(400).entity(ex.getMessage()).build();
   }
 }
Example #4
0
  @Path("/addform")
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  public Response addForm(@QueryParam("token") String token, comp.nuhs.jaxb.Model.Form form) {
    try {
      Utils.verify(token, 2);
    } catch (Exception ex) {
      return Response.status(401).entity(ex.getMessage()).build();
    }

    try {
      form.addForm();
      return Response.status(201).entity("").build();
    } catch (Exception ex) {
      return Response.status(400).entity(ex.getMessage()).build();
    }
  }