@Test public void testGetNotifierById() throws Exception { final Notifier notifier = new Notifier(); new Expectations() { { mockCatalogService.getNotifierInfo(anyLong);times=1; result = notifier; } }; Notifier result = (Notifier) resource.getNotifierById(1L, securityContext).getEntity(); assertEquals(notifier, result); }
@GET @Path("/notifiers/{id}") @Timed public Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext) { boolean notifierUser = SecurityUtil.hasRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_USER); if (notifierUser) { LOG.debug("Allowing get Notifier, since user has role: {}", Roles.ROLE_NOTIFIER_USER); } else { SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, id, READ); } Notifier result = catalogService.getNotifierInfo(id); if (result != null) { return WSUtils.respondEntity(result, OK); } throw EntityNotFoundException.byId(id.toString()); }
NotifierInfoCatalogResource { @GET @Path("/notifiers/{id}") @Timed public Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext) { boolean notifierUser = SecurityUtil.hasRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_USER); if (notifierUser) { LOG.debug("Allowing get Notifier, since user has role: {}", Roles.ROLE_NOTIFIER_USER); } else { SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, id, READ); } Notifier result = catalogService.getNotifierInfo(id); if (result != null) { return WSUtils.respondEntity(result, OK); } throw EntityNotFoundException.byId(id.toString()); } }
NotifierInfoCatalogResource { @GET @Path("/notifiers/{id}") @Timed public Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext) { boolean notifierUser = SecurityUtil.hasRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_USER); if (notifierUser) { LOG.debug("Allowing get Notifier, since user has role: {}", Roles.ROLE_NOTIFIER_USER); } else { SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, id, READ); } Notifier result = catalogService.getNotifierInfo(id); if (result != null) { return WSUtils.respondEntity(result, OK); } throw EntityNotFoundException.byId(id.toString()); } NotifierInfoCatalogResource(StreamlineAuthorizer authorizer, StreamCatalogService catalogService, FileStorage fileStorage); }
NotifierInfoCatalogResource { @GET @Path("/notifiers/{id}") @Timed public Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext) { boolean notifierUser = SecurityUtil.hasRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_USER); if (notifierUser) { LOG.debug("Allowing get Notifier, since user has role: {}", Roles.ROLE_NOTIFIER_USER); } else { SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, id, READ); } Notifier result = catalogService.getNotifierInfo(id); if (result != null) { return WSUtils.respondEntity(result, OK); } throw EntityNotFoundException.byId(id.toString()); } NotifierInfoCatalogResource(StreamlineAuthorizer authorizer, StreamCatalogService catalogService, FileStorage fileStorage); @GET @Path("/notifiers") @Timed Response listNotifiers(@Context UriInfo uriInfo, @Context SecurityContext securityContext); @GET @Path("/notifiers/{id}") @Timed Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/notifiers") @Timed Response addNotifier(@FormDataParam("notifierJarFile") final InputStream inputStream,
                                @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader,
                                @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig,
                                @Context SecurityContext securityContext); @DELETE @Path("/notifiers/{id}") @Timed Response removeNotifierInfo(@PathParam("id") Long id, @Context SecurityContext securityContext); @PUT @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/notifiers/{id}") @Timed Response addOrUpdateNotifierInfo(@PathParam("id") Long id,
                                            @FormDataParam("notifierJarFile") final InputStream inputStream,
                                            @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader,
                                            @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig,
                                            @Context SecurityContext securityContext); @Timed @GET @Produces({"application/java-archive", "application/json"}) @Path("/notifiers/download/{notifierId}") Response downloadNotifier(@PathParam("notifierId") Long notifierId, @Context SecurityContext securityContext); }
NotifierInfoCatalogResource { @GET @Path("/notifiers/{id}") @Timed public Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext) { boolean notifierUser = SecurityUtil.hasRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_USER); if (notifierUser) { LOG.debug("Allowing get Notifier, since user has role: {}", Roles.ROLE_NOTIFIER_USER); } else { SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, id, READ); } Notifier result = catalogService.getNotifierInfo(id); if (result != null) { return WSUtils.respondEntity(result, OK); } throw EntityNotFoundException.byId(id.toString()); } NotifierInfoCatalogResource(StreamlineAuthorizer authorizer, StreamCatalogService catalogService, FileStorage fileStorage); @GET @Path("/notifiers") @Timed Response listNotifiers(@Context UriInfo uriInfo, @Context SecurityContext securityContext); @GET @Path("/notifiers/{id}") @Timed Response getNotifierById(@PathParam("id") Long id, @Context SecurityContext securityContext); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/notifiers") @Timed Response addNotifier(@FormDataParam("notifierJarFile") final InputStream inputStream,
                                @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader,
                                @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig,
                                @Context SecurityContext securityContext); @DELETE @Path("/notifiers/{id}") @Timed Response removeNotifierInfo(@PathParam("id") Long id, @Context SecurityContext securityContext); @PUT @Consumes(MediaType.MULTIPART_FORM_DATA) @Path("/notifiers/{id}") @Timed Response addOrUpdateNotifierInfo(@PathParam("id") Long id,
                                            @FormDataParam("notifierJarFile") final InputStream inputStream,
                                            @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader,
                                            @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig,
                                            @Context SecurityContext securityContext); @Timed @GET @Produces({"application/java-archive", "application/json"}) @Path("/notifiers/download/{notifierId}") Response downloadNotifier(@PathParam("notifierId") Long notifierId, @Context SecurityContext securityContext);  }