Search in sources :

Example 1 with TemplateChange

use of com.thinkbiganalytics.metadata.api.event.template.TemplateChange in project kylo by Teradata.

the class DefaultFeedManagerTemplateService method notifyTemplateStateChange.

/**
 * update audit information for template changes
 *
 * @param template   the template
 * @param templateId the template id
 * @param state      the new state
 * @param changeType the type of change
 */
private void notifyTemplateStateChange(RegisteredTemplate template, FeedManagerTemplate.ID templateId, FeedManagerTemplate.State state, MetadataChange.ChangeType changeType) {
    final Principal principal = SecurityContextHolder.getContext().getAuthentication() != null ? SecurityContextHolder.getContext().getAuthentication() : null;
    TemplateChange change = new TemplateChange(changeType, template != null ? template.getTemplateName() : "", templateId, state);
    TemplateChangeEvent event = new TemplateChangeEvent(change, DateTime.now(), principal);
    metadataEventService.notify(event);
}
Also used : TemplateChange(com.thinkbiganalytics.metadata.api.event.template.TemplateChange) TemplateChangeEvent(com.thinkbiganalytics.metadata.api.event.template.TemplateChangeEvent) Principal(java.security.Principal)

Example 2 with TemplateChange

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

TemplateChange (com.thinkbiganalytics.metadata.api.event.template.TemplateChange)2 TemplateChangeEvent (com.thinkbiganalytics.metadata.api.event.template.TemplateChangeEvent)2 Principal (java.security.Principal)2 ChangeType (com.thinkbiganalytics.metadata.api.event.MetadataChange.ChangeType)1 MetadataEventService (com.thinkbiganalytics.metadata.api.event.MetadataEventService)1 FeedManagerTemplate (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate)1 FeedManagerTemplateProvider (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplateProvider)1 TemplateDeletionException (com.thinkbiganalytics.metadata.api.template.TemplateDeletionException)1 TemplateAccessControl (com.thinkbiganalytics.metadata.api.template.security.TemplateAccessControl)1 BaseJcrProvider (com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider)1 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)1 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)1 EntityUtil (com.thinkbiganalytics.metadata.modeshape.common.EntityUtil)1 JcrEntity (com.thinkbiganalytics.metadata.modeshape.common.JcrEntity)1 JcrAllowedActions (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions)1 JcrAllowedEntityActionsProvider (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedEntityActionsProvider)1 JcrQueryUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil)1 JcrUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrUtil)1 AccessController (com.thinkbiganalytics.security.AccessController)1 AllowedActions (com.thinkbiganalytics.security.action.AllowedActions)1