use of com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException in project kylo by Teradata.
the class JcrFeedProvider method createDraftEntity.
@Override
public Node createDraftEntity(ID entityId, EntityVersion.ID versionId) {
Version version = findVersion(entityId, versionId, false).map(JcrEntityVersion.class::cast).map(ev -> ev.getVersion()).orElseThrow(() -> new VersionNotFoundException(versionId));
JcrVersionUtil.restore(version);
Node draft = createDraftEntity(entityId);
return draft;
}
use of com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException 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