Search in sources :

Example 11 with ApplicationEvent

use of org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent 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 12 with ApplicationEvent

use of org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent 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 13 with ApplicationEvent

use of org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent in project carbon-apimgt by wso2.

the class MappingUtil method toApplicationDto.

/**
 * This method convert Application model to ApplicationEvent
 * @param application Contains application data
 * @return DTO containing application data
 */
public static ApplicationDTO toApplicationDto(Application application) {
    ApplicationDTO applicationDTO = new ApplicationDTO();
    applicationDTO.setApplicationId(application.getId());
    applicationDTO.setDescription(application.getDescription());
    applicationDTO.setName(application.getName());
    applicationDTO.setSubscriber(application.getCreatedUser());
    if (application.getPolicy() != null) {
        applicationDTO.setThrottlingTier(application.getPolicy().getPolicyName());
    }
    return applicationDTO;
}
Also used : ApplicationDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.ApplicationDTO)

Example 14 with ApplicationEvent

use of org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent in project carbon-apimgt by wso2.

the class AbstractAPIManager method addDefaultApplicationForSubscriber.

/**
 * Add default application on the first time a subscriber is added to the database
 *
 * @param subscriber Subscriber
 * @throws APIManagementException if an error occurs while adding default application
 */
private void addDefaultApplicationForSubscriber(Subscriber subscriber) throws APIManagementException {
    Application defaultApp = new Application(APIConstants.DEFAULT_APPLICATION_NAME, subscriber);
    if (APIUtil.isEnabledUnlimitedTier()) {
        defaultApp.setTier(APIConstants.UNLIMITED_TIER);
    } else {
        Map<String, Tier> throttlingTiers = APIUtil.getTiers(APIConstants.TIER_APPLICATION_TYPE, getTenantDomain(subscriber.getName()));
        Set<Tier> tierValueList = new HashSet<Tier>(throttlingTiers.values());
        List<Tier> sortedTierList = APIUtil.sortTiers(tierValueList);
        defaultApp.setTier(sortedTierList.get(0).getName());
    }
    // application will not be shared within the group
    defaultApp.setGroupId("");
    defaultApp.setTokenType(APIConstants.TOKEN_TYPE_JWT);
    defaultApp.setUUID(UUID.randomUUID().toString());
    defaultApp.setDescription(APIConstants.DEFAULT_APPLICATION_DESCRIPTION);
    int applicationId = apiMgtDAO.addApplication(defaultApp, subscriber.getName(), tenantDomain);
    ApplicationEvent applicationEvent = new ApplicationEvent(UUID.randomUUID().toString(), System.currentTimeMillis(), APIConstants.EventType.APPLICATION_CREATE.name(), tenantId, tenantDomain, applicationId, defaultApp.getUUID(), defaultApp.getName(), defaultApp.getTokenType(), defaultApp.getTier(), defaultApp.getGroupId(), defaultApp.getApplicationAttributes(), subscriber.getName());
    APIUtil.sendNotification(applicationEvent, APIConstants.NotifierType.APPLICATION.name());
}
Also used : Tier(org.wso2.carbon.apimgt.api.model.Tier) ApplicationEvent(org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent) Application(org.wso2.carbon.apimgt.api.model.Application) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 15 with ApplicationEvent

use of org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent in project carbon-apimgt by wso2.

the class SolaceApplicationNotifier method process.

/**
 * Process Application notifier event related to Solace applications
 *
 * @param event related to Application handling
 * @throws NotifierException if error occurs when casting event
 */
private void process(Event event) throws NotifierException {
    ApplicationEvent applicationEvent;
    applicationEvent = (ApplicationEvent) event;
    if (APIConstants.EventType.APPLICATION_DELETE.name().equals(event.getType())) {
        removeSolaceApplication(applicationEvent);
    } else if (APIConstants.EventType.APPLICATION_UPDATE.name().equals(event.getType())) {
        renameSolaceApplication(applicationEvent);
    }
}
Also used : ApplicationEvent(org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent)

Aggregations

ApplicationEvent (org.wso2.carbon.apimgt.impl.notifier.events.ApplicationEvent)7 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)6 Application (org.wso2.carbon.apimgt.api.model.Application)5 HashSet (java.util.HashSet)4 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)4 ArrayList (java.util.ArrayList)3 LinkedHashSet (java.util.LinkedHashSet)3 List (java.util.List)3 JSONObject (org.json.simple.JSONObject)3 APIRevisionDeployment (org.wso2.carbon.apimgt.api.model.APIRevisionDeployment)3 Environment (org.wso2.carbon.apimgt.api.model.Environment)3 Subscriber (org.wso2.carbon.apimgt.api.model.Subscriber)3 ApplicationEvent (org.wso2.carbon.apimgt.core.models.events.ApplicationEvent)3 ApplicationRegistrationWorkflowDTO (org.wso2.carbon.apimgt.impl.dto.ApplicationRegistrationWorkflowDTO)3 ApplicationWorkflowDTO (org.wso2.carbon.apimgt.impl.dto.ApplicationWorkflowDTO)3 SubscriptionWorkflowDTO (org.wso2.carbon.apimgt.impl.dto.SubscriptionWorkflowDTO)3 ApplicationRegistrationEvent (org.wso2.carbon.apimgt.impl.notifier.events.ApplicationRegistrationEvent)3 NotifierException (org.wso2.carbon.apimgt.impl.notifier.exceptions.NotifierException)3 RecommenderDetailsExtractor (org.wso2.carbon.apimgt.impl.recommendationmgt.RecommenderDetailsExtractor)3 RecommenderEventPublisher (org.wso2.carbon.apimgt.impl.recommendationmgt.RecommenderEventPublisher)3