use of com.hortonworks.streamline.streams.catalog.Notifier in project streamline by hortonworks.
the class RestIntegrationTest method createNotifierInfo.
private Notifier createNotifierInfo(Long id, String name) {
Notifier notifier = new Notifier();
notifier.setClassName("A.B.C");
notifier.setId(id);
notifier.setJarFileName(name);
notifier.setName(name);
return notifier;
}
use of com.hortonworks.streamline.streams.catalog.Notifier in project streamline by hortonworks.
the class StreamCatalogService method getNotifierInfo.
public Notifier getNotifierInfo(Long id) {
Notifier notifier = new Notifier();
notifier.setId(id);
return this.dao.get(new StorableKey(NOTIFIER_INFO_NAMESPACE, notifier.getPrimaryKey()));
}
use of com.hortonworks.streamline.streams.catalog.Notifier in project streamline by hortonworks.
the class NotifierInfoCatalogResource method downloadNotifier.
/**
* 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());
}
use of com.hortonworks.streamline.streams.catalog.Notifier in project streamline by hortonworks.
the class NotifierInfoCatalogResource method removeNotifierInfo.
@DELETE
@Path("/notifiers/{id}")
@Timed
public Response removeNotifierInfo(@PathParam("id") Long id, @Context SecurityContext securityContext) {
SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, id, DELETE);
Notifier removedNotifier = catalogService.removeNotifierInfo(id);
if (removedNotifier != null) {
SecurityUtil.removeAcl(authorizer, securityContext, Notifier.NAMESPACE, id);
return WSUtils.respondEntity(removedNotifier, OK);
}
throw EntityNotFoundException.byId(id.toString());
}
use of com.hortonworks.streamline.streams.catalog.Notifier in project streamline by hortonworks.
the class NotifierInfoCatalogResource method addOrUpdateNotifierInfo.
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/notifiers/{id}")
@Timed
public Response addOrUpdateNotifierInfo(@PathParam("id") Long id, @FormDataParam("notifierJarFile") final InputStream inputStream, @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader, @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig, @Context SecurityContext securityContext) throws IOException {
SecurityUtil.checkPermissions(authorizer, securityContext, Notifier.NAMESPACE, id, WRITE);
MediaType mediaType = notifierConfig.getMediaType();
LOG.debug("Media type {}", mediaType);
if (!mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
throw new UnsupportedMediaTypeException(mediaType.toString());
}
Notifier notifier = notifierConfig.getValueAs(Notifier.class);
String jarFileName = uploadJar(inputStream, notifier.getName());
notifier.setJarFileName(jarFileName);
Notifier newNotifier = catalogService.addOrUpdateNotifierInfo(id, notifier);
return WSUtils.respondEntity(newNotifier, CREATED);
}
Aggregations