@POST @Path("{id}/imagenes/remove") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response removeImages(@PathParam(value = "id") Long id, List<String> images) { try { Producto p = em.find(Producto.class, id); List<String> images_old = new ArrayList<>(); if (p.getImagenes() != null && !p.getImagenes().equals("")) { images_old = Arrays.asList(p.getImagenes().split(",")); } HashSet<String> set = new HashSet<>(images_old); set.removeAll(images); String joined = String.join(",", set); p.setImagenes(joined); // update doc mongo DataProducto dp = p.getDataProducto(); new MongoController().upsertProduct(dp); return Response.status(200).entity(dp).build(); } catch (Exception e) { e.printStackTrace(); DataResponse dr = new DataResponse(); dr.setMensaje("Error remover imagenes"); dr.setDescripcion("Problema en mongodb"); return Response.status(500).entity(dr).build(); } }