@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()); }
@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()); }
/** * 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()); }
@DELETE @Path("/udfs/{id}") @Timed
@DELETE @Path("/namespaces/{id}/mapping") @Timed public Response unmapAllServicesToClusterInNamespace(@PathParam("id") Long namespaceId, @Context SecurityContext securityContext) { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_ENVIRONMENT_SUPER_ADMIN, Namespace.NAMESPACE, namespaceId, WRITE); Namespace namespace = environmentService.getNamespace(namespaceId); if (namespace == null) { throw EntityNotFoundException.byId(namespaceId.toString()); } String streamingEngine = namespace.getStreamingEngine(); Collection<NamespaceServiceClusterMap> mappings = environmentService.listServiceClusterMapping(namespaceId); boolean containsStreamingEngine = mappings.stream() .anyMatch(m -> m.getServiceName().equals(streamingEngine)); if (containsStreamingEngine) { assertNoTopologyReferringNamespaceIsRunning(namespaceId, WSUtils.getUserFromSecurityContext(securityContext)); } List<NamespaceServiceClusterMap> removed = mappings.stream() .map((x) -> environmentService.removeServiceClusterMapping(x.getNamespaceId(), x.getServiceName(), x.getClusterId())) .collect(toList()); return WSUtils.respondEntities(removed, OK); }
@DELETE @Path("/namespaces/{id}/mapping/{serviceName}/cluster/{clusterId}") @Timed public Response unmapServiceToClusterInNamespace(@PathParam("id") Long namespaceId, @PathParam("serviceName") String serviceName, @PathParam("clusterId") Long clusterId, @Context SecurityContext securityContext) { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_ENVIRONMENT_SUPER_ADMIN, Namespace.NAMESPACE, namespaceId, WRITE); Namespace namespace = environmentService.getNamespace(namespaceId); if (namespace == null) { throw EntityNotFoundException.byId(namespaceId.toString()); } String streamingEngine = namespace.getStreamingEngine(); Collection<NamespaceServiceClusterMap> mappings = environmentService.listServiceClusterMapping(namespaceId); boolean containsStreamingEngine = mappings.stream() .anyMatch(m -> m.getServiceName().equals(streamingEngine)); // check topology running only streaming engine exists if (serviceName.equals(streamingEngine) && containsStreamingEngine) { assertNoTopologyReferringNamespaceIsRunning(namespaceId, WSUtils.getUserFromSecurityContext(securityContext)); } NamespaceServiceClusterMap mapping = environmentService.removeServiceClusterMapping(namespaceId, serviceName, clusterId); if (mapping != null) { return WSUtils.respondEntity(mapping, OK); } throw EntityNotFoundException.byId(buildMessageForCompositeId(namespaceId, serviceName, clusterId)); }
@DELETE @Path("/topologies/{topologyId}") @Timed
@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()); }