Search in sources :

Example 1 with ChangeType

use of com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType in project kylo by Teradata.

the class JcrFeedProvider method addPostFeedChangeAction.

/**
 * Registers an action that produces a feed change event upon a successful transaction commit.
 *
 * @param feed the feed to being created
 */
private void addPostFeedChangeAction(Feed feed, ChangeType changeType) {
    Feed.State state = feed.getState();
    Feed.ID id = feed.getId();
    String feedName = feed.getQualifiedName();
    final Principal principal = SecurityContextHolder.getContext().getAuthentication();
    Consumer<Boolean> action = (success) -> {
        if (success) {
            FeedChange change = new FeedChange(changeType, feedName, feedName, id, state);
            FeedChangeEvent event = new FeedChangeEvent(change, DateTime.now(), principal);
            metadataEventService.notify(event);
        }
    };
    JcrMetadataAccess.addPostTransactionAction(action);
}
Also used : ID(com.thinkbiganalytics.metadata.api.feed.Feed.ID) 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) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) QueryResult(javax.jcr.query.QueryResult) FeedChange(com.thinkbiganalytics.metadata.api.event.feed.FeedChange) Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) AbstractMetadataCriteria(com.thinkbiganalytics.metadata.modeshape.AbstractMetadataCriteria) FeedProvider(com.thinkbiganalytics.metadata.api.feed.FeedProvider) JcrQueryUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) FeedAccessControl(com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl) JcrDatasource(com.thinkbiganalytics.metadata.modeshape.datasource.JcrDatasource) Map(java.util.Map) FeedPropertyChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent) AccessController(com.thinkbiganalytics.security.AccessController) Pageable(org.springframework.data.domain.Pageable) UserFieldDescriptors(com.thinkbiganalytics.metadata.modeshape.common.UserFieldDescriptors) JcrAllowedEntityActionsProvider(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedEntityActionsProvider) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) FeedDestination(com.thinkbiganalytics.metadata.api.feed.FeedDestination) PreconditionBuilder(com.thinkbiganalytics.metadata.api.feed.PreconditionBuilder) 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) Collectors(java.util.stream.Collectors) FeedCriteria(com.thinkbiganalytics.metadata.api.feed.FeedCriteria) Serializable(java.io.Serializable) SecurityRoleProvider(com.thinkbiganalytics.security.role.SecurityRoleProvider) List(java.util.List) Principal(java.security.Principal) Predicate(com.google.common.base.Predicate) CategoryProvider(com.thinkbiganalytics.metadata.api.category.CategoryProvider) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) Optional(java.util.Optional) BaseJcrProvider(com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider) 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) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) HashMap(java.util.HashMap) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) ServiceLevelAgreementBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementBuilder) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ObligationGroupBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationGroupBuilder) RepositoryException(javax.jcr.RepositoryException) Node(javax.jcr.Node) FeedChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent) FeedSource(com.thinkbiganalytics.metadata.api.feed.FeedSource) Nonnull(javax.annotation.Nonnull) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Datasource(com.thinkbiganalytics.metadata.api.datasource.Datasource) 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) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) Consumer(java.util.function.Consumer) JcrCategory(com.thinkbiganalytics.metadata.modeshape.category.JcrCategory) ID(com.thinkbiganalytics.metadata.api.feed.Feed.ID) Condition(com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) ObligationBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationBuilder) JcrObject(com.thinkbiganalytics.metadata.modeshape.common.JcrObject) DatasourceProvider(com.thinkbiganalytics.metadata.api.datasource.DatasourceProvider) VersionProviderMixin(com.thinkbiganalytics.metadata.modeshape.common.mixin.VersionProviderMixin) Collections(java.util.Collections) FeedChange(com.thinkbiganalytics.metadata.api.event.feed.FeedChange) FeedChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent) Principal(java.security.Principal) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 2 with ChangeType

use of com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType in project kylo by Teradata.

the class JcrFeedTemplateProvider method addPostFeedChangeAction.

/**
 * Registers an action that produces a template change event upon a successful transaction commit.
 *
 * @param template the feed to being created
 */
private void addPostFeedChangeAction(FeedManagerTemplate template, ChangeType changeType) {
    FeedManagerTemplate.State state = template.getState();
    FeedManagerTemplate.ID id = template.getId();
    String desc = template.getName();
    DateTime createTime = template.getCreatedTime();
    final Principal principal = SecurityContextHolder.getContext().getAuthentication() != null ? SecurityContextHolder.getContext().getAuthentication() : null;
    Consumer<Boolean> action = (success) -> {
        if (success) {
            TemplateChange change = new TemplateChange(changeType, desc, id, state);
            TemplateChangeEvent event = new TemplateChangeEvent(change, createTime, principal);
            metadataEventService.notify(event);
        }
    };
    JcrMetadataAccess.addPostTransactionAction(action);
}
Also used : EntityUtil(com.thinkbiganalytics.metadata.modeshape.common.EntityUtil) ChangeType(com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType) HashMap(java.util.HashMap) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) StringUtils(org.apache.commons.lang3.StringUtils) AllowedActions(com.thinkbiganalytics.security.action.AllowedActions) Inject(javax.inject.Inject) TemplateChangeEvent(com.thinkbiganalytics.metadata.api.event.template.TemplateChangeEvent) JcrQueryUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) Map(java.util.Map) TemplateAccessControl(com.thinkbiganalytics.metadata.api.template.security.TemplateAccessControl) AccessController(com.thinkbiganalytics.security.AccessController) JcrAllowedEntityActionsProvider(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedEntityActionsProvider) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) FeedManagerTemplateProvider(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplateProvider) DateTime(org.joda.time.DateTime) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) Serializable(java.io.Serializable) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) Consumer(java.util.function.Consumer) SecurityRoleProvider(com.thinkbiganalytics.security.role.SecurityRoleProvider) List(java.util.List) Principal(java.security.Principal) JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) TemplateChange(com.thinkbiganalytics.metadata.api.event.template.TemplateChange) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) TemplateDeletionException(com.thinkbiganalytics.metadata.api.template.TemplateDeletionException) BaseJcrProvider(com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) JcrEntity(com.thinkbiganalytics.metadata.modeshape.common.JcrEntity) TemplateChange(com.thinkbiganalytics.metadata.api.event.template.TemplateChange) TemplateChangeEvent(com.thinkbiganalytics.metadata.api.event.template.TemplateChangeEvent) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) DateTime(org.joda.time.DateTime) Principal(java.security.Principal)

Aggregations

ChangeType (com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType)2 MetadataEventService (com.thinkbiganalytics.metadata.api.event.MetadataEventService)2 FeedManagerTemplate (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate)2 BaseJcrProvider (com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider)2 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)2 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)2 EntityUtil (com.thinkbiganalytics.metadata.modeshape.common.EntityUtil)2 JcrEntity (com.thinkbiganalytics.metadata.modeshape.common.JcrEntity)2 JcrAllowedActions (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions)2 Predicate (com.google.common.base.Predicate)1 Strings (com.google.common.base.Strings)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 DatasourceProvider (com.thinkbiganalytics.metadata.api.datasource.DatasourceProvider)1 FeedChange (com.thinkbiganalytics.metadata.api.event.feed.FeedChange)1 FeedChangeEvent (com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent)1 FeedPropertyChangeEvent (com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent)1