Search in sources :

Example 6 with EventPublisherEvent

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

the class APIMgtCacheInvalidationRequestSender method send.

public void send(CacheEntryInfo cacheInfo) {
    if (cacheInvalidationConfiguration.isEnabled() && DataHolder.getInstance().isStarted()) {
        boolean excludedCachePresent = false;
        for (String excludedCache : cacheInvalidationConfiguration.getExcludedCaches()) {
            if (cacheInfo.getCacheName().contains(excludedCache)) {
                excludedCachePresent = true;
                break;
            }
        }
        if (!excludedCachePresent) {
            Object[] objects = new Object[] { cacheInfo.getCacheManagerName(), cacheInfo.getCacheName(), constructCacheKeyString(cacheInfo.getCacheKey()), cacheInfo.getTenantDomain(), cacheInfo.getTenantId(), cacheInvalidationConfiguration.getDomain(), DataHolder.getNodeId() };
            EventPublisherEvent globalCacheInvalidationEvent = new EventPublisherEvent(cacheInvalidationConfiguration.getStream(), System.currentTimeMillis(), objects);
            APIUtil.publishEvent(EventPublisherType.GLOBAL_CACHE_INVALIDATION, globalCacheInvalidationEvent, globalCacheInvalidationEvent.toString());
        }
    }
}
Also used : EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent) JsonObject(com.google.gson.JsonObject)

Example 7 with EventPublisherEvent

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

the class APIProviderImpl method publishBlockingEvent.

/**
 * Publishes the changes on blocking conditions.
 * @param blockConditionsDTO Blockcondition Dto event
 */
private void publishBlockingEvent(BlockConditionsDTO blockConditionsDTO, String state) {
    String conditionType = blockConditionsDTO.getConditionType();
    String conditionValue = blockConditionsDTO.getConditionValue();
    if (APIConstants.BLOCKING_CONDITIONS_IP.equals(conditionType) || APIConstants.BLOCK_CONDITION_IP_RANGE.equals(conditionType)) {
        conditionValue = StringEscapeUtils.escapeJava(conditionValue);
    }
    Object[] objects = new Object[] { blockConditionsDTO.getConditionId(), blockConditionsDTO.getConditionType(), conditionValue, state, tenantDomain };
    Event blockingMessage = new Event(APIConstants.BLOCKING_CONDITIONS_STREAM_ID, System.currentTimeMillis(), null, null, objects);
    EventPublisherEvent blockingEvent = new EventPublisherEvent(APIConstants.BLOCKING_CONDITIONS_STREAM_ID, System.currentTimeMillis(), objects, blockingMessage.toString());
    APIUtil.publishEvent(EventPublisherType.BLOCKING_EVENT, blockingEvent, blockingMessage.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)

Example 8 with EventPublisherEvent

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

the class TokenRevocationNotifierImpl method sendMessageOnRealtime.

/**
 * Method to publish the revoked token on to the realtime message broker
 *
 * @param revokedToken requested revoked token
 * @param properties realtime notifier properties read from the config
 */
@Override
public void sendMessageOnRealtime(String revokedToken, Properties properties) {
    // Variables related to Realtime Notifier
    String realtimeNotifierTTL = realTimeNotifierProperties.getProperty("ttl", DEFAULT_TTL);
    long expiryTimeForJWT = Long.parseLong(properties.getProperty("expiryTime"));
    String eventId = properties.getProperty(APIConstants.NotificationEvent.EVENT_ID);
    String tokenType = properties.getProperty(APIConstants.NotificationEvent.TOKEN_TYPE);
    int tenantId = (int) properties.get(APIConstants.NotificationEvent.TENANT_ID);
    Object[] objects = new Object[] { eventId, revokedToken, realtimeNotifierTTL, expiryTimeForJWT, tokenType, tenantId };
    EventPublisherEvent tokenRevocationEvent = new EventPublisherEvent(APIConstants.TOKEN_REVOCATION_STREAM_ID, System.currentTimeMillis(), objects);
    APIUtil.publishEvent(EventPublisherType.TOKEN_REVOCATION, tokenRevocationEvent, tokenRevocationEvent.toString());
}
Also used : EventPublisherEvent(org.wso2.carbon.apimgt.eventing.EventPublisherEvent)

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