Пример #1
0
 // FIXME: Enable again (disabled due to ipad content negotiation trouble during mtd2011 demo)
 @Get("xml")
 public Representation serveXMLResult() {
   selectedMime = MimeHelper.XML;
   //		System.out.println("VersionedObjectResource.getRepresentation() returning XML");
   try {
     return getVersionAsXMLRepresentatioFromDatabase();
   } catch (ResourceException e) {
     getResponse().setStatus(e.getStatus());
     return new StringRepresentation(e.toString());
   }
 }
 @Delete("json")
 public Representation batchDelete(final String jsonContent) {
   LOG.info("Batch delete witnesses " + jsonContent);
   JsonParser parser = new JsonParser();
   JsonArray jsonArray = parser.parse(jsonContent).getAsJsonArray();
   Set<Usage> usage = new HashSet<Usage>();
   for (Iterator<JsonElement> itr = jsonArray.iterator(); itr.hasNext(); ) {
     JsonElement ele = itr.next();
     Long id = ele.getAsLong();
     Witness w = this.witnessDao.find(id);
     if (w != null) {
       try {
         usage.addAll(this.remover.remove(w));
       } catch (ResourceException e) {
         LOG.warn(e.toString());
       }
     } else {
       LOG.warn("Witness ID " + id + " is not a valid witness for this workspace");
     }
   }
   Gson gson = new Gson();
   return toJsonRepresentation(gson.toJson(usage));
 }