Search in sources :

Example 36 with Event

use of org.wso2.siddhi.core.event.Event in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method updateApplication.

@Override
public void updateApplication(Application application) throws GatewayException {
    if (application != null) {
        ApplicationEvent applicationEvent = new ApplicationEvent(APIMgtConstants.GatewayEventTypes.APPLICATION_UPDATE);
        applicationEvent.setApplicationId(application.getId());
        applicationEvent.setName(application.getName());
        applicationEvent.setThrottlingTier(application.getPolicy().getUuid());
        applicationEvent.setSubscriber(application.getCreatedUser());
        publishToStoreTopic(applicationEvent);
        if (log.isDebugEnabled()) {
            log.debug("Application : " + application.getName() + " updated event has been successfully published " + "to broker");
        }
    }
}
Also used : ApplicationEvent(org.wso2.carbon.apimgt.core.models.events.ApplicationEvent)

Example 37 with Event

use of org.wso2.siddhi.core.event.Event in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method deleteAPISubscription.

/**
 * {@inheritDoc}
 */
@Override
public void deleteAPISubscription(List<SubscriptionValidationData> subscriptionValidationDataList) throws GatewayException {
    SubscriptionEvent subscriptionDeleteEvent = new SubscriptionEvent(APIMgtConstants.GatewayEventTypes.SUBSCRIPTION_DELETE);
    subscriptionDeleteEvent.setSubscriptionsList(subscriptionValidationDataList);
    publishToStoreTopic(subscriptionDeleteEvent);
    if (log.isDebugEnabled()) {
        log.debug("Subscription deleted event has been successfully published to broker");
    }
}
Also used : SubscriptionEvent(org.wso2.carbon.apimgt.core.models.events.SubscriptionEvent)

Example 38 with Event

use of org.wso2.siddhi.core.event.Event in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method addApplication.

@Override
public void addApplication(Application application) throws GatewayException {
    if (application != null) {
        ApplicationEvent applicationEvent = new ApplicationEvent(APIMgtConstants.GatewayEventTypes.APPLICATION_CREATE);
        applicationEvent.setApplicationId(application.getId());
        applicationEvent.setName(application.getName());
        applicationEvent.setThrottlingTier(application.getPolicy().getUuid());
        applicationEvent.setSubscriber(application.getCreatedUser());
        publishToStoreTopic(applicationEvent);
        if (log.isDebugEnabled()) {
            log.debug("Application : " + application.getName() + " created event has been successfully published " + "to broker");
        }
    }
}
Also used : ApplicationEvent(org.wso2.carbon.apimgt.core.models.events.ApplicationEvent)

Example 39 with Event

use of org.wso2.siddhi.core.event.Event in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method addBlockCondition.

@Override
public void addBlockCondition(BlockConditions blockConditions) throws GatewayException {
    if (blockConditions != null) {
        BlockEvent blockEvent = new BlockEvent(APIMgtConstants.GatewayEventTypes.BLOCK_CONDITION_ADD);
        blockEvent.setConditionId(blockConditions.getConditionId());
        blockEvent.setUuid(blockConditions.getUuid());
        blockEvent.setConditionType(blockConditions.getConditionType());
        blockEvent.setEnabled(blockConditions.isEnabled());
        blockEvent.setConditionValue(blockConditions.getConditionValue());
        if (APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITIONS_IP.equals(blockConditions.getConditionType())) {
            blockEvent.setFixedIp(APIUtils.ipToLong(blockConditions.getConditionValue()));
        }
        if (APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITION_IP_RANGE.equals(blockConditions.getConditionType())) {
            blockEvent.setStartingIP(APIUtils.ipToLong(blockConditions.getStartingIP()));
            blockEvent.setEndingIP(APIUtils.ipToLong(blockConditions.getEndingIP()));
        }
        publishToThrottleTopic(blockEvent);
        if (log.isDebugEnabled()) {
            log.debug("BlockCondition : " + blockConditions.getUuid() + " add event has been successfully " + "published " + "to broker");
        }
    }
}
Also used : BlockEvent(org.wso2.carbon.apimgt.core.models.events.BlockEvent)

Example 40 with Event

use of org.wso2.siddhi.core.event.Event in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method deleteThreatProtectionPolicy.

/**
 * {@inheritDoc}
 */
@Override
public void deleteThreatProtectionPolicy(ThreatProtectionPolicy policy) throws GatewayException {
    ThreatProtectionEvent event = new ThreatProtectionEvent(APIMgtConstants.GatewayEventTypes.THREAT_PROTECTION_POLICY_DELETE);
    event.setPolicy(policy);
    publishToThreatProtectionTopic(event);
}
Also used : ThreatProtectionEvent(org.wso2.carbon.apimgt.core.models.events.ThreatProtectionEvent)

Aggregations

APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)8 GatewayException (org.wso2.carbon.apimgt.core.exception.GatewayException)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 Event (org.wso2.carbon.apimgt.core.models.Event)5 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 SQLException (java.sql.SQLException)4 Test (org.testng.annotations.Test)4 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)4 Function (org.wso2.carbon.apimgt.core.models.Function)4 ZonedDateTime (java.time.ZonedDateTime)3 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)3 API (org.wso2.carbon.apimgt.core.models.API)3 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)3 ApplicationEvent (org.wso2.carbon.apimgt.core.models.events.ApplicationEvent)3 PolicyEvent (org.wso2.carbon.apimgt.core.models.events.PolicyEvent)3 ThreatProtectionEvent (org.wso2.carbon.apimgt.core.models.events.ThreatProtectionEvent)3 Gson (com.google.gson.Gson)2 URI (java.net.URI)2