Search in sources :

Example 21 with Broker

use of org.wso2.broker.core.Broker in project carbon-apimgt by wso2.

the class APIGatewayPublisherImpl method updatePolicy.

@Override
public void updatePolicy(PolicyValidationData policyValidationData) throws GatewayException {
    if (policyValidationData != null) {
        PolicyEvent policyEvent = new PolicyEvent(APIMgtConstants.GatewayEventTypes.POLICY_UPDATE);
        policyEvent.setId(policyValidationData.getId());
        policyEvent.setName(policyValidationData.getName());
        policyEvent.setStopOnQuotaReach(policyValidationData.isStopOnQuotaReach());
        publishToThrottleTopic(policyEvent);
        if (log.isDebugEnabled()) {
            log.debug("Policy : " + policyValidationData.getName() + " update event has been successfully " + "published " + "to broker");
        }
    }
}
Also used : PolicyEvent(org.wso2.carbon.apimgt.core.models.events.PolicyEvent)

Example 22 with Broker

use of org.wso2.broker.core.Broker 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 23 with Broker

use of org.wso2.broker.core.Broker 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 24 with Broker

use of org.wso2.broker.core.Broker 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 25 with Broker

use of org.wso2.broker.core.Broker 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)

Aggregations

Broker (org.wso2.carbon.apimgt.core.api.Broker)6 Test (org.junit.Test)5 API (org.wso2.carbon.apimgt.core.models.API)5 ArrayList (java.util.ArrayList)4 BrokerConfigProvider (org.wso2.broker.common.BrokerConfigProvider)3 APIEvent (org.wso2.carbon.apimgt.core.models.events.APIEvent)3 ApplicationEvent (org.wso2.carbon.apimgt.core.models.events.ApplicationEvent)3 BlockEvent (org.wso2.carbon.apimgt.core.models.events.BlockEvent)3 PolicyEvent (org.wso2.carbon.apimgt.core.models.events.PolicyEvent)3 SubscriptionEvent (org.wso2.carbon.apimgt.core.models.events.SubscriptionEvent)3 HikariDataSource (com.zaxxer.hikari.HikariDataSource)2 Path (java.nio.file.Path)2 GatewayException (org.wso2.carbon.apimgt.core.exception.GatewayException)2 ConfigProvider (org.wso2.carbon.config.provider.ConfigProvider)2 Gson (com.google.gson.Gson)1 JMSException (javax.jms.JMSException)1 TextMessage (javax.jms.TextMessage)1 Topic (javax.jms.Topic)1 TopicConnection (javax.jms.TopicConnection)1 TopicPublisher (javax.jms.TopicPublisher)1