Search in sources :

Example 81 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class FeedRestController method getFeedFieldPoliciesByName.

@GET
@Path("/by-name/{feedName}/field-policies")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the specified feed.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the feed field policies (List<FieldPolicy>) as json.", response = List.class), @ApiResponse(code = 500, message = "The feed is unavailable.", response = RestResponseStatus.class) })
public Response getFeedFieldPoliciesByName(@PathParam("feedName") String feedName) {
    String categorySystemName = FeedNameUtil.category(feedName);
    String feedSystemName = FeedNameUtil.feed(feedName);
    if (StringUtils.isNotBlank(categorySystemName) && StringUtils.isNotBlank(feedSystemName)) {
        FeedMetadata feed = getMetadataService().getFeedByName(categorySystemName, feedSystemName);
        if (feed != null && feed.getTable() != null) {
            return Response.ok(feed.getTable().getFieldPoliciesJson()).build();
        } else {
            throw new NotFoundException("Unable to find the feed field policies for name: " + feedName);
        }
    } else {
        throw new NotFoundException("Unable to find the feed field policies for name: " + feedName);
    }
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NotFoundException(javax.ws.rs.NotFoundException) VersionNotFoundException(com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 82 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class FeedRestController method queryProfileInvalidResults.

@GET
@Path("/{feedId}/profile-invalid-results")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets statistics on the invalid rows for the specified job.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the invalid row statistics.", response = Map.class, responseContainer = "List"), @ApiResponse(code = 500, message = "The profile is unavailable.", response = RestResponseStatus.class) })
public Response queryProfileInvalidResults(@PathParam("feedId") String feedId, @QueryParam("processingdttm") String processingdttm, @QueryParam("limit") int limit, @QueryParam("filter") String filter) {
    FeedMetadata feedMetadata = getMetadataService().getFeedById(feedId);
    String condition = "";
    if (StringUtils.isNotBlank(filter)) {
        condition = " and dlp_reject_reason like " + HiveUtils.quoteString("%" + filter + "%") + " ";
    }
    return getPage(processingdttm, limit, feedMetadata.getInvalidTableName(), condition);
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 83 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class FeedRestController method createDraftFeed.

@POST
@Path("/draft/entity")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Creates a new feed as draft version.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the feed metadata.", response = NifiFeed.class), @ApiResponse(code = 500, message = "An internal error occurred.", response = RestResponseStatus.class) })
@Nonnull
public Response createDraftFeed(@Nonnull final FeedMetadata feedMetadata) {
    try {
        FeedMetadata update = getMetadataService().saveDraftFeed(feedMetadata);
        NifiFeed feed = new NifiFeed(update, null);
        feed.setSuccess(true);
        return Response.ok(feed).build();
    } catch (DuplicateFeedNameException e) {
        log.info("Failed to create a new feed due to another feed having the same category/feed name: " + feedMetadata.getCategoryAndFeedDisplayName());
        // Create an error message
        String msg = "A feed already exists in the category \"" + e.getCategoryName() + "\" with name name \"" + e.getFeedName() + "\"";
        // Add error message to feed
        NifiFeed feed = new NifiFeed(feedMetadata, null);
        feed.addErrorMessage(msg);
        feed.setSuccess(false);
        return Response.status(Status.CONFLICT).entity(feed).build();
    } catch (NifiConnectionException e) {
        throw e;
    } catch (Exception e) {
        log.error("Failed to create a new feed.", e);
        // Create an error message
        String msg = (e.getMessage() != null) ? "Error creating Feed: " + e.getMessage() : "An unknown error occurred while saving the feed.";
        if (e.getCause() instanceof JDBCException) {
            msg += ". " + ((JDBCException) e).getSQLException();
        }
        // Add error message to feed
        NifiFeed feed = new NifiFeed(feedMetadata, null);
        feed.addErrorMessage(msg);
        feed.setSuccess(false);
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(feed).build();
    }
}
Also used : JDBCException(org.hibernate.JDBCException) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NifiConnectionException(com.thinkbiganalytics.nifi.rest.client.NifiConnectionException) DuplicateFeedNameException(com.thinkbiganalytics.feedmgr.service.feed.DuplicateFeedNameException) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed) NifiClientRuntimeException(com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException) FeedCleanupTimeoutException(com.thinkbiganalytics.feedmgr.service.FeedCleanupTimeoutException) FeedCleanupFailedException(com.thinkbiganalytics.feedmgr.service.FeedCleanupFailedException) WebApplicationException(javax.ws.rs.WebApplicationException) AccessDeniedException(java.nio.file.AccessDeniedException) DeployFeedException(com.thinkbiganalytics.feedmgr.service.feed.DeployFeedException) DuplicateFeedNameException(com.thinkbiganalytics.feedmgr.service.feed.DuplicateFeedNameException) IOException(java.io.IOException) FeedCurrentlyRunningException(com.thinkbiganalytics.feedmgr.service.feed.reindexing.FeedCurrentlyRunningException) ClientErrorException(javax.ws.rs.ClientErrorException) JDBCException(org.hibernate.JDBCException) FeedHistoryDataReindexingNotEnabledException(com.thinkbiganalytics.feedmgr.service.feed.reindexing.FeedHistoryDataReindexingNotEnabledException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) NotFoundException(javax.ws.rs.NotFoundException) AccessControlException(java.security.AccessControlException) DataAccessException(org.springframework.dao.DataAccessException) VersionNotFoundException(com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) NifiConnectionException(com.thinkbiganalytics.nifi.rest.client.NifiConnectionException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Nonnull(javax.annotation.Nonnull) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 84 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class FeedRestController method getFeedByName.

@GET
@Path("/by-name/{feedName}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the specified feed.")
@ApiResponses({ @ApiResponse(code = 200, message = "Returns the feed.", response = FeedMetadata.class), @ApiResponse(code = 500, message = "The feed is unavailable.", response = RestResponseStatus.class) })
public Response getFeedByName(@PathParam("feedName") String feedName) {
    String categorySystemName = FeedNameUtil.category(feedName);
    String feedSystemName = FeedNameUtil.feed(feedName);
    if (StringUtils.isNotBlank(categorySystemName) && StringUtils.isNotBlank(feedSystemName)) {
        FeedMetadata feed = getMetadataService().getFeedByName(categorySystemName, feedSystemName);
        return Response.ok(feed).build();
    } else {
        throw new NotFoundException("Unable to find the feed for name: " + feedName);
    }
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NotFoundException(javax.ws.rs.NotFoundException) VersionNotFoundException(com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 85 with FeedMetadata

use of com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata in project kylo by Teradata.

the class FileObjectPersistence method getFeedsFromFile.

public Collection<FeedMetadata> getFeedsFromFile() {
    ObjectMapper mapper = new ObjectMapper();
    File file = new File(filePath + "/" + FEED_METADATA_FILENAME);
    Collection<FeedMetadata> feeds = null;
    if (file.exists()) {
        try {
            feeds = mapper.readValue(file, new TypeReference<List<FeedMetadata>>() {
            });
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return feeds;
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IOException(java.io.IOException) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)96 NifiProperty (com.thinkbiganalytics.nifi.rest.model.NifiProperty)36 ArrayList (java.util.ArrayList)35 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)32 List (java.util.List)30 Map (java.util.Map)30 Collectors (java.util.stream.Collectors)30 Set (java.util.Set)28 StringUtils (org.apache.commons.lang3.StringUtils)28 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)27 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)27 Logger (org.slf4j.Logger)27 LoggerFactory (org.slf4j.LoggerFactory)27 HashSet (java.util.HashSet)26 Inject (javax.inject.Inject)25 Nonnull (javax.annotation.Nonnull)24 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)23 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)23 FeedServicesAccessControl (com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl)23 AccessController (com.thinkbiganalytics.security.AccessController)23