Search in sources :

Example 1 with VersionNotFoundException

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;
}
Also used : JcrEntityVersion(com.thinkbiganalytics.metadata.modeshape.versioning.JcrEntityVersion) EntityUtil(com.thinkbiganalytics.metadata.modeshape.common.EntityUtil) Category(com.thinkbiganalytics.metadata.api.category.Category) DatasourceNotFoundException(com.thinkbiganalytics.metadata.api.datasource.DatasourceNotFoundException) ChangeType(com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) FeedProvider(com.thinkbiganalytics.metadata.api.feed.FeedProvider) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) FeedAccessControl(com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl) Map(java.util.Map) FeedPropertyChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent) AccessController(com.thinkbiganalytics.security.AccessController) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) Path(java.nio.file.Path) CategoryNotFoundException(com.thinkbiganalytics.metadata.api.category.CategoryNotFoundException) CategoryDetails(com.thinkbiganalytics.metadata.modeshape.category.CategoryDetails) Session(javax.jcr.Session) FeedOpsAccessControlProvider(com.thinkbiganalytics.metadata.api.feed.security.FeedOpsAccessControlProvider) Set(java.util.Set) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Serializable(java.io.Serializable) Predicate(com.google.common.base.Predicate) CategoryProvider(com.thinkbiganalytics.metadata.api.category.CategoryProvider) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) DraftVersionProviderMixin(com.thinkbiganalytics.metadata.modeshape.common.mixin.DraftVersionProviderMixin) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) PropertyChange(com.thinkbiganalytics.metadata.api.event.feed.PropertyChange) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) NodeIterator(javax.jcr.NodeIterator) JcrEntity(com.thinkbiganalytics.metadata.modeshape.common.JcrEntity) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) ServiceLevelAgreementBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementBuilder) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) Datasource(com.thinkbiganalytics.metadata.api.datasource.Datasource) JcrChangeComment(com.thinkbiganalytics.metadata.modeshape.template.JcrChangeComment) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) ID(com.thinkbiganalytics.metadata.api.feed.Feed.ID) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) JcrObject(com.thinkbiganalytics.metadata.modeshape.common.JcrObject) DatasourceProvider(com.thinkbiganalytics.metadata.api.datasource.DatasourceProvider) VersionProviderMixin(com.thinkbiganalytics.metadata.modeshape.common.mixin.VersionProviderMixin) Version(javax.jcr.version.Version) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) QueryResult(javax.jcr.query.QueryResult) FeedChange(com.thinkbiganalytics.metadata.api.event.feed.FeedChange) ChangeComment(com.thinkbiganalytics.metadata.api.template.ChangeComment) JcrPropertyConstants(com.thinkbiganalytics.metadata.modeshape.common.JcrPropertyConstants) AbstractMetadataCriteria(com.thinkbiganalytics.metadata.modeshape.AbstractMetadataCriteria) DataSetProvider(com.thinkbiganalytics.metadata.api.catalog.DataSetProvider) JcrQueryUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil) JcrDatasource(com.thinkbiganalytics.metadata.modeshape.datasource.JcrDatasource) Pageable(org.springframework.data.domain.Pageable) UserFieldDescriptors(com.thinkbiganalytics.metadata.modeshape.common.UserFieldDescriptors) JcrAllowedEntityActionsProvider(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedEntityActionsProvider) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) PreconditionBuilder(com.thinkbiganalytics.metadata.api.feed.PreconditionBuilder) DataSetNotFoundException(com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException) Collectors(java.util.stream.Collectors) SecurityRoleProvider(com.thinkbiganalytics.security.role.SecurityRoleProvider) List(java.util.List) Principal(java.security.Principal) AccessControlException(java.security.AccessControlException) Optional(java.util.Optional) BaseJcrProvider(com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) DataSet(com.thinkbiganalytics.metadata.api.catalog.DataSet) HashMap(java.util.HashMap) VersionNotFoundException(com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException) EntityVersion(com.thinkbiganalytics.metadata.api.versioning.EntityVersion) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) HashSet(java.util.HashSet) Inject(javax.inject.Inject) JcrDataSet(com.thinkbiganalytics.metadata.modeshape.catalog.dataset.JcrDataSet) ObligationGroupBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationGroupBuilder) RepositoryException(javax.jcr.RepositoryException) JcrVersionUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrVersionUtil) Node(javax.jcr.Node) FeedChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent) FeedSource(com.thinkbiganalytics.metadata.api.feed.FeedSource) VersionAlreadyExistsException(com.thinkbiganalytics.metadata.api.versioning.VersionAlreadyExistsException) JcrEntityVersion(com.thinkbiganalytics.metadata.modeshape.versioning.JcrEntityVersion) Nonnull(javax.annotation.Nonnull) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) FeedNameUtil(com.thinkbiganalytics.support.FeedNameUtil) DateTime(org.joda.time.DateTime) ServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider) UserFieldDescriptor(com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor) JcrServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreementProvider) Consumer(java.util.function.Consumer) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) Condition(com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition) ObligationBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationBuilder) RoleMembership(com.thinkbiganalytics.security.role.RoleMembership) Collections(java.util.Collections) Version(javax.jcr.version.Version) EntityVersion(com.thinkbiganalytics.metadata.api.versioning.EntityVersion) JcrEntityVersion(com.thinkbiganalytics.metadata.modeshape.versioning.JcrEntityVersion) Node(javax.jcr.Node) VersionNotFoundException(com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException)

Example 2 with VersionNotFoundException

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");
    }
}
Also used : DeployResponseEntityVersion(com.thinkbiganalytics.feedmgr.rest.model.DeployResponseEntityVersion) EntityVersion(com.thinkbiganalytics.feedmgr.rest.model.EntityVersion) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) VersionNotFoundException(com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException) 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) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

FeedNotFoundException (com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException)2 VersionNotFoundException (com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException)2 Predicate (com.google.common.base.Predicate)1 Strings (com.google.common.base.Strings)1 DeployResponseEntityVersion (com.thinkbiganalytics.feedmgr.rest.model.DeployResponseEntityVersion)1 EntityVersion (com.thinkbiganalytics.feedmgr.rest.model.EntityVersion)1 FeedCleanupFailedException (com.thinkbiganalytics.feedmgr.service.FeedCleanupFailedException)1 FeedCleanupTimeoutException (com.thinkbiganalytics.feedmgr.service.FeedCleanupTimeoutException)1 DeployFeedException (com.thinkbiganalytics.feedmgr.service.feed.DeployFeedException)1 DuplicateFeedNameException (com.thinkbiganalytics.feedmgr.service.feed.DuplicateFeedNameException)1 FeedCurrentlyRunningException (com.thinkbiganalytics.feedmgr.service.feed.reindexing.FeedCurrentlyRunningException)1 FeedHistoryDataReindexingNotEnabledException (com.thinkbiganalytics.feedmgr.service.feed.reindexing.FeedHistoryDataReindexingNotEnabledException)1 DataSet (com.thinkbiganalytics.metadata.api.catalog.DataSet)1 DataSetNotFoundException (com.thinkbiganalytics.metadata.api.catalog.DataSetNotFoundException)1 DataSetProvider (com.thinkbiganalytics.metadata.api.catalog.DataSetProvider)1 Category (com.thinkbiganalytics.metadata.api.category.Category)1 CategoryNotFoundException (com.thinkbiganalytics.metadata.api.category.CategoryNotFoundException)1 CategoryProvider (com.thinkbiganalytics.metadata.api.category.CategoryProvider)1 Datasource (com.thinkbiganalytics.metadata.api.datasource.Datasource)1 DatasourceNotFoundException (com.thinkbiganalytics.metadata.api.datasource.DatasourceNotFoundException)1