Search in sources :

Example 6 with DELETE

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());
}
Also used : Namespace(com.hortonworks.streamline.streams.cluster.catalog.Namespace) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) DELETE(com.hortonworks.streamline.streams.security.Permission.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 7 with DELETE

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());
}
Also used : Service(com.hortonworks.streamline.streams.cluster.catalog.Service) StormMetadataService(com.hortonworks.streamline.streams.cluster.service.metadata.StormMetadataService) EnvironmentService(com.hortonworks.streamline.streams.cluster.service.EnvironmentService) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) Component(com.hortonworks.streamline.streams.cluster.catalog.Component) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) DELETE(com.hortonworks.streamline.streams.security.Permission.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Example 8 with DELETE

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());
}
Also used : IOException(java.io.IOException) File(com.hortonworks.streamline.streams.catalog.File) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) DELETE(com.hortonworks.streamline.streams.security.Permission.DELETE) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)8 DELETE (com.hortonworks.streamline.streams.security.Permission.DELETE)8 DELETE (javax.ws.rs.DELETE)8 Path (javax.ws.rs.Path)8 Namespace (com.hortonworks.streamline.streams.cluster.catalog.Namespace)3 IOException (java.io.IOException)3 Topology (com.hortonworks.streamline.streams.catalog.Topology)2 NamespaceServiceClusterMap (com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)2 EnvironmentService (com.hortonworks.streamline.streams.cluster.service.EnvironmentService)2 TopologyNotAliveException (com.hortonworks.streamline.streams.exception.TopologyNotAliveException)2 Response (javax.ws.rs.core.Response)2 QueryParam (com.hortonworks.registries.common.QueryParam)1 AlreadyExistsException (com.hortonworks.registries.storage.exception.AlreadyExistsException)1 BadRequestException (com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException)1 EntityNotFoundException (com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException)1 StreamingEngineNotReachableException (com.hortonworks.streamline.common.exception.service.exception.server.StreamingEngineNotReachableException)1 WSUtils (com.hortonworks.streamline.common.util.WSUtils)1 TopologyActionsService (com.hortonworks.streamline.streams.actions.topology.service.TopologyActionsService)1 File (com.hortonworks.streamline.streams.catalog.File)1 Notifier (com.hortonworks.streamline.streams.catalog.Notifier)1