Search in sources :

Example 26 with EventListener

use of org.springframework.context.event.EventListener in project cas by apereo.

the class DefaultCasEventListener method handleCasAuthenticationPolicyFailureEvent.

/**
 * Handle cas authentication policy failure event.
 *
 * @param event the event
 */
@EventListener
public void handleCasAuthenticationPolicyFailureEvent(final CasAuthenticationPolicyFailureEvent event) {
    if (this.casEventRepository != null) {
        final CasEvent dto = prepareCasEvent(event);
        dto.setPrincipalId(event.getAuthentication().getPrincipal().getId());
        dto.putId(CasAuthenticationPolicyFailureEvent.class.getSimpleName());
        this.casEventRepository.save(dto);
    }
}
Also used : AbstractCasEvent(org.apereo.cas.support.events.AbstractCasEvent) CasEvent(org.apereo.cas.support.events.dao.CasEvent) CasAuthenticationPolicyFailureEvent(org.apereo.cas.support.events.authentication.CasAuthenticationPolicyFailureEvent) EventListener(org.springframework.context.event.EventListener)

Example 27 with EventListener

use of org.springframework.context.event.EventListener in project cas by apereo.

the class DefaultCasEventListener method handleCasTicketGrantingTicketCreatedEvent.

/**
 * Handle TGT creation event.
 *
 * @param event the event
 */
@EventListener
public void handleCasTicketGrantingTicketCreatedEvent(final CasTicketGrantingTicketCreatedEvent event) {
    if (this.casEventRepository != null) {
        final CasEvent dto = prepareCasEvent(event);
        dto.setCreationTime(event.getTicketGrantingTicket().getCreationTime().toString());
        dto.putId(TicketIdSanitizationUtils.sanitize(event.getTicketGrantingTicket().getId()));
        dto.setPrincipalId(event.getTicketGrantingTicket().getAuthentication().getPrincipal().getId());
        this.casEventRepository.save(dto);
    }
}
Also used : AbstractCasEvent(org.apereo.cas.support.events.AbstractCasEvent) CasEvent(org.apereo.cas.support.events.dao.CasEvent) EventListener(org.springframework.context.event.EventListener)

Example 28 with EventListener

use of org.springframework.context.event.EventListener in project metacat by Netflix.

the class SNSNotificationServiceImpl method notifyOfTableRename.

/**
 * {@inheritDoc}
 */
@Override
@EventListener
public void notifyOfTableRename(final MetacatRenameTablePostEvent event) {
    log.debug("Received RenameTableEvent {}", event);
    UpdateTableMessage message = null;
    try {
        message = this.createUpdateTableMessage(UUID.randomUUID().toString(), event.getRequestContext().getTimestamp(), event.getRequestContext().getId(), event.getName().toString(), event.getOldTable(), event.getCurrentTable());
        this.publishNotification(this.tableTopicArn, message, event.getName(), "Unable to publish rename table notification", Metrics.CounterSNSNotificationTableRename.getMetricName(), true);
    } catch (final Exception e) {
        this.notificationMetric.handleException(event.getName(), "Unable to create json patch for rename table notification", Metrics.CounterSNSNotificationTableRename.getMetricName(), message, e);
    }
}
Also used : UpdateTableMessage(com.netflix.metacat.common.dto.notifications.sns.messages.UpdateTableMessage) InvalidParameterException(com.amazonaws.services.sns.model.InvalidParameterException) IOException(java.io.IOException) InvalidParameterValueException(com.amazonaws.services.sns.model.InvalidParameterValueException) EventListener(org.springframework.context.event.EventListener)

Example 29 with EventListener

use of org.springframework.context.event.EventListener in project metacat by Netflix.

the class SNSNotificationServiceImpl method notifyOfPartitionAddition.

/**
 * {@inheritDoc}
 */
@Override
@EventListener
public void notifyOfPartitionAddition(final MetacatSaveTablePartitionPostEvent event) {
    log.debug("Received SaveTablePartitionPostEvent {}", event);
    final String name = event.getName().toString();
    final long timestamp = event.getRequestContext().getTimestamp();
    final String requestId = event.getRequestContext().getId();
    // Publish a global message stating how many partitions were updated for the table to the table topic
    final TablePartitionsUpdatePayload partitionsUpdatePayload;
    if (this.config.isSnsNotificationAttachPartitionIdsEnabled() && event.getPartitions() != null) {
        partitionsUpdatePayload = createTablePartitionsUpdatePayload(event.getPartitions(), event, false);
    } else {
        partitionsUpdatePayload = new TablePartitionsUpdatePayload(event.getPartitions().size(), 0, Lists.newArrayList(), Lists.newArrayList(), PARTITION_ID_UNENABLED);
    }
    final UpdateTablePartitionsMessage tableMessage = new UpdateTablePartitionsMessage(UUID.randomUUID().toString(), timestamp, requestId, name, partitionsUpdatePayload);
    this.publishNotification(this.tableTopicArn, tableMessage, event.getName(), "Unable to publish table partition add notification", Metrics.CounterSNSNotificationTablePartitionAdd.getMetricName(), true);
    if (config.isSnsNotificationTopicPartitionEnabled()) {
        AddPartitionMessage message = null;
        for (final PartitionDto partition : event.getPartitions()) {
            message = new AddPartitionMessage(UUID.randomUUID().toString(), timestamp, requestId, name, partition);
            this.publishNotification(this.partitionTopicArn, message, event.getName(), "Unable to publish partition creation notification", Metrics.CounterSNSNotificationPartitionAdd.getMetricName(), true);
            log.debug("Published create partition message {} on {}", message, this.partitionTopicArn);
        }
    }
}
Also used : TablePartitionsUpdatePayload(com.netflix.metacat.common.dto.notifications.sns.payloads.TablePartitionsUpdatePayload) PartitionDto(com.netflix.metacat.common.dto.PartitionDto) UpdateTablePartitionsMessage(com.netflix.metacat.common.dto.notifications.sns.messages.UpdateTablePartitionsMessage) AddPartitionMessage(com.netflix.metacat.common.dto.notifications.sns.messages.AddPartitionMessage) EventListener(org.springframework.context.event.EventListener)

Example 30 with EventListener

use of org.springframework.context.event.EventListener in project metacat by Netflix.

the class SNSNotificationServiceImpl method notifyOfTableCreation.

/**
 * {@inheritDoc}
 */
@Override
@EventListener
public void notifyOfTableCreation(final MetacatCreateTablePostEvent event) {
    log.debug("Received CreateTableEvent {}", event);
    final CreateTableMessage message = new CreateTableMessage(UUID.randomUUID().toString(), event.getRequestContext().getTimestamp(), event.getRequestContext().getId(), event.getName().toString(), event.getTable());
    this.publishNotification(this.tableTopicArn, message, event.getName(), "Unable to publish create table notification", Metrics.CounterSNSNotificationTableCreate.getMetricName(), true);
}
Also used : CreateTableMessage(com.netflix.metacat.common.dto.notifications.sns.messages.CreateTableMessage) EventListener(org.springframework.context.event.EventListener)

Aggregations

EventListener (org.springframework.context.event.EventListener)34 TableDto (com.netflix.metacat.common.dto.TableDto)10 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)6 AbstractCasEvent (org.apereo.cas.support.events.AbstractCasEvent)4 CasEvent (org.apereo.cas.support.events.dao.CasEvent)4 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)3 AntivirusJobResponse (com.odysseusinc.arachne.portal.service.impl.antivirus.events.AntivirusJobResponse)3 IOException (java.io.IOException)3 List (java.util.List)3 Transactional (org.springframework.transaction.annotation.Transactional)3 InvalidParameterException (com.amazonaws.services.sns.model.InvalidParameterException)2 InvalidParameterValueException (com.amazonaws.services.sns.model.InvalidParameterValueException)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)2 NameDateDto (com.netflix.metacat.common.NameDateDto)2 QualifiedName (com.netflix.metacat.common.QualifiedName)2 UpdateTableMessage (com.netflix.metacat.common.dto.notifications.sns.messages.UpdateTableMessage)2 UpdateTablePartitionsMessage (com.netflix.metacat.common.dto.notifications.sns.messages.UpdateTablePartitionsMessage)2 TablePartitionsUpdatePayload (com.netflix.metacat.common.dto.notifications.sns.payloads.TablePartitionsUpdatePayload)2 MetacatJsonLocator (com.netflix.metacat.common.json.MetacatJsonLocator)2