FileService extends BasicService implements OwnerAPISupport<File> { @DELETE @Path("/files/{fileId}") public Response deleteFile(@PathParam("fileId") long fileId) { File existingFile = getExistingFile(fileId, true); getECM().deleteDocumentByName(existingFile.getFileKey(), false); for (Owner owner : existingFile.getOwners()) { new OwnerDAO().deleteById(owner.getId()); } return new FileDAO().deleteById(fileId) ? RESPONSE_OK : RESPONSE_BAD; }  @GET @Path("/files") @Produces(MediaType.APPLICATION_JSON) List<File> getFiles(@QueryParam("userId") String userId); @GET @Path("/files/{fileId}") @Produces(MediaType.APPLICATION_JSON) File getFile(@PathParam("fileId") long id); @PUT @Path("/files/{fileId}") @Produces(MediaType.APPLICATION_JSON) File updateFile(@PathParam("fileId") long fileId, File fileData); @POST @Path("/files") Response uploadFile(); @POST @Path("/files/{fileId}/rotate") Response rotateImage(@PathParam("fileId") long fileId); @POST @Path("/files/{fileId}/content") Response updateFileContent(@PathParam("fileId") long fileId); @DELETE @Path("/files/{fileId}") Response deleteFile(@PathParam("fileId") long fileId); @GET @Path("/files/{fileId}/references") @Produces(MediaType.APPLICATION_JSON) FileReferences getReferences(@PathParam("fileId") long fileId); @GET @Path("/files/{fileId}/content") @Produces({ "image/jpeg,image/png,image/gif,image/bmp,application/pdf,image/svg+xml,image/x-icon,video/mp4" }) Response getFileContent(@PathParam("fileId") long fileId,
			@DefaultValue("false") @QueryParam("thumbnail") boolean thumbnail,
			@DefaultValue("0") @QueryParam("page") int page,
			@DefaultValue("false") @QueryParam("download") boolean download); @GET @Path("/files/{fileId}/content/{path}") @Produces({ "text/html,image/jpeg,image/png,image/gif,image/bmp,application/pdf,image/svg+xml,image/x-icon,video/mp4" }) Response getFileContent(@PathParam("fileId") long fileId, @PathParam("path") String path,
			@DefaultValue("0") @QueryParam("page") long pageId); @Override @POST @Path("/files/{fileId}/owners") @Consumes(MediaType.APPLICATION_JSON) File addOwners(@PathParam("fileId") long fileId, Owner[] ownerData); @Override @DELETE @Path("/files/{fileId}/owners/{ownerId}") @Produces(MediaType.APPLICATION_JSON) File deleteOwner(@PathParam("fileId") long fileId, @PathParam("ownerId") long ownerId); @GET @Path("/screenkey/{key}") @Produces({ "image/jpeg,image/png,image/gif,image/bmp,application/pdf,image/svg+xml,image/x-icon,video/mp4" }) Response getScreenshotContent(@PathParam("key") String key); @POST @Path("/screenkey/{key}") Response uploadScreenshot(@PathParam("key") String key); @GET @Path("/ecm") @Produces(MediaType.APPLICATION_JSON) List<File> getRawECM(); @DELETE @Path("/ecm/{key}") @Produces(MediaType.APPLICATION_JSON) Response deleteECMFile(@PathParam("key") String ecmKey); @POST @Path("/deletethumbnails") Response deleteThumbnails();  }
@Test public void testDeleteFile() throws Exception { fileService.createFile("f1", "jpg", "f1", 99); assertEquals(1, getFiles().size()); fileService.deleteFile(getFiles().get(0).getId()); assertEquals(0, getFiles().size()); }