Search in sources :

Example 1 with READ

use of com.hortonworks.streamline.streams.security.Permission.READ in project streamline by hortonworks.

the class TopologyTestRunResource method getEventsOfTestRunTopologyHistory.

private Response getEventsOfTestRunTopologyHistory(Long topologyId, Long historyId, String componentName, SecurityContext securityContext) throws IOException {
    SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ);
    File eventLogFile = getEventLogFile(topologyId, historyId);
    Stream<EventInformation> eventsStream = eventLogFileReader.loadEventLogFileAsStream(eventLogFile);
    if (!StringUtils.isEmpty(componentName)) {
        eventsStream = eventsStream.filter(event -> {
            String eventComponentName = event.getComponentName();
            return eventComponentName != null && eventComponentName.equals(componentName);
        });
    }
    return WSUtils.respondEntities(eventsStream.collect(toList()), OK);
}
Also used : Topology(com.hortonworks.streamline.streams.catalog.Topology) Roles(com.hortonworks.streamline.streams.security.Roles) Produces(javax.ws.rs.Produces) BadRequestException(com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) SecurityContext(javax.ws.rs.core.SecurityContext) BooleanUtils(org.apache.commons.lang.BooleanUtils) MediaType(javax.ws.rs.core.MediaType) QueryParam(javax.ws.rs.QueryParam) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) WSUtils(com.hortonworks.streamline.common.util.WSUtils) READ(com.hortonworks.streamline.streams.security.Permission.READ) TypeReference(com.fasterxml.jackson.core.type.TypeReference) StreamlineAuthorizer(com.hortonworks.streamline.streams.security.StreamlineAuthorizer) TopologyStream(com.hortonworks.streamline.streams.catalog.TopologyStream) DELETE(javax.ws.rs.DELETE) SecurityUtil(com.hortonworks.streamline.streams.security.SecurityUtil) TopologySink(com.hortonworks.streamline.streams.catalog.TopologySink) Context(javax.ws.rs.core.Context) EventInformationTreeBuilder(com.hortonworks.streamline.streams.common.event.tree.EventInformationTreeBuilder) OK(javax.ws.rs.core.Response.Status.OK) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Timed(com.codahale.metrics.annotation.Timed) TopologySource(com.hortonworks.streamline.streams.catalog.TopologySource) List(java.util.List) Stream(java.util.stream.Stream) Response(javax.ws.rs.core.Response) SchemaValidationFailedException(com.hortonworks.streamline.common.exception.SchemaValidationFailedException) Optional(java.util.Optional) UriInfo(javax.ws.rs.core.UriInfo) EventInformation(com.hortonworks.streamline.streams.common.event.EventInformation) TopologyTestRunCaseSink(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink) CREATED(javax.ws.rs.core.Response.Status.CREATED) JsonIgnoreProperties(com.fasterxml.jackson.annotation.JsonIgnoreProperties) TopologyTestRunCase(com.hortonworks.streamline.streams.catalog.TopologyTestRunCase) StringUtils(org.datanucleus.util.StringUtils) PathParam(javax.ws.rs.PathParam) EntityNotFoundException(com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException) EventInformationTreeNode(com.hortonworks.streamline.streams.common.event.tree.EventInformationTreeNode) GET(javax.ws.rs.GET) Schema(com.hortonworks.registries.common.Schema) WRITE(com.hortonworks.streamline.streams.security.Permission.WRITE) GroupedCorrelationEvents(com.hortonworks.streamline.streams.common.event.correlation.GroupedCorrelationEvents) EventLogFileReader(com.hortonworks.streamline.streams.common.event.EventLogFileReader) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) TopologyActionsService(com.hortonworks.streamline.streams.actions.topology.service.TopologyActionsService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) SchemaValueConverter(com.hortonworks.streamline.common.SchemaValueConverter) TopologyTestRunCaseSource(com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource) File(java.io.File) TopologyTestRunHistory(com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory) TopologyComponent(com.hortonworks.streamline.streams.catalog.TopologyComponent) Collectors.toList(java.util.stream.Collectors.toList) CorrelatedEventsGrouper(com.hortonworks.streamline.streams.common.event.correlation.CorrelatedEventsGrouper) EXECUTE(com.hortonworks.streamline.streams.security.Permission.EXECUTE) StreamCatalogService(com.hortonworks.streamline.streams.catalog.service.StreamCatalogService) PUT(javax.ws.rs.PUT) Collections(java.util.Collections) InputStream(java.io.InputStream) EventInformation(com.hortonworks.streamline.streams.common.event.EventInformation) File(java.io.File)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Schema (com.hortonworks.registries.common.Schema)1 SchemaValueConverter (com.hortonworks.streamline.common.SchemaValueConverter)1 SchemaValidationFailedException (com.hortonworks.streamline.common.exception.SchemaValidationFailedException)1 BadRequestException (com.hortonworks.streamline.common.exception.service.exception.request.BadRequestException)1 EntityNotFoundException (com.hortonworks.streamline.common.exception.service.exception.request.EntityNotFoundException)1 WSUtils (com.hortonworks.streamline.common.util.WSUtils)1 TopologyActionsService (com.hortonworks.streamline.streams.actions.topology.service.TopologyActionsService)1 Topology (com.hortonworks.streamline.streams.catalog.Topology)1 TopologyComponent (com.hortonworks.streamline.streams.catalog.TopologyComponent)1 TopologySink (com.hortonworks.streamline.streams.catalog.TopologySink)1 TopologySource (com.hortonworks.streamline.streams.catalog.TopologySource)1 TopologyStream (com.hortonworks.streamline.streams.catalog.TopologyStream)1 TopologyTestRunCase (com.hortonworks.streamline.streams.catalog.TopologyTestRunCase)1 TopologyTestRunCaseSink (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSink)1 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)1 TopologyTestRunHistory (com.hortonworks.streamline.streams.catalog.TopologyTestRunHistory)1