private void updateNotifierJarFileName(TopologySink sink) { String notifierClassName = sink.getConfig().getString(Notifier.CLASS_NAME, ""); if (!notifierClassName.isEmpty()) { Collection<Notifier> notifiers = listNotifierInfos(QueryParam.params(Notifier.CLASS_NAME, notifierClassName)); if (notifiers.isEmpty()) { throw new IllegalStateException("No registered notifier in the cluster for class '" + notifierClassName + "'"); } Notifier current = notifiers.iterator().next(); sink.getConfig().setAny(Notifier.JARFILE_NAME, current.getJarFileName()); } }
/** * Download the jar corresponding to a specific Notifier. * <p> * E.g. curl http://localhost:8080/api/v1/catalog/notifiers/download/34 -o /tmp/notifier.jar * </p> */ @Timed @GET @Produces({"application/java-archive", "application/json"}) @Path("/notifiers/download/{notifierId}") public Response downloadNotifier(@PathParam("notifierId") Long notifierId, @Context SecurityContext securityContext) throws IOException { SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, notifierId, READ, EXECUTE); Notifier notifier = catalogService.getNotifierInfo(notifierId); if (notifier != null) { StreamingOutput streamOutput = WSUtils.wrapWithStreamingOutput( catalogService.downloadFileFromStorage(notifier.getJarFileName())); return Response.ok(streamOutput).build(); } throw EntityNotFoundException.byId(notifierId.toString()); }