Search in sources :

Example 16 with Broker

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

the class APIGatewayPublisherImpl method deleteApplication.

@Override
public void deleteApplication(String applicationId) throws GatewayException {
    if (applicationId != null) {
        ApplicationEvent applicationEvent = new ApplicationEvent(APIMgtConstants.GatewayEventTypes.APPLICATION_DELETE);
        applicationEvent.setApplicationId(applicationId);
        publishToStoreTopic(applicationEvent);
        if (log.isDebugEnabled()) {
            log.debug("Application : " + applicationId + " deleted event has been successfully published " + "to broker");
        }
    }
}
Also used : ApplicationEvent(org.wso2.carbon.apimgt.core.models.events.ApplicationEvent)

Example 17 with Broker

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

the class APIGatewayPublisherImpl method updateAPISubscriptionStatus.

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

Example 18 with Broker

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

the class APIGatewayPublisherImpl method updateAPI.

@Override
public void updateAPI(API api) throws GatewayException {
    // build the message to send
    APIEvent apiUpdateEvent = new APIEvent(APIMgtConstants.GatewayEventTypes.API_UPDATE);
    apiUpdateEvent.setLabels(api.getLabels());
    apiUpdateEvent.setApiSummary(toAPISummary(api));
    publishToPublisherTopic(apiUpdateEvent);
    if (log.isDebugEnabled()) {
        log.debug("API : " + api.getName() + " updated event has been successfully published to broker");
    }
}
Also used : APIEvent(org.wso2.carbon.apimgt.core.models.events.APIEvent)

Example 19 with Broker

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

the class APIGatewayPublisherImpl method deleteAPI.

@Override
public void deleteAPI(API api) throws GatewayException {
    // build the message to send
    APIEvent apiDeleteEvent = new APIEvent(APIMgtConstants.GatewayEventTypes.API_DELETE);
    apiDeleteEvent.setLabels(api.getLabels());
    apiDeleteEvent.setApiSummary(toAPISummary(api));
    publishToPublisherTopic(apiDeleteEvent);
    if (log.isDebugEnabled()) {
        log.debug("API : " + api.getName() + " deleted event has been successfully published to broker");
    }
    if (api.hasOwnGateway()) {
        // Delete the Gateway - check how we can assume that we complete the deletion
        try {
            List<String> labels = api.getLabels();
            if (labels != null && !labels.isEmpty()) {
                removeContainerBasedGateway(labels.toArray()[0].toString(), api);
            } else {
                log.error("Could not delete container based gateways as labels could not find in the API.");
            }
        } catch (ContainerBasedGatewayException e) {
            String msg = "Error while removing the container based gateway";
            throw new GatewayException(msg, e, ExceptionCodes.CONTAINER_GATEWAY_REMOVAL_FAILED);
        }
    }
}
Also used : APIEvent(org.wso2.carbon.apimgt.core.models.events.APIEvent) GatewayException(org.wso2.carbon.apimgt.core.exception.GatewayException) ContainerBasedGatewayException(org.wso2.carbon.apimgt.core.exception.ContainerBasedGatewayException) ContainerBasedGatewayException(org.wso2.carbon.apimgt.core.exception.ContainerBasedGatewayException)

Example 20 with Broker

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

the class APIGatewayPublisherImpl method updateBlockCondition.

@Override
public void updateBlockCondition(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() + " update 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