@Test(expected = WebApplicationException.class) public void testUploadScreenshotForNonExistingScreen() throws Exception { UploadHelper.simulateFileUpload(requestMock, "600x400.png", "image/png"); fileService.uploadScreenshot("nonexisting"); }
@POST @Path("/screenkey/{key}") public Response uploadScreenshot(@PathParam("key") String key) { Screen existingScreen = ScreenDAO.getScreenByKey(key); if (existingScreen == null) { throwNotFound(); } boolean uploadFile = false; if (existingScreen.isScreenshotMode() && existingScreen.getMetric_playlistTime() > 10) { long pageId = existingScreen.getMetric_currentPageId(); Page existingPage = getExistingPage(pageId, false); if (existingPage != null) { uploadFile = true; File existingFile = doUploadScreenshot(key + "_" + pageId + "_auto", "int_screenshot_" + pageId + "_", Consts.xDim, Consts.yDim); existingPage.setAutoScreenshot(existingFile); PageDAO.save(existingPage); } } if (!uploadFile) { doUploadScreenshot(key, "int_screenshot_", 1280, 720); Date eventDate = new Date(); existingScreen.setLastContainerAlive(eventDate); existingScreen = ScreenDAO.save(existingScreen); EventHistoryDAO.save(new EventHistory(existingScreen.getId(), eventDate)); } return RESPONSE_OK; }
FileService extends BasicService implements OwnerAPISupport<File> { @POST @Path("/screenkey/{key}") public Response uploadScreenshot(@PathParam("key") String key) { Screen existingScreen = ScreenDAO.getScreenByKey(key); if (existingScreen == null) { throwNotFound(); } boolean uploadFile = false; if (existingScreen.isScreenshotMode() && existingScreen.getMetric_playlistTime() > 10) { long pageId = existingScreen.getMetric_currentPageId(); Page existingPage = getExistingPage(pageId, false); if (existingPage != null) { uploadFile = true; File existingFile = doUploadScreenshot(key + "_" + pageId + "_auto", "int_screenshot_" + pageId + "_", Consts.xDim, Consts.yDim); existingPage.setAutoScreenshot(existingFile); PageDAO.save(existingPage); } } if (!uploadFile) { doUploadScreenshot(key, "int_screenshot_", 1280, 720); Date eventDate = new Date(); existingScreen.setLastContainerAlive(eventDate); existingScreen = ScreenDAO.save(existingScreen); EventHistoryDAO.save(new EventHistory(existingScreen.getId(), eventDate)); } return RESPONSE_OK; } }
FileService extends BasicService implements OwnerAPISupport<File> { @POST @Path("/screenkey/{key}") public Response uploadScreenshot(@PathParam("key") String key) { Screen existingScreen = ScreenDAO.getScreenByKey(key); if (existingScreen == null) { throwNotFound(); } boolean uploadFile = false; if (existingScreen.isScreenshotMode() && existingScreen.getMetric_playlistTime() > 10) { long pageId = existingScreen.getMetric_currentPageId(); Page existingPage = getExistingPage(pageId, false); if (existingPage != null) { uploadFile = true; File existingFile = doUploadScreenshot(key + "_" + pageId + "_auto", "int_screenshot_" + pageId + "_", Consts.xDim, Consts.yDim); existingPage.setAutoScreenshot(existingFile); PageDAO.save(existingPage); } } if (!uploadFile) { doUploadScreenshot(key, "int_screenshot_", 1280, 720); Date eventDate = new Date(); existingScreen.setLastContainerAlive(eventDate); existingScreen = ScreenDAO.save(existingScreen); EventHistoryDAO.save(new EventHistory(existingScreen.getId(), eventDate)); } return RESPONSE_OK; }  }
FileService extends BasicService implements OwnerAPISupport<File> { @POST @Path("/screenkey/{key}") public Response uploadScreenshot(@PathParam("key") String key) { Screen existingScreen = ScreenDAO.getScreenByKey(key); if (existingScreen == null) { throwNotFound(); } boolean uploadFile = false; if (existingScreen.isScreenshotMode() && existingScreen.getMetric_playlistTime() > 10) { long pageId = existingScreen.getMetric_currentPageId(); Page existingPage = getExistingPage(pageId, false); if (existingPage != null) { uploadFile = true; File existingFile = doUploadScreenshot(key + "_" + pageId + "_auto", "int_screenshot_" + pageId + "_", Consts.xDim, Consts.yDim); existingPage.setAutoScreenshot(existingFile); PageDAO.save(existingPage); } } if (!uploadFile) { doUploadScreenshot(key, "int_screenshot_", 1280, 720); Date eventDate = new Date(); existingScreen.setLastContainerAlive(eventDate); existingScreen = ScreenDAO.save(existingScreen); EventHistoryDAO.save(new EventHistory(existingScreen.getId(), eventDate)); } return RESPONSE_OK; }  @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(); }
FileService extends BasicService implements OwnerAPISupport<File> { @POST @Path("/screenkey/{key}") public Response uploadScreenshot(@PathParam("key") String key) { Screen existingScreen = ScreenDAO.getScreenByKey(key); if (existingScreen == null) { throwNotFound(); } boolean uploadFile = false; if (existingScreen.isScreenshotMode() && existingScreen.getMetric_playlistTime() > 10) { long pageId = existingScreen.getMetric_currentPageId(); Page existingPage = getExistingPage(pageId, false); if (existingPage != null) { uploadFile = true; File existingFile = doUploadScreenshot(key + "_" + pageId + "_auto", "int_screenshot_" + pageId + "_", Consts.xDim, Consts.yDim); existingPage.setAutoScreenshot(existingFile); PageDAO.save(existingPage); } } if (!uploadFile) { doUploadScreenshot(key, "int_screenshot_", 1280, 720); Date eventDate = new Date(); existingScreen.setLastContainerAlive(eventDate); existingScreen = ScreenDAO.save(existingScreen); EventHistoryDAO.save(new EventHistory(existingScreen.getId(), eventDate)); } return RESPONSE_OK; }  @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();  }