use of com.hortonworks.streamline.common.exception.service.exception.server.StreamingEngineNotReachableException in project streamline by hortonworks.
the class TopologyCatalogResource method removeTopology.
@DELETE
@Path("/topologies/{topologyId}")
@Timed
public Response removeTopology(@PathParam("topologyId") Long topologyId, @javax.ws.rs.QueryParam("onlyCurrent") boolean onlyCurrent, @javax.ws.rs.QueryParam("force") boolean force, @Context SecurityContext securityContext) throws Exception {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_SUPER_ADMIN, NAMESPACE, topologyId, DELETE);
if (!force) {
Topology result = catalogService.getTopology(topologyId);
if (result == null) {
throw EntityNotFoundException.byId(topologyId.toString());
}
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
try {
String runtimeTopologyId = actionsService.getRuntimeTopologyId(result, asUser);
if (StringUtils.isNotEmpty(runtimeTopologyId)) {
throw BadRequestException.message("Can't remove topology while Topology is running - topology id: " + topologyId);
}
} catch (TopologyNotAliveException e) {
// OK to continue
} catch (StormNotReachableException | IOException e) {
// users need to make a request with force parameter on
throw new StreamingEngineNotReachableException(e.getMessage(), e);
}
}
Response response;
if (onlyCurrent) {
response = removeCurrentTopologyVersion(topologyId);
} else {
response = removeAllTopologyVersions(topologyId);
}
SecurityUtil.removeAcl(authorizer, securityContext, NAMESPACE, topologyId);
return response;
}
Aggregations