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