Search in sources :

Example 1 with NotificationEventService

use of org.wso2.carbon.apimgt.notification.NotificationEventService in project carbon-apimgt by wso2.

the class NotifyApiServiceImpl method notifyPost.

@Override
public Response notifyPost(String xWSO2KEYManager, String body, MessageContext messageContext) {
    try {
        NotificationEventService notificationEventService = (NotificationEventService) PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(NotificationEventService.class, new Hashtable<>());
        Map<String, List<String>> requestHeaders = messageContext.getHttpHeaders().getRequestHeaders();
        notificationEventService.processEvent(xWSO2KEYManager, body, requestHeaders);
        return Response.ok().build();
    } catch (APIManagementException e) {
        log.error("Error while processing notification", e);
        JSONObject responseObj = new JSONObject();
        responseObj.put("Message", e.getMessage());
        String responseStringObj = String.valueOf(responseObj);
        return Response.serverError().entity(responseStringObj).build();
    }
}
Also used : NotificationEventService(org.wso2.carbon.apimgt.notification.NotificationEventService) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) JSONObject(org.json.JSONObject) Hashtable(java.util.Hashtable) List(java.util.List)

Example 2 with NotificationEventService

use of org.wso2.carbon.apimgt.notification.NotificationEventService in project carbon-apimgt by wso2.

the class ApimgtNotificationServiceComponent method activate.

@Activate
protected void activate(ComponentContext ctxt) {
    ctxt.getBundleContext().registerService(KeyManagerEventHandler.class, new DefaultKeyManagerEventHandlerImpl(), null);
    ctxt.getBundleContext().registerService(EventHandler.class, new WebhooksSubscriptionEventHandler(), null);
    ctxt.getBundleContext().registerService(EventHandler.class, new WebhooksDeliveryEventHandler(), null);
    ctxt.getBundleContext().registerService(NotificationEventService.class, new NotificationEventService(), null);
}
Also used : NotificationEventService(org.wso2.carbon.apimgt.notification.NotificationEventService) WebhooksDeliveryEventHandler(org.wso2.carbon.apimgt.notification.WebhooksDeliveryEventHandler) DefaultKeyManagerEventHandlerImpl(org.wso2.carbon.apimgt.notification.DefaultKeyManagerEventHandlerImpl) WebhooksSubscriptionEventHandler(org.wso2.carbon.apimgt.notification.WebhooksSubscriptionEventHandler) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

NotificationEventService (org.wso2.carbon.apimgt.notification.NotificationEventService)2 Hashtable (java.util.Hashtable)1 List (java.util.List)1 JSONObject (org.json.JSONObject)1 Activate (org.osgi.service.component.annotations.Activate)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 DefaultKeyManagerEventHandlerImpl (org.wso2.carbon.apimgt.notification.DefaultKeyManagerEventHandlerImpl)1 WebhooksDeliveryEventHandler (org.wso2.carbon.apimgt.notification.WebhooksDeliveryEventHandler)1 WebhooksSubscriptionEventHandler (org.wso2.carbon.apimgt.notification.WebhooksSubscriptionEventHandler)1