diff --git a/src/main/java/com/oggio88/jpacrepo/service/PacmanWebService.java b/src/main/java/com/oggio88/jpacrepo/service/PacmanWebService.java index 70a8e7b..3a3ab7f 100644 --- a/src/main/java/com/oggio88/jpacrepo/service/PacmanWebService.java +++ b/src/main/java/com/oggio88/jpacrepo/service/PacmanWebService.java @@ -29,9 +29,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.io.*; import java.net.URI; import java.nio.file.Files; -import java.util.List; -import java.util.SortedMap; -import java.util.TreeMap; +import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -284,6 +282,22 @@ public class PacmanWebService } } + @POST + @Path("/doYouWantAny") + @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) + public Response doYouWantAny(List filenames) + { + Set result = new HashSet<>(filenames); + if(!result.isEmpty()) + { + TypedQuery query = em.createQuery("SELECT pkg.fileName from PkgData pkg WHERE pkg.fileName in :filenames", String.class); + query.setParameter("filenames", filenames); + Set toBeRemoved = new HashSet(query.getResultList()); + result.removeAll(toBeRemoved); + } + return Response.ok(result).build(); + } + @POST @Path("/upload") @Consumes(MediaType.APPLICATION_OCTET_STREAM) @@ -466,7 +480,7 @@ public class PacmanWebService } } }; - return Response.ok(stream).build(); + return Response.ok(stream).header("Content-Disposition", "attachment; filename=pkgs.tar").build(); } private Response manageQueryResult(List list)