use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.
the class DefaultFeedManagerFeedService method deployFeedVersion.
@Override
public DeployResponseEntityVersion deployFeedVersion(String feedIdStr, String versionIdStr, boolean includeContent) throws DeployFeedException {
Optional<Map.Entry<Feed.ID, ActionGroup>> feedAccess = checkChangeVersions(feedIdStr);
return feedAccess.map(entry -> {
Feed.ID domainFeedId = entry.getKey();
return metadataAccess.commit(() -> {
com.thinkbiganalytics.metadata.api.versioning.EntityVersion.ID versionId = this.feedProvider.resolveVersion(versionIdStr);
return this.feedProvider.findVersion(domainFeedId, versionId, true).map(ver -> {
Feed feed = ver.getEntity().get();
// validate the required user properties
// Set user-defined properties
Set<UserFieldDescriptor> fields = feedModelTransform.getUserFields(feed.getCategory());
if (fields != null && !fields.isEmpty()) {
if (feed.isMissingRequiredProperties(fields)) {
throw new MetadataRepositoryException("Unable to deploy the feed. It is missing required properties ");
}
}
FeedMetadata feedMetadata = feedModelTransform.domainToFeedMetadata(feed, entry.getValue());
NifiFeed deployedFeed = deployFeed(feedMetadata, ver);
EntityVersion entityVersion = feedModelTransform.domainToFeedVersion(feedProvider.findVersion(domainFeedId, versionId, includeContent).get(), entry.getValue());
return new DeployResponseEntityVersion(entityVersion, deployedFeed);
}).orElseThrow(() -> new FeedNotFoundException(domainFeedId));
}, MetadataAccess.SERVICE);
}).orElseThrow(() -> new FeedNotFoundException(this.feedProvider.resolveFeed(feedIdStr)));
}
use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.
the class FeedRestController method feedVersionAction.
@POST
@Path("/{feedId}/versions/{versionId}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Performs one or more actions on a feed version.")
@ApiResponses({ @ApiResponse(code = 200, message = "Feed version was successfully processed", response = FeedMetadata.class), @ApiResponse(code = 400, message = "Indicates the feed or version to be deployed does not exist", response = FeedMetadata.class), @ApiResponse(code = 500, message = "The feed is unavailable.", response = RestResponseStatus.class) })
public Response feedVersionAction(@PathParam("feedId") String feedId, @PathParam("versionId") String versionId, @FormParam("action") String actionStr) {
try {
Set<VersionAction> actions = validateVersionActions(actionStr, VersionAction.DRAFT, VersionAction.DEPLOY, VersionAction.REMOVE);
EntityVersion version = null;
for (VersionAction action : actions) {
switch(action) {
case DRAFT:
version = getMetadataService().createDraftFromFeedVersion(feedId, versionId, true);
break;
case DEPLOY:
if (actions.contains(VersionAction.DRAFT)) {
version = getMetadataService().createVersionFromDraftFeed(feedId, null, false);
}
version = getMetadataService().deployFeedVersion(feedId, version != null ? version.getId() : versionId, true);
break;
case REMOVE:
// break;
return Response.status(Status.BAD_REQUEST).entity("Feed version removal currently not supported: " + actionStr).build();
default:
return Response.status(Status.BAD_REQUEST).entity("Unsupported action for feed version: " + actionStr).build();
}
}
return Response.ok(version).build();
} catch (FeedNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Feed not found: " + feedId).build();
} catch (VersionNotFoundException e) {
return Response.status(Status.NOT_FOUND).entity("Version not found: " + versionId).build();
} catch (Exception e) {
log.error("Unexpected exception retrieving the feed version", e);
throw new InternalServerErrorException("Unexpected exception retrieving the feed version");
}
}
Aggregations