Search in sources :

Example 1 with FeedChange

use of com.thinkbiganalytics.metadata.api.event.feed.FeedChange 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 FeedChange

use of com.thinkbiganalytics.metadata.api.event.feed.FeedChange in project kylo by Teradata.

the class DefaultFeedManagerFeedService method notifyFeedStateChange.

/**
 * update the audit information for feed state changes
 *
 * @param feedId     the feed id
 * @param state      the new state
 * @param changeType the event type
 */
private void notifyFeedStateChange(FeedMetadata feedMetadata, Feed.ID feedId, Feed.State state, MetadataChange.ChangeType changeType) {
    final Principal principal = SecurityContextHolder.getContext().getAuthentication() != null ? SecurityContextHolder.getContext().getAuthentication() : null;
    String feedName = feedMetadata != null ? feedMetadata.getCategoryAndFeedName() : "";
    FeedChange change = new FeedChange(changeType, feedName, feedName, feedId, state);
    FeedChangeEvent event = new FeedChangeEvent(change, DateTime.now(), principal);
    metadataEventService.notify(event);
}
Also used : FeedChange(com.thinkbiganalytics.metadata.api.event.feed.FeedChange) FeedChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent) Principal(java.security.Principal)

Aggregations

FeedChange (com.thinkbiganalytics.metadata.api.event.feed.FeedChange)2 FeedChangeEvent (com.thinkbiganalytics.metadata.api.event.feed.FeedChangeEvent)2 Principal (java.security.Principal)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 ChangeType (com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType)1 MetadataEventService (com.thinkbiganalytics.metadata.api.event.MetadataEventService)1 FeedPropertyChangeEvent (com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent)1 PropertyChange (com.thinkbiganalytics.metadata.api.event.feed.PropertyChange)1 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)1 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)1 ID (com.thinkbiganalytics.metadata.api.feed.Feed.ID)1 FeedCriteria (com.thinkbiganalytics.metadata.api.feed.FeedCriteria)1 FeedDestination (com.thinkbiganalytics.metadata.api.feed.FeedDestination)1