/*
 *  Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.wso2.carbon.apimgt.gateway.handlers.streaming.sse.analytics;

import org.apache.synapse.MessageContext;

/**
 * Data provider for the response events of server sent events.
 */
public class SseResponseEventDataProvider extends AsyncAnalyticsDataProvider {

    private int responseCode;

    public SseResponseEventDataProvider(MessageContext messageContext) {
        super(messageContext);
    }

    @Override
    public int getTargetResponseCode() {
        return responseCode;
    }

    @Override
    public int getProxyResponseCode() {
        return responseCode;
    }

    public void setResponseCode(int responseCode) {
        this.responseCode = responseCode;
    }
}

@@ -788,16 +788,146 @@
 Context;
+%0Aimport org.wso2.carbon.apimgt.common.gateway.analytics.publishers.dto.Operation;%0Aimport org.wso2.carbon.apimgt.impl.APIConstants;
 %0A%0A/**%0A *
@@ -1101,16 +1101,59 @@
 nseCode;
+%0A    private MessageContext messageContext;
 %0A%0A    pu
@@ -1250,16 +1250,62 @@
 ntext);%0A
+        this.messageContext = messageContext;%0A
     %7D%0A%0A 
@@ -1440,32 +1440,32 @@
 esponseCode() %7B%0A
-
         return r
@@ -1480,24 +1480,334 @@
 ode;%0A    %7D%0A%0A
+    @Override%0A    public Operation getOperation() %7B%0A%0A        Operation operation = super.getOperation();%0A        String apiResourceTemplate = (String) messageContext.getProperty(APIConstants.API_ELECTED_RESOURCE);%0A        operation.setApiResourceTemplate(apiResourceTemplate);%0A        return operation;%0A    %7D%0A%0A
     public v

Refactor sse response event provider