use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyCatalogResource method getTopologyByIdAndVersion.
@GET
@Path("/topologies/{topologyId}/versions/{versionId}")
@Timed
public Response getTopologyByIdAndVersion(@PathParam("topologyId") Long topologyId, @PathParam("versionId") Long versionId, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
Topology result = catalogService.getTopology(topologyId, versionId);
if (result != null) {
return WSUtils.respondEntity(result, OK);
}
throw EntityNotFoundException.byId(topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyCatalogResource method cloneTopology.
@POST
@Path("/topologies/{topologyId}/actions/clone")
@Timed
public Response cloneTopology(@PathParam("topologyId") Long topologyId, @QueryParam("namespaceId") Long namespaceId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_ADMIN);
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, READ, EXECUTE);
Topology originalTopology = catalogService.getTopology(topologyId);
if (originalTopology != null) {
Topology clonedTopology = catalogService.cloneTopology(namespaceId, originalTopology);
return WSUtils.respondEntity(clonedTopology, OK);
}
throw EntityNotFoundException.byId(topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyCatalogResource method getComponentsToReconfigure.
@GET
@Path("/topologies/{topologyId}/reconfigure")
@Timed
public Response getComponentsToReconfigure(@PathParam("topologyId") Long topologyId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, NAMESPACE, topologyId, READ);
Topology topology = catalogService.getTopology(topologyId);
if (topology != null) {
return WSUtils.respondEntity(catalogService.getComponentsToReconfigure(topology), OK);
}
throw EntityNotFoundException.byId(topologyId.toString());
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyCatalogResource method addTopology.
@POST
@Path("/topologies")
@Timed
public Response addTopology(Topology topology, @Context SecurityContext securityContext) {
SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_ADMIN);
if (StringUtils.isEmpty(topology.getName())) {
throw BadRequestException.missingParameter(Topology.NAME);
}
if (StringUtils.isEmpty(topology.getConfig())) {
throw BadRequestException.missingParameter(Topology.CONFIG);
}
Topology createdTopology = catalogService.addTopology(topology);
SecurityUtil.addAcl(authorizer, securityContext, NAMESPACE, createdTopology.getId(), EnumSet.allOf(Permission.class));
return WSUtils.respondEntity(createdTopology, CREATED);
}
use of com.hortonworks.streamline.streams.catalog.Topology in project streamline by hortonworks.
the class TopologyCatalogResource method exportTopology.
@GET
@Path("/topologies/{topologyId}/actions/export")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Timed
public Response exportTopology(@PathParam("topologyId") Long topologyId, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, READ, EXECUTE);
Topology topology = catalogService.getTopology(topologyId);
if (topology != null) {
String exportedTopology = catalogService.exportTopology(topology);
if (!StringUtils.isEmpty(exportedTopology)) {
InputStream is = new ByteArrayInputStream(exportedTopology.getBytes(StandardCharsets.UTF_8));
return Response.status(OK).entity(is).header("Content-Disposition", "attachment; filename=\"" + topology.getName() + ".json\"").build();
}
}
throw EntityNotFoundException.byId(topologyId.toString());
}
Aggregations