use of com.hortonworks.streamline.streams.security.Permission.DELETE in project streamline by hortonworks.
the class NamespaceCatalogResource method removeNamespace.
@DELETE
@Path("/namespaces/{id}")
@Timed
public Response removeNamespace(@PathParam("id") Long namespaceId, @Context SecurityContext securityContext) {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_ENVIRONMENT_SUPER_ADMIN, Namespace.NAMESPACE, namespaceId, DELETE);
assertNoTopologyRefersNamespace(namespaceId);
Namespace removed = environmentService.removeNamespace(namespaceId);
if (removed != null) {
SecurityUtil.removeAcl(authorizer, securityContext, Namespace.NAMESPACE, namespaceId);
return WSUtils.respondEntity(removed, OK);
}
throw EntityNotFoundException.byId(namespaceId.toString());
}
use of com.hortonworks.streamline.streams.security.Permission.DELETE in project streamline by hortonworks.
the class ClusterCatalogResource method removeCluster.
@DELETE
@Path("/clusters/{id}")
@Timed
public Response removeCluster(@PathParam("id") Long clusterId, @Context SecurityContext securityContext) {
assertNoNamespaceRefersCluster(clusterId);
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_SERVICE_POOL_SUPER_ADMIN, NAMESPACE, clusterId, DELETE);
// remove all services / service configurations / components / component processes in this cluster
Collection<Service> services = environmentService.listServices(clusterId);
services.forEach(svc -> {
environmentService.listServiceConfigurations(svc.getId()).forEach(sc -> environmentService.removeServiceConfiguration(sc.getId()));
Collection<Component> components = environmentService.listComponents(svc.getId());
components.forEach(component -> {
environmentService.listComponentProcesses(component.getId()).forEach(componentProcess -> environmentService.removeComponentProcess(componentProcess.getId()));
environmentService.removeComponent(component.getId());
});
environmentService.removeService(svc.getId());
});
Cluster removedCluster = environmentService.removeCluster(clusterId);
if (removedCluster != null) {
SecurityUtil.removeAcl(authorizer, securityContext, NAMESPACE, clusterId);
return WSUtils.respondEntity(removedCluster, OK);
}
throw EntityNotFoundException.byId(clusterId.toString());
}
use of com.hortonworks.streamline.streams.security.Permission.DELETE in project streamline by hortonworks.
the class FileCatalogResource method removeFile.
/**
* Deletes the file of given {@code fileId}
*
* @param fileId
*/
@DELETE
@Path("/files/{id}")
@Timed
public Response removeFile(@PathParam("id") Long fileId, @Context SecurityContext securityContext) throws IOException {
SecurityUtil.checkPermissions(authorizer, securityContext, File.NAMESPACE, fileId, DELETE);
try {
File removedFile = catalogService.removeFile(fileId);
SecurityUtil.removeAcl(authorizer, securityContext, File.NAMESPACE, fileId);
log.info("Removed File entry is [{}]", removedFile);
if (removedFile != null) {
boolean removed = catalogService.deleteFileFromStorage(removedFile.getStoredFileName());
logDeletionMessage(removedFile.getStoredFileName(), removed);
return WSUtils.respondEntity(removedFile, OK);
}
} catch (IOException ex) {
log.error("Encountered error in removing file with id [{}]", fileId, ex);
throw ex;
}
log.info("File entry with id [{}] is not found", fileId);
throw EntityNotFoundException.byId(fileId.toString());
}
Aggregations