@Test(expected = WebApplicationException.class) public void testGetNonExistingScreen() throws Exception { assertNull(screenService.getScreen(-1, true, false)); }
@GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) public Screen getScreen(@PathParam("id") long screenId, @DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics, @DefaultValue("false") @QueryParam("live") boolean live) { Screen result = null; if (screenId == 0) { result = new Screen(); result.setName("Demo Screen"); result.setShowOwners(true); User user = new User("d046998", "robert.wetzold@sap.com", "Robert", "Wetzold"); user.updateDynamicValues(); File movie = new File("-PrimeTime Teaser-"); movie.setId(-1); Playlist playlist = new Playlist(); Page page0 = new Page("Introduction"); page0.addOwner(new Owner(user)); page0.setPageType(PageType.MOVIE); page0.setFile(movie); page0.updateDynamicValues(); PageReference pageRef0 = new PageReference(page0); pageRef0.setPageDisplayDurationOverride(12); playlist.addPageReference(pageRef0); Page page1 = new Page("Introduction"); page1.addOwner(new Owner(user)); page1.setPageType(PageType.TEXT); page1.setText("This is a demo for PrimeTime, your simple solution to create wall screen presentations, aka digital signage."); page1.updateDynamicValues(); playlist.addPageReference(new PageReference(page1)); Page page2 = new Page("Getting Started"); page2.addOwner(new Owner(user)); page2.setPageType(PageType.TEXT); page2.setText( "To get started, create your pages and put them together into your own playlist.</p><p>You can show one or multiple URLs, PDFs, images, movies, formatted texts or HTML."); page2.updateDynamicValues(); playlist.addPageReference(new PageReference(page2)); Page page3 = new Page("Contribute"); page3.addOwner(new Owner(user)); page3.setPageType(PageType.TEXT); page3.setText( "This is an open source tool by SAP. If you want to contribute, please feel invited to do so."); page3.updateDynamicValues(); playlist.addPageReference(new PageReference(page3)); String devUrl = ConfigUtil.getProperty(Consts.APP, Consts.PROP_DEVELOPMENTURL); if (StringUtils.isNoneEmpty(devUrl)) { Page page4 = new Page("Source Code"); page4.addOwner(new Owner(user)); page4.setUrl(devUrl); page4.updateDynamicValues(); playlist.addPageReference(new PageReference(page4)); } result.setPlaylist(playlist); } else { result = getExistingScreen(screenId, false); checkRemoteValidity(result); if (result.getOwners().isEmpty() && !isAdmin()) { throwUnauthorized(); } if (result.isScreenshotMode() && live) { result.setPlaylist(getScreenshotPlaylist()); result.setShowHeader(false); result.setShowFooter(false); } if (result.getPlaylist() != null) { result.getPlaylist().expand(); } if (!includeMetrics) { removeMetrics(result); } } return result; }
ScreenService extends BasicService implements OwnerAPISupport<Screen> { @GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) public Screen getScreen(@PathParam("id") long screenId, @DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics, @DefaultValue("false") @QueryParam("live") boolean live) { Screen result = null; if (screenId == 0) { result = new Screen(); result.setName("Demo Screen"); result.setShowOwners(true); User user = new User("d046998", "robert.wetzold@sap.com", "Robert", "Wetzold"); user.updateDynamicValues(); File movie = new File("-PrimeTime Teaser-"); movie.setId(-1); Playlist playlist = new Playlist(); Page page0 = new Page("Introduction"); page0.addOwner(new Owner(user)); page0.setPageType(PageType.MOVIE); page0.setFile(movie); page0.updateDynamicValues(); PageReference pageRef0 = new PageReference(page0); pageRef0.setPageDisplayDurationOverride(12); playlist.addPageReference(pageRef0); Page page1 = new Page("Introduction"); page1.addOwner(new Owner(user)); page1.setPageType(PageType.TEXT); page1.setText("This is a demo for PrimeTime, your simple solution to create wall screen presentations, aka digital signage."); page1.updateDynamicValues(); playlist.addPageReference(new PageReference(page1)); Page page2 = new Page("Getting Started"); page2.addOwner(new Owner(user)); page2.setPageType(PageType.TEXT); page2.setText( "To get started, create your pages and put them together into your own playlist.</p><p>You can show one or multiple URLs, PDFs, images, movies, formatted texts or HTML."); page2.updateDynamicValues(); playlist.addPageReference(new PageReference(page2)); Page page3 = new Page("Contribute"); page3.addOwner(new Owner(user)); page3.setPageType(PageType.TEXT); page3.setText( "This is an open source tool by SAP. If you want to contribute, please feel invited to do so."); page3.updateDynamicValues(); playlist.addPageReference(new PageReference(page3)); String devUrl = ConfigUtil.getProperty(Consts.APP, Consts.PROP_DEVELOPMENTURL); if (StringUtils.isNoneEmpty(devUrl)) { Page page4 = new Page("Source Code"); page4.addOwner(new Owner(user)); page4.setUrl(devUrl); page4.updateDynamicValues(); playlist.addPageReference(new PageReference(page4)); } result.setPlaylist(playlist); } else { result = getExistingScreen(screenId, false); checkRemoteValidity(result); if (result.getOwners().isEmpty() && !isAdmin()) { throwUnauthorized(); } if (result.isScreenshotMode() && live) { result.setPlaylist(getScreenshotPlaylist()); result.setShowHeader(false); result.setShowFooter(false); } if (result.getPlaylist() != null) { result.getPlaylist().expand(); } if (!includeMetrics) { removeMetrics(result); } } return result; } }
ScreenService extends BasicService implements OwnerAPISupport<Screen> { @GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) public Screen getScreen(@PathParam("id") long screenId, @DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics, @DefaultValue("false") @QueryParam("live") boolean live) { Screen result = null; if (screenId == 0) { result = new Screen(); result.setName("Demo Screen"); result.setShowOwners(true); User user = new User("d046998", "robert.wetzold@sap.com", "Robert", "Wetzold"); user.updateDynamicValues(); File movie = new File("-PrimeTime Teaser-"); movie.setId(-1); Playlist playlist = new Playlist(); Page page0 = new Page("Introduction"); page0.addOwner(new Owner(user)); page0.setPageType(PageType.MOVIE); page0.setFile(movie); page0.updateDynamicValues(); PageReference pageRef0 = new PageReference(page0); pageRef0.setPageDisplayDurationOverride(12); playlist.addPageReference(pageRef0); Page page1 = new Page("Introduction"); page1.addOwner(new Owner(user)); page1.setPageType(PageType.TEXT); page1.setText("This is a demo for PrimeTime, your simple solution to create wall screen presentations, aka digital signage."); page1.updateDynamicValues(); playlist.addPageReference(new PageReference(page1)); Page page2 = new Page("Getting Started"); page2.addOwner(new Owner(user)); page2.setPageType(PageType.TEXT); page2.setText( "To get started, create your pages and put them together into your own playlist.</p><p>You can show one or multiple URLs, PDFs, images, movies, formatted texts or HTML."); page2.updateDynamicValues(); playlist.addPageReference(new PageReference(page2)); Page page3 = new Page("Contribute"); page3.addOwner(new Owner(user)); page3.setPageType(PageType.TEXT); page3.setText( "This is an open source tool by SAP. If you want to contribute, please feel invited to do so."); page3.updateDynamicValues(); playlist.addPageReference(new PageReference(page3)); String devUrl = ConfigUtil.getProperty(Consts.APP, Consts.PROP_DEVELOPMENTURL); if (StringUtils.isNoneEmpty(devUrl)) { Page page4 = new Page("Source Code"); page4.addOwner(new Owner(user)); page4.setUrl(devUrl); page4.updateDynamicValues(); playlist.addPageReference(new PageReference(page4)); } result.setPlaylist(playlist); } else { result = getExistingScreen(screenId, false); checkRemoteValidity(result); if (result.getOwners().isEmpty() && !isAdmin()) { throwUnauthorized(); } if (result.isScreenshotMode() && live) { result.setPlaylist(getScreenshotPlaylist()); result.setShowHeader(false); result.setShowFooter(false); } if (result.getPlaylist() != null) { result.getPlaylist().expand(); } if (!includeMetrics) { removeMetrics(result); } } return result; }  }
ScreenService extends BasicService implements OwnerAPISupport<Screen> { @GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) public Screen getScreen(@PathParam("id") long screenId, @DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics, @DefaultValue("false") @QueryParam("live") boolean live) { Screen result = null; if (screenId == 0) { result = new Screen(); result.setName("Demo Screen"); result.setShowOwners(true); User user = new User("d046998", "robert.wetzold@sap.com", "Robert", "Wetzold"); user.updateDynamicValues(); File movie = new File("-PrimeTime Teaser-"); movie.setId(-1); Playlist playlist = new Playlist(); Page page0 = new Page("Introduction"); page0.addOwner(new Owner(user)); page0.setPageType(PageType.MOVIE); page0.setFile(movie); page0.updateDynamicValues(); PageReference pageRef0 = new PageReference(page0); pageRef0.setPageDisplayDurationOverride(12); playlist.addPageReference(pageRef0); Page page1 = new Page("Introduction"); page1.addOwner(new Owner(user)); page1.setPageType(PageType.TEXT); page1.setText("This is a demo for PrimeTime, your simple solution to create wall screen presentations, aka digital signage."); page1.updateDynamicValues(); playlist.addPageReference(new PageReference(page1)); Page page2 = new Page("Getting Started"); page2.addOwner(new Owner(user)); page2.setPageType(PageType.TEXT); page2.setText( "To get started, create your pages and put them together into your own playlist.</p><p>You can show one or multiple URLs, PDFs, images, movies, formatted texts or HTML."); page2.updateDynamicValues(); playlist.addPageReference(new PageReference(page2)); Page page3 = new Page("Contribute"); page3.addOwner(new Owner(user)); page3.setPageType(PageType.TEXT); page3.setText( "This is an open source tool by SAP. If you want to contribute, please feel invited to do so."); page3.updateDynamicValues(); playlist.addPageReference(new PageReference(page3)); String devUrl = ConfigUtil.getProperty(Consts.APP, Consts.PROP_DEVELOPMENTURL); if (StringUtils.isNoneEmpty(devUrl)) { Page page4 = new Page("Source Code"); page4.addOwner(new Owner(user)); page4.setUrl(devUrl); page4.updateDynamicValues(); playlist.addPageReference(new PageReference(page4)); } result.setPlaylist(playlist); } else { result = getExistingScreen(screenId, false); checkRemoteValidity(result); if (result.getOwners().isEmpty() && !isAdmin()) { throwUnauthorized(); } if (result.isScreenshotMode() && live) { result.setPlaylist(getScreenshotPlaylist()); result.setShowHeader(false); result.setShowFooter(false); } if (result.getPlaylist() != null) { result.getPlaylist().expand(); } if (!includeMetrics) { removeMetrics(result); } } return result; }  @GET @Path("/screens") @Produces(MediaType.APPLICATION_JSON) List<Screen> getScreens(@QueryParam("userId") String userId); @GET @Path("/onboardings") @Produces(MediaType.APPLICATION_JSON) List<Screen> getOnboardings(); @GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) Screen getScreen(@PathParam("id") long screenId,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics,
			@DefaultValue("false") @QueryParam("live") boolean live); @GET @Path("/screens/bykey/{key}") @Produces(MediaType.APPLICATION_JSON) Screen getScreenByKey(@PathParam("key") String key,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics,
			@DefaultValue("false") @QueryParam("live") boolean live,
			@DefaultValue("false") @QueryParam("autoOnboard") boolean doOnboarding,
			@QueryParam("owner") String requestedOwner); @POST @Path("/screens") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Screen createScreen(Screen screen); @PUT @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) Screen updateScreen(@PathParam("id") long screenId, Screen screenData); @PUT @Path("/screens/{id}/statistics") @Produces(MediaType.APPLICATION_JSON) Screen updateScreenStatstics(@PathParam("id") long screenId, Screen screenData); @GET @Path("/screens/{id}/health") @Produces(MediaType.APPLICATION_JSON) Screen.AliveState getScreenHealth(@PathParam("id") long screenId); @GET @Path("/screens/{id}/events") @Produces(MediaType.APPLICATION_JSON) List<EventHistory> getScreenEvents(@PathParam("id") long screenId); @GET @Path("/screens/{id}/eventsperhour") @Produces(MediaType.APPLICATION_JSON) List<BasicNameValuePair> getScreenEventsPerHour(@PathParam("id") long screenId); @GET @Path("/screens/{id}/control") @Produces(MediaType.APPLICATION_JSON) Integer getRemoteKey(@PathParam("id") long screenId); @PUT @Path("/screens/{id}/control/{key}") @Produces(MediaType.APPLICATION_JSON) Screen remoteControlScreen(@PathParam("id") long screenId, Screen screenData, @PathParam("key") int key); @POST @Path("/screens/{id}/copy") @Consumes(MediaType.APPLICATION_JSON) Screen copyScreen(@PathParam("id") long screenId, Screen newScreen); @PUT @Path("/screens/{id}/requestedOwner") @Produces(MediaType.APPLICATION_JSON) Screen updateRequestedOwner(@PathParam("id") long screenId, Screen screenData); @POST @Path("/screens/{id}/onboard") @Produces(MediaType.APPLICATION_JSON) Screen onboardScreen(@PathParam("id") long screenId); @POST @Path("/claim/{key}") @Produces(MediaType.APPLICATION_JSON) Screen claimScreen(@PathParam("key") String key, @DefaultValue("0") @QueryParam("screenId") long screenId); @DELETE @Path("/screens/{screenId}") Response deleteScreen(@PathParam("screenId") long screenId); @Override @POST @Path("/screens/{screenId}/owners") @Consumes(MediaType.APPLICATION_JSON) Screen addOwners(@PathParam("screenId") long screenId, Owner[] ownerData); @Override @DELETE @Path("/screens/{screenId}/owners/{ownerId}") @Produces(MediaType.APPLICATION_JSON) Screen deleteOwner(@PathParam("screenId") long screenId, @PathParam("ownerId") long ownerId); @POST @Path("/screenkey/{key}/appliancestart") @Consumes(MediaType.APPLICATION_JSON) Response registerApplianceStart(@PathParam("key") String key, ApplianceInfo logContent); }
ScreenService extends BasicService implements OwnerAPISupport<Screen> { @GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) public Screen getScreen(@PathParam("id") long screenId, @DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics, @DefaultValue("false") @QueryParam("live") boolean live) { Screen result = null; if (screenId == 0) { result = new Screen(); result.setName("Demo Screen"); result.setShowOwners(true); User user = new User("d046998", "robert.wetzold@sap.com", "Robert", "Wetzold"); user.updateDynamicValues(); File movie = new File("-PrimeTime Teaser-"); movie.setId(-1); Playlist playlist = new Playlist(); Page page0 = new Page("Introduction"); page0.addOwner(new Owner(user)); page0.setPageType(PageType.MOVIE); page0.setFile(movie); page0.updateDynamicValues(); PageReference pageRef0 = new PageReference(page0); pageRef0.setPageDisplayDurationOverride(12); playlist.addPageReference(pageRef0); Page page1 = new Page("Introduction"); page1.addOwner(new Owner(user)); page1.setPageType(PageType.TEXT); page1.setText("This is a demo for PrimeTime, your simple solution to create wall screen presentations, aka digital signage."); page1.updateDynamicValues(); playlist.addPageReference(new PageReference(page1)); Page page2 = new Page("Getting Started"); page2.addOwner(new Owner(user)); page2.setPageType(PageType.TEXT); page2.setText( "To get started, create your pages and put them together into your own playlist.</p><p>You can show one or multiple URLs, PDFs, images, movies, formatted texts or HTML."); page2.updateDynamicValues(); playlist.addPageReference(new PageReference(page2)); Page page3 = new Page("Contribute"); page3.addOwner(new Owner(user)); page3.setPageType(PageType.TEXT); page3.setText( "This is an open source tool by SAP. If you want to contribute, please feel invited to do so."); page3.updateDynamicValues(); playlist.addPageReference(new PageReference(page3)); String devUrl = ConfigUtil.getProperty(Consts.APP, Consts.PROP_DEVELOPMENTURL); if (StringUtils.isNoneEmpty(devUrl)) { Page page4 = new Page("Source Code"); page4.addOwner(new Owner(user)); page4.setUrl(devUrl); page4.updateDynamicValues(); playlist.addPageReference(new PageReference(page4)); } result.setPlaylist(playlist); } else { result = getExistingScreen(screenId, false); checkRemoteValidity(result); if (result.getOwners().isEmpty() && !isAdmin()) { throwUnauthorized(); } if (result.isScreenshotMode() && live) { result.setPlaylist(getScreenshotPlaylist()); result.setShowHeader(false); result.setShowFooter(false); } if (result.getPlaylist() != null) { result.getPlaylist().expand(); } if (!includeMetrics) { removeMetrics(result); } } return result; }  @GET @Path("/screens") @Produces(MediaType.APPLICATION_JSON) List<Screen> getScreens(@QueryParam("userId") String userId); @GET @Path("/onboardings") @Produces(MediaType.APPLICATION_JSON) List<Screen> getOnboardings(); @GET @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) Screen getScreen(@PathParam("id") long screenId,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics,
			@DefaultValue("false") @QueryParam("live") boolean live); @GET @Path("/screens/bykey/{key}") @Produces(MediaType.APPLICATION_JSON) Screen getScreenByKey(@PathParam("key") String key,
			@DefaultValue("true") @QueryParam("includeMetrics") boolean includeMetrics,
			@DefaultValue("false") @QueryParam("live") boolean live,
			@DefaultValue("false") @QueryParam("autoOnboard") boolean doOnboarding,
			@QueryParam("owner") String requestedOwner); @POST @Path("/screens") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Screen createScreen(Screen screen); @PUT @Path("/screens/{id}") @Produces(MediaType.APPLICATION_JSON) Screen updateScreen(@PathParam("id") long screenId, Screen screenData); @PUT @Path("/screens/{id}/statistics") @Produces(MediaType.APPLICATION_JSON) Screen updateScreenStatstics(@PathParam("id") long screenId, Screen screenData); @GET @Path("/screens/{id}/health") @Produces(MediaType.APPLICATION_JSON) Screen.AliveState getScreenHealth(@PathParam("id") long screenId); @GET @Path("/screens/{id}/events") @Produces(MediaType.APPLICATION_JSON) List<EventHistory> getScreenEvents(@PathParam("id") long screenId); @GET @Path("/screens/{id}/eventsperhour") @Produces(MediaType.APPLICATION_JSON) List<BasicNameValuePair> getScreenEventsPerHour(@PathParam("id") long screenId); @GET @Path("/screens/{id}/control") @Produces(MediaType.APPLICATION_JSON) Integer getRemoteKey(@PathParam("id") long screenId); @PUT @Path("/screens/{id}/control/{key}") @Produces(MediaType.APPLICATION_JSON) Screen remoteControlScreen(@PathParam("id") long screenId, Screen screenData, @PathParam("key") int key); @POST @Path("/screens/{id}/copy") @Consumes(MediaType.APPLICATION_JSON) Screen copyScreen(@PathParam("id") long screenId, Screen newScreen); @PUT @Path("/screens/{id}/requestedOwner") @Produces(MediaType.APPLICATION_JSON) Screen updateRequestedOwner(@PathParam("id") long screenId, Screen screenData); @POST @Path("/screens/{id}/onboard") @Produces(MediaType.APPLICATION_JSON) Screen onboardScreen(@PathParam("id") long screenId); @POST @Path("/claim/{key}") @Produces(MediaType.APPLICATION_JSON) Screen claimScreen(@PathParam("key") String key, @DefaultValue("0") @QueryParam("screenId") long screenId); @DELETE @Path("/screens/{screenId}") Response deleteScreen(@PathParam("screenId") long screenId); @Override @POST @Path("/screens/{screenId}/owners") @Consumes(MediaType.APPLICATION_JSON) Screen addOwners(@PathParam("screenId") long screenId, Owner[] ownerData); @Override @DELETE @Path("/screens/{screenId}/owners/{ownerId}") @Produces(MediaType.APPLICATION_JSON) Screen deleteOwner(@PathParam("screenId") long screenId, @PathParam("ownerId") long ownerId); @POST @Path("/screenkey/{key}/appliancestart") @Consumes(MediaType.APPLICATION_JSON) Response registerApplianceStart(@PathParam("key") String key, ApplianceInfo logContent);  }