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);
}
}
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);
}
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();
}
}
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);
}
}
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;
}
Aggregations