@GET
 @Path("handle")
 @Produces({"application/pdf"})
 public Response handle(@QueryParam("handle") String handle) {
   final File pFile = PDFExlusiveGenerateSupport.popFile(handle);
   if (pFile != null) {
     try {
       final InputStream fis = new FileInputStream(pFile);
       StreamingOutput stream =
           new StreamingOutput() {
             public void write(OutputStream output) throws IOException, WebApplicationException {
               try {
                 IOUtils.copyStreams(fis, output);
               } catch (Exception e) {
                 throw new WebApplicationException(e);
               } finally {
                 if (pFile != null) pFile.delete();
               }
             }
           };
       SimpleDateFormat sdate = new SimpleDateFormat("yyyyMMdd_mmhhss");
       return Response.ok()
           .header(
               "Content-disposition", "attachment; filename=" + sdate.format(new Date()) + ".pdf")
           .entity(stream)
           .build();
     } catch (FileNotFoundException e) {
       throw new PDFResourceNotFound("uuid not found");
     }
   } else {
     throw new PDFResourceNotFound("uuid not found");
   }
 }
 public JSONObject outputJSON(File generatedPDF)
     throws IOException, COSVisitorException, JSONException {
   String uuid = UUID.randomUUID().toString();
   PDFExlusiveGenerateSupport.pushFile(uuid, generatedPDF);
   JSONObject obj = new JSONObject();
   obj.put("handle", uuid);
   return obj;
 }