Search in sources :

Example 1 with EventPublisherEvent

use of org.wso2.carbon.apimgt.eventing.EventPublisherEvent in project carbon-apimgt by wso2.

the class APIProviderImpl method publishKeyTemplateEvent.

private void publishKeyTemplateEvent(String templateValue, String state) {
    Object[] objects = new Object[] { templateValue, state };
    Event keyTemplateMessage = new Event(APIConstants.KEY_TEMPLATE_STREM_ID, System.currentTimeMillis(), null, null, objects);
    ThrottleProperties throttleProperties = getAPIManagerConfiguration().getThrottleProperties();
    EventPublisherEvent keyTemplateEvent = new EventPublisherEvent(APIConstants.KEY_TEMPLATE_STREM_ID, System.currentTimeMillis(), objects, keyTemplateMessage.toString());
    APIUtil.publishEvent(EventPublisherType.KEY_TEMPLATE, keyTemplateEvent, keyTemplateMessage.toString());
}
Also used : EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent) GlobalPolicyEvent(org.wso2.carbon.apimgt.impl.notifier.events.GlobalPolicyEvent) ScopeEvent(org.wso2.carbon.apimgt.impl.notifier.events.ScopeEvent) APIPolicyEvent(org.wso2.carbon.apimgt.impl.notifier.events.APIPolicyEvent) ApplicationPolicyEvent(org.wso2.carbon.apimgt.impl.notifier.events.ApplicationPolicyEvent) LifeCycleEvent(org.wso2.carbon.apimgt.api.model.LifeCycleEvent) Event(org.wso2.carbon.databridge.commons.Event) CertificateEvent(org.wso2.carbon.apimgt.impl.notifier.events.CertificateEvent) SubscriptionPolicyEvent(org.wso2.carbon.apimgt.impl.notifier.events.SubscriptionPolicyEvent) SubscriptionEvent(org.wso2.carbon.apimgt.impl.notifier.events.SubscriptionEvent) EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent) APIEvent(org.wso2.carbon.apimgt.impl.notifier.events.APIEvent) JSONObject(org.json.simple.JSONObject) ThrottleProperties(org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)

Example 2 with EventPublisherEvent

use of org.wso2.carbon.apimgt.eventing.EventPublisherEvent in project carbon-apimgt by wso2.

the class WebhooksSubscriptionEventHandler method sendSubscriptionNotificationOnRealtime.

/**
 * Method to publish the subscription request on to the realtime message broker
 *
 * @param event realtime notification data read from the event
 */
private void sendSubscriptionNotificationOnRealtime(WebhooksSubscriptionEvent event, boolean isSuccess) {
    Object[] objects = new Object[] { event.getApiUUID(), event.getApiName(), event.getApiContext(), event.getApiVersion(), event.getAppID(), event.getTenantDomain(), event.getTenantId(), event.getCallback(), event.getTopic(), event.getMode(), event.getSecret(), event.getExpiryTime(), event.getSubscriberName(), event.getApplicationTier(), event.getTier(), event.getApiTier(), !isSuccess };
    EventPublisherEvent asyncWebhooksEvent = new EventPublisherEvent(APIConstants.WEBHOOKS_SUBSCRIPTION_STREAM_ID, System.currentTimeMillis(), objects);
    APIUtil.publishEvent(EventPublisherType.ASYNC_WEBHOOKS, asyncWebhooksEvent, asyncWebhooksEvent.toString());
}
Also used : EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent)

Example 3 with EventPublisherEvent

use of org.wso2.carbon.apimgt.eventing.EventPublisherEvent in project carbon-apimgt by wso2.

the class KeyMgtNotificationSender method notify.

public void notify(KeyManagerConfigurationDTO keyManagerConfigurationDTO, String action) {
    String encodedString = "";
    if (keyManagerConfigurationDTO.getAdditionalProperties() != null) {
        String additionalProperties = new Gson().toJson(keyManagerConfigurationDTO.getAdditionalProperties());
        encodedString = new String(Base64.encodeBase64(additionalProperties.getBytes()));
    }
    Object[] objects = new Object[] { APIConstants.KeyManager.KeyManagerEvent.KEY_MANAGER_CONFIGURATION, action, keyManagerConfigurationDTO.getName(), keyManagerConfigurationDTO.getType(), keyManagerConfigurationDTO.isEnabled(), encodedString, keyManagerConfigurationDTO.getOrganization(), keyManagerConfigurationDTO.getTokenType() };
    Event keyManagerEvent = new Event(APIConstants.KeyManager.KeyManagerEvent.KEY_MANAGER_STREAM_ID, System.currentTimeMillis(), null, null, objects);
    EventHubConfigurationDto eventHubConfigurationDto = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration().getEventHubConfigurationDto();
    if (eventHubConfigurationDto.isEnabled()) {
        EventPublisherEvent notificationEvent = new EventPublisherEvent(APIConstants.KeyManager.KeyManagerEvent.KEY_MANAGER_STREAM_ID, System.currentTimeMillis(), objects, keyManagerEvent.toString());
        APIUtil.publishEvent(EventPublisherType.KEYMGT_EVENT, notificationEvent, keyManagerEvent.toString());
    }
}
Also used : EventHubConfigurationDto(org.wso2.carbon.apimgt.impl.dto.EventHubConfigurationDto) EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent) Gson(com.google.gson.Gson) Event(org.wso2.carbon.databridge.commons.Event) EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent)

Example 4 with EventPublisherEvent

use of org.wso2.carbon.apimgt.eventing.EventPublisherEvent in project carbon-apimgt by wso2.

the class APIAuthenticationAdminClient method publishEvent.

/**
 * Publishes events through event publisher
 *
 * @param objectData - The event payload data.
 */
private void publishEvent(Object[] objectData) {
    EventPublisherEvent cacheInvalidationEvent = new EventPublisherEvent(APIConstants.CACHE_INVALIDATION_STREAM_ID, System.currentTimeMillis(), objectData);
    APIUtil.publishEvent(EventPublisherType.CACHE_INVALIDATION, cacheInvalidationEvent, cacheInvalidationEvent.toString());
}
Also used : EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent)

Example 5 with EventPublisherEvent

use of org.wso2.carbon.apimgt.eventing.EventPublisherEvent in project carbon-apimgt by wso2.

the class AbstractNotifier method publishEventToEventHub.

protected void publishEventToEventHub(Event event) {
    byte[] bytesEncoded = Base64.encodeBase64(new Gson().toJson(event).getBytes());
    Object[] objects = new Object[] { event.getType(), event.getTimeStamp(), new String(bytesEncoded) };
    // Decoded event string to be logged in the case of failures and debugging
    String loggingEvent = event.toString();
    EventPublisherEvent notificationEvent = new EventPublisherEvent(APIConstants.NOTIFICATION_STREAM_ID, System.currentTimeMillis(), objects, loggingEvent);
    APIUtil.publishEvent(EventPublisherType.NOTIFICATION, notificationEvent, loggingEvent);
}
Also used : EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent) Gson(com.google.gson.Gson)

Aggregations

EventPublisherEvent (org.wso2.carbon.apimgt.eventing.EventPublisherEvent)8 Event (org.wso2.carbon.databridge.commons.Event)3 Gson (com.google.gson.Gson)2 JSONObject (org.json.simple.JSONObject)2 LifeCycleEvent (org.wso2.carbon.apimgt.api.model.LifeCycleEvent)2 APIEvent (org.wso2.carbon.apimgt.impl.notifier.events.APIEvent)2 APIPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.APIPolicyEvent)2 ApplicationPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.ApplicationPolicyEvent)2 CertificateEvent (org.wso2.carbon.apimgt.impl.notifier.events.CertificateEvent)2 GlobalPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.GlobalPolicyEvent)2 ScopeEvent (org.wso2.carbon.apimgt.impl.notifier.events.ScopeEvent)2 SubscriptionEvent (org.wso2.carbon.apimgt.impl.notifier.events.SubscriptionEvent)2 SubscriptionPolicyEvent (org.wso2.carbon.apimgt.impl.notifier.events.SubscriptionPolicyEvent)2 JsonObject (com.google.gson.JsonObject)1 EventHubConfigurationDto (org.wso2.carbon.apimgt.impl.dto.EventHubConfigurationDto)1 ThrottleProperties (org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)1