Search in sources :

Example 1 with EventListener

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

the class DefaultCasEventListener method handleCasAuthenticationTransactionFailureEvent.

/**
     * Handle cas authentication policy failure event.
     *
     * @param event the event
     */
@EventListener
public void handleCasAuthenticationTransactionFailureEvent(final CasAuthenticationTransactionFailureEvent event) {
    if (this.casEventRepository != null) {
        final CasEvent dto = prepareCasEvent(event);
        dto.setPrincipalId(event.getCredential().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 2 with EventListener

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

the class DefaultCasEventListener method handleCasRiskyAuthenticationDetectedEvent.

/**
     * Handle cas risky authentication detected event.
     *
     * @param event the event
     */
@EventListener
public void handleCasRiskyAuthenticationDetectedEvent(final CasRiskyAuthenticationDetectedEvent event) {
    if (this.casEventRepository != null) {
        final CasEvent dto = prepareCasEvent(event);
        dto.putId(event.getService().getName());
        dto.setPrincipalId(event.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 3 with EventListener

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

the class MetacatElasticSearchEventHandlers method metacatUpdateTablePostEventHandler.

/**
     * Subscriber.
     *
     * @param event event
     */
@EventListener
public void metacatUpdateTablePostEventHandler(final MetacatUpdateTablePostEvent event) {
    log.debug("Received UpdateTableEvent {}", event);
    registry.counter(Metrics.CounterElasticSearchTableUpdate.name()).increment();
    final TableDto dto = event.getCurrentTable();
    final ElasticSearchDoc doc = new ElasticSearchDoc(dto.getName().toString(), dto, event.getRequestContext().getUserName(), false);
    final ElasticSearchDoc oldDoc = es.get(ElasticSearchDoc.Type.table.name(), doc.getId());
    es.save(ElasticSearchDoc.Type.table.name(), doc.getId(), doc.toJsonString());
    if (oldDoc == null || oldDoc.getDto() == null || !Objects.equals(((TableDto) oldDoc.getDto()).getDataMetadata(), dto.getDataMetadata())) {
        updateEntitiesWithSameUri(ElasticSearchDoc.Type.table.name(), dto, event.getRequestContext());
    }
}
Also used : TableDto(com.netflix.metacat.common.dto.TableDto) EventListener(org.springframework.context.event.EventListener)

Example 4 with EventListener

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

the class MetacatElasticSearchEventHandlers method metacatDeleteTablePostEventHandler.

/**
     * Subscriber.
     *
     * @param event event
     */
@EventListener
public void metacatDeleteTablePostEventHandler(final MetacatDeleteTablePostEvent event) {
    log.debug("Received DeleteTableEvent {}", event);
    registry.counter(Metrics.CounterElasticSearchTableDelete.name()).increment();
    final TableDto dto = event.getTable();
    es.softDelete(ElasticSearchDoc.Type.table.name(), dto.getName().toString(), event.getRequestContext());
    try {
        final List<String> partitionIdsToBeDeleted = es.getIdsByQualifiedName(ElasticSearchDoc.Type.partition.name(), dto.getName());
        es.delete(ElasticSearchDoc.Type.partition.name(), partitionIdsToBeDeleted);
    } catch (Exception e) {
        log.warn("Failed deleting the partitions for the dropped table/view:{}", dto.getName().toString());
    }
}
Also used : TableDto(com.netflix.metacat.common.dto.TableDto) EventListener(org.springframework.context.event.EventListener)

Example 5 with EventListener

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

the class MetacatElasticSearchEventHandlers method metacatDeleteDatabasePostEventHandler.

/**
     * Subscriber.
     *
     * @param event event
     */
@EventListener
public void metacatDeleteDatabasePostEventHandler(final MetacatDeleteDatabasePostEvent event) {
    log.debug("Received DeleteDatabaseEvent {}", event);
    registry.counter(Metrics.CounterElasticSearchDatabaseDelete.name()).increment();
    final DatabaseDto dto = event.getDatabase();
    es.softDelete(ElasticSearchDoc.Type.database.name(), dto.getName().toString(), event.getRequestContext());
}
Also used : DatabaseDto(com.netflix.metacat.common.dto.DatabaseDto) EventListener(org.springframework.context.event.EventListener)

Aggregations

EventListener (org.springframework.context.event.EventListener)19 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)6 IOException (java.io.IOException)6 TableDto (com.netflix.metacat.common.dto.TableDto)5 AbstractCasEvent (org.apereo.cas.support.events.AbstractCasEvent)4 CasEvent (org.apereo.cas.support.events.dao.CasEvent)4 DatabaseDto (com.netflix.metacat.common.dto.DatabaseDto)3 PartitionDto (com.netflix.metacat.common.dto.PartitionDto)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 CasAuthenticationPolicyFailureEvent (org.apereo.cas.support.events.authentication.CasAuthenticationPolicyFailureEvent)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 User (com.naturalprogrammer.spring.tutorial.domain.User)1 MetacatRequestContext (com.netflix.metacat.common.MetacatRequestContext)1 AddPartitionMessage (com.netflix.metacat.common.dto.notifications.sns.messages.AddPartitionMessage)1 CreateTableMessage (com.netflix.metacat.common.dto.notifications.sns.messages.CreateTableMessage)1 DeletePartitionMessage (com.netflix.metacat.common.dto.notifications.sns.messages.DeletePartitionMessage)1 DeleteTableMessage (com.netflix.metacat.common.dto.notifications.sns.messages.DeleteTableMessage)1 MetacatJsonLocator (com.netflix.metacat.common.json.MetacatJsonLocator)1