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());
}
}
}
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());
}
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());
}
Aggregations